Pinpoint是什么
简单的说,Pinpoint是一款对Java编写的大规模分布式系统的APM工具,有些人也喜欢称呼这类工具为调用链系统、分布式跟踪系统。我们知道,前端向后台发起一个查询请求,后台服务可能要调用多个服务,每个服务可能又会调用其它服务,最终将结果返回,汇总到页面上。如果某个环节发生异常,工程师很难准确定位这个问题到底是由哪个服务调用造成的,Pinpoint等相关工具的作用就是追踪每个请求的完整调用链路,收集调用链路上每个服务的性能数据,方便工程师能够快速定位问题。它对性能的影响最小(只增加约3%资源利用率),安装agent是无侵入式的

为什么要用Pinpoint
最重要的原因,对代码的零侵入,运用JavaAgent字节码增强技术,只需要加启动参数即可。

Pinpoint-Collector:收集各种性能数据
Pinpoint-Agent:和自己运行的应用关联起来的探针
Pinpoint-Web:将收集到的数据显示成WEB网页形式
HBase Storage:收集到的数据存到HBase中

部署:
1台Web,安装好jdk,tomcat
2台collector,安装jdk,tomcat
1台hbase ,安装好jdk,hbase必须给大点的存储,目前我挂的是300G的硬盘,预生产环境比较小,后面根据实际情况调整
War包下载:
https://github.com/naver/pinpoint/releases
https://github.com/phoenix002/pinpoint/blob/master/hbase/scripts/hbase-create.hbase
官方安装文档:https://naver.github.io/pinpoint/installation.html

pinpoint-hbase
[root@pinpoint-hbase ]#df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext4 20G 2.1G 17G 12% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 8.4M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sdb1 xfs 300G 37M 300G 1% /opt/hbase-data
tmpfs tmpfs 783M 0 783M 0% /run/user/0

[root@pinpoint-hbase ]#cat /ect/fstab
UUID=db3db1ea-0791-44ed-97ca-b59616152f19 /opt/hbase-data xfs defaults 0 0
https://www.cnblogs.com/sfissw/p/7900284.html

reboot之前记得mount -a 一下

[root@pinpoint-hbase ]#cat /etc/hosts
172.16.41.79 pinpoint-hbase

[root@pinpoint-hbase conf]#cat hbase-env.sh | grep -v "^#" | grep -v "^$"
export JAVA_HOME=/opt/jdk
export HBASE_HEAPSIZE=6G
export HBASE_OPTS="-XX:+UseConcMarkSweepGC"
export HBASE_MASTER_OPTS="$HBASE_MASTER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"
export HBASE_REGIONSERVER_OPTS="$HBASE_REGIONSERVER_OPTS -XX:PermSize=128m -XX:MaxPermSize=128m"

[root@pinpoint-hbase conf]# cat hbase-site.xml | grep -v "^#" | grep -v "^$"


hbase.rootdir
file:///opt/hbase-data

[root@pinpoint-hbase bin]# cd /opt/hbase/bin
[root@pinpoint-hbase bin]# ./start-hbase.sh

[root@pinpoint-hbase bin]# jps
27586 HMaster
1174 Jps

[root@pinpoint-hbase opt]# ll
total 28
drwxr-xr-x 8 root root 4096 Jul 4 08:44 hbase
-rw-r--r-- 1 root root 15763 Jul 2 15:57 hbase-create.hbase
drwxr-xr-x 9 root root 137 Jul 4 14:48 hbase-data
drwxr-xr-x 8 root root 4096 Jul 4 08:37 jdk

初始化pinpoint数据库
./hbase shell /opt/hbase-create.hbase

./hbase shell 查看数据库是否初始化成功:
输入status 'detailed'查看刚才初始化的表,是否存在
hbase(main):001:0> status 'detailed'

[root@pinpoint-hbase bin]# netstat -antp|grep LIST
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 710/sshd
tcp6 0 0 :::16010 :::
LISTEN 27586/java
tcp6 0 0 172.16.41.79:60204 ::: LISTEN 27586/java
tcp6 0 0 172.16.41.79:42925 :::
LISTEN 27586/java
tcp6 0 0 :::60435 ::: LISTEN 27586/java
tcp6 0 0 :::22 :::
LISTEN 710/sshd
tcp6 0 0 :::2181 :::* LISTEN 27586/java

hbase页面查看:http://172.16.41.79:16010/master-status

Pinpoint-web
[root@Pinpoint-web classes]#/opt/tomcat-pinpoint-web/webapps/ROOT/WEB-INF/classes**

cat hbase.properties | grep -v "^#" | grep -v "^$"
hbase.client.host=pinpoint-hbase
hbase.client.port=2181
hbase.zookeeper.znode.parent=/hbase
hbase.namespace=default
hbase.ipc.client.tcpnodelay=true
hbase.rpc.timeout=10000
hbase.client.operation.timeout=10000
hbase.ipc.client.socket.timeout.read=20000
hbase.ipc.client.socket.timeout.write=30000
hbase.client.thread.max=64
hbase.client.threadPool.queueSize=5120
hbase.client.threadPool.prestart=false
hbase.client.parallel.scan.enable=true
hbase.client.parallel.scan.maxthreads=64
hbase.client.parallel.scan.maxthreadsperscan=16

[root@Pinpoint-web classes]#cat pinpoint-web.properties | grep -v "^#" | grep -v "^$"
cluster.enable=true
cluster.web.tcp.port=9997
cluster.zookeeper.address=172.16.41.79:2181
cluster.zookeeper.sessiontimeout=30000
cluster.zookeeper.retry.interval=60000
cluster.connect.address=
admin.password=admin
config.sendUsage=true
config.editUserInfo=true
config.openSource=true
config.show.activeThread=true
config.show.activeThreadDump=true
config.enable.activeThreadDump=true
config.show.applicationStat=false
config.enable.serverMapRealTime=true
web.hbase.selectSpans.limit=500
web.hbase.selectAllSpans.limit=500
web.activethread.activeAgent.duration.days=7
web.servermap.creator.worker.threadSize=32
web.servermap.creator.worker.queueSize=1024
web.servermap.appender.worker.threadSize=32
web.servermap.appender.worker.queueSize=1024
websocket.allowedOrigins=
web.installation.pinpointVersion=
web.installation.downloadUrl=
**

cat /etc/hosts
172.16.41.79 pinpoint-hbase

[root@Pinpoint-web classes]# netstat -antp|grep LIST
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 689/sshd
tcp6 0 0 :::8010 :::
LISTEN 15120/java
tcp6 0 0 172.16.41.78:9997 ::: LISTEN 15120/java
tcp6 0 0 :::8081 :::
LISTEN 15120/java
tcp6 0 0 :::22 ::: LISTEN 689/sshd
tcp6 0 0 127.0.0.1:8006 :::
LISTEN 15120/java

Pinpoint-collector-2
[root@Pinpoint-collector-2 webapps]# cat /etc/hosts
172.16.41.79 pinpoint-hbase

[root@Pinpoint-collector-2 classes]# pwd
/opt/tomcat-pinpoint-collector/webapps/pinpoint-collector-1.7.2/WEB-INF/classes
[root@Pinpoint-collector-2 classes]# cat hbase.properties | grep -v "^#" | grep -v "^$"
hbase.client.host=pinpoint-hbase
hbase.client.port=2181
hbase.zookeeper.znode.parent=/hbase
hbase.namespace=default
hbase.ipc.client.tcpnodelay=true
hbase.rpc.timeout=10000
hbase.client.operation.timeout=10000
hbase.ipc.client.socket.timeout.read=20000
hbase.ipc.client.socket.timeout.write=60000
hbase.client.thread.max=64
hbase.client.threadPool.queueSize=5120
hbase.client.threadPool.prestart=false
hbase.client.async.enable=false
hbase.client.async.in.queuesize=10000
hbase.client.async.flush.period.ms=100
hbase.client.async.max.retries.in.queue=10
[root@Pinpoint-collector-2 classes]#

[root@Pinpoint-collector-2 classes]# cat pinpoint-collector.properties | grep -v "^#" | grep -v "^$"
collector.receiver.base.ip=0.0.0.0
collector.receiver.base.port=9994
collector.receiver.base.worker.threadSize=8
collector.receiver.base.worker.queueSize=1024
collector.receiver.base.worker.monitor=true
collector.receiver.stat.udp=true
collector.receiver.stat.udp.ip=0.0.0.0
collector.receiver.stat.udp.port=9995
collector.receiver.stat.udp.receiveBufferSize=4194304
collector.receiver.stat.tcp=false
collector.receiver.stat.tcp.ip=0.0.0.0
collector.receiver.stat.tcp.port=9995
collector.receiver.stat.worker.threadSize=8
collector.receiver.stat.worker.queueSize=64
collector.receiver.stat.worker.monitor=true
collector.receiver.span.udp=true
collector.receiver.span.udp.ip=0.0.0.0
collector.receiver.span.udp.port=9996
collector.receiver.span.udp.receiveBufferSize=4194304
collector.receiver.span.tcp=false
collector.receiver.span.tcp.ip=0.0.0.0
collector.receiver.span.tcp.port=9996
collector.receiver.span.worker.threadSize=32
collector.receiver.span.worker.queueSize=256
collector.receiver.span.worker.monitor=true
collector.l4.ip=
collector.agentEventWorker.threadSize=4
collector.agentEventWorker.queueSize=1024
statistics.flushPeriod=1000
cluster.enable=true
cluster.zookeeper.address=172.16.41.79:2181
cluster.zookeeper.sessiontimeout=30000
cluster.listen.ip=
cluster.listen.port=
collector.spanEvent.sequence.limit=10000
flink.cluster.enable=false
flink.cluster.zookeeper.address=localhost
flink.cluster.zookeeper.sessiontimeout=3000
[root@Pinpoint-collector-2 classes]#

[root@Pinpoint-collector-2 classes]# netstat -antp|grep LIST
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 681/sshd
tcp6 0 0 :::8009 :::
LISTEN 20226/java
tcp6 0 0 :::9994 ::: LISTEN 20226/java
tcp6 0 0 :::8080 :::
LISTEN 20226/java
tcp6 0 0 :::22 ::: LISTEN 681/sshd
tcp6 0 0 127.0.0.1:8005 :::
LISTEN 20226/java

web程序部署:
IP=ifconfig|grep inet|grep 10.68|awk '{print $2}'|awk -F '.' '{print $3"."$4}'
CATALINA_OPTS="$JAVA_OPTS -javaagent:/opt/pinpoint-agent/pinpoint-bootstrap-1.7.1.jar -Dpinpoint.agentId=srm-api-war-${IP} -Dpinpoint.applicationName=srm-api-war"

dubbo程序部署:
IP=ifconfig|grep inet|grep 10.68|awk '{print $2}'|awk -F '.' '{print $3"."$4}'
J_OPTS="-javaagent:/opt/pinpoint-agent/pinpoint-bootstrap-1.7.1.jar -Dpinpoint.agentId=srm-opsearchdata-${IP} -Dpinpoint.applicationName=srm-op-searchdata"

参考资料:
https://github.com/naver/pinpoint
http://www.cnblogs.com/yyhh/p/6106472.html#yy0301
https://github.com/ameizi/DevArticles/issues/166
https://blog.csdn.net/huashao0602/article/details/75271599
http://www.herohuang.com/2017/03/01/apm-pinpoint/
https://my.oschina.net/u/3201295/blog/834844
https://blog.csdn.net/wslyk606/article/details/77752467