码迷,mamicode.com
首页 > 其他好文 > 详细

5.2 nc + JMX查看分布式程序数据

时间:2018-10-11 22:36:06      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:shel   发送   pid   mem   使用   RKE   new   write   lin   

JMX即java管理扩展服务

1、先在s101开启nc服务端

nc -lk 8888

2、先开启spark shell

spark-shell --master spark:s101:7077

3、使用shell

//工具函数,将分布式程序中所需数据回传到执行节点
def sendInfo(obj:Object ,m:String , param:String)= { val ip = java.net.InetAddress.getLocalHost.getHostAddress val pid = java.lang.management.ManagementFactory.getRuntimeMXBean.getName.split("@")(0) val tname = Thread.currentThread().getName val classname = obj.getClass.getSimpleName val objHash = obj.hashCode() val info = "ip:" + ip + "/" + "pid:" + pid + "/" +"当前线程:" + tname + "/" + "当前对象:" +
classname + "@" + objHash + "/" +"方法:" + m + "/" + "文本:" + param + "\r\n" //发送数据给nc 服务器 val sock = new java.net.Socket("s101" , 8888) val out = sock.getOutputStream out.write(info.getBytes()) out.flush() out.close() }
val rdd1 = sc.textFile("myspark/wc" , 3)
val rdd2 = rdd1.flatMap(line=>{
sendInfo(this , "flatMap" , line)
line.split(" ")}
)
val rdd3 = rdd2.coalesce(4,true)
val rdd4 = rdd3.map(word=>{
sendInfo(this , "map" , word)
(word,1)
})
val rdd5 = rdd4.reduceByKey((a,b)=>{
sendInfo(this, "reduceByKey", a + "," + b)
a + b
},5)
val arr = rdd5.collect()

数据

ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@2033283521/方法:flatMap/文本:8 6 7
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@2033283521/方法:flatMap/文本:9 8 9
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@2033283521/方法:flatMap/文本:0 5 6

ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@1991892807/方法:map/文本:7
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@1991892807/方法:map/文本:0
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@1991892807/方法:map/文本:1
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@1991892807/方法:map/文本:7
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@1991892807/方法:map/文本:3
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@1991892807/方法:map/文本:3
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@1991892807/方法:map/文本:8

ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@157045983/方法:reduceByKey/文本:1,1
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@157045983/方法:reduceByKey/文本:1,1

ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@578058632/方法:reduceByKey/文本:1,1
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@578058632/方法:reduceByKey/文本:2,1
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-1/当前对象:$iw@578058632/方法:reduceByKey/文本:2,1

ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-0/当前对象:$iw@437061105/方法:reduceByKey/文本:1,1
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-0/当前对象:$iw@437061105/方法:reduceByKey/文本:1,1
ip:192.168.137.102/pid:7070/当前线程:Executor task launch worker-0/当前对象:$iw@437061105/方法:reduceByKey/文本:2,2
------------------------------------------------------------------------------------------------------------------------------------------
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@774135418/方法:flatMap/文本:1 2 3
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@774135418/方法:flatMap/文本:2 4 5
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@774135418/方法:flatMap/文本:3 6 7
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@774135418/方法:flatMap/文本:4 8 9

ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1721291521/方法:map/文本:0
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1721291521/方法:map/文本:3
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1721291521/方法:map/文本:2
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1721291521/方法:map/文本:5
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1721291521/方法:map/文本:4
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1721291521/方法:map/文本:6
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1721291521/方法:map/文本:9

ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:1
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:4
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:7
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:5
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:2
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:5
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:8
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:8
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1352742443/方法:map/文本:6

ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1645250114/方法:reduceByKey/文本:1,1
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1645250114/方法:reduceByKey/文本:1,1

ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1398861210/方法:reduceByKey/文本:1,1
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1398861210/方法:reduceByKey/文本:2,2
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-1/当前对象:$iw@1398861210/方法:reduceByKey/文本:1,1

ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1022819022/方法:reduceByKey/文本:1,2
ip:192.168.137.103/pid:5996/当前线程:Executor task launch worker-0/当前对象:$iw@1022819022/方法:reduceByKey/文本:2,1
---------------------------------------------------------------------------------------------------------------------------------------
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@388488515/方法:flatMap/文本:5 0 1
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@388488515/方法:flatMap/文本:6 2 3
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@388488515/方法:flatMap/文本:7 4 5

ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@952442015/方法:map/文本:6
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@952442015/方法:map/文本:6
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@952442015/方法:map/文本:9
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@952442015/方法:map/文本:9
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@952442015/方法:map/文本:4
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@952442015/方法:map/文本:5
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@952442015/方法:map/文本:2

ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@2087943646/方法:reduceByKey/文本:1,1
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@2087943646/方法:reduceByKey/文本:1,1

ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@1851342893/方法:reduceByKey/文本:1,1
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@1851342893/方法:reduceByKey/文本:2,1
ip:192.168.137.104/pid:5673/当前线程:Executor task launch worker-0/当前对象:$iw@1851342893/方法:reduceByKey/文本:2,1

 

5.2 nc + JMX查看分布式程序数据

标签:shel   发送   pid   mem   使用   RKE   new   write   lin   

原文地址:https://www.cnblogs.com/lybpy/p/9775419.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!