开源APM工具pinpoint线上部署
Pinpoint是一个分析大型分布式系统的平台,提供解决方案来处理海量跟踪数据。2012年七月开始开发,2015年1月9日作为开源项目启动。
安装指南
pinpoint运行需要以实例
- HBase (用于存储)
- pinpoint Collector (收集数据)
- pinpoint Web (使用web 界面)
- pinpoint Agent (java 探针)
版本信息(以下来源官网)
Java version required to run Pinpoint:
Pinpoint Version | Agent | Collector | Web |
---|---|---|---|
1.0.x | 6-8 | 6+ | 6+ |
1.1.x | 6-8 | 7+ | 7+ |
1.5.x | 6-8 | 7+ | 7+ |
1.6.x | 6-8 | 7+ | 7+ |
1.7.x | 6-8 | 8+ | 8+ |
HBase compatibility table:
Pinpoint Version | HBase 0.94.x | HBase 0.98.x | HBase 1.0.x | HBase 1.1.x | HBase 1.2.x |
---|---|---|---|---|---|
1.0.x | yes | no | no | no | no |
1.1.x | no | not tested | yes | not tested | not tested |
1.5.x | no | not tested | yes | not tested | not tested |
1.6.x | no | not tested | not tested | not tested | yes |
1.7.x | no | not tested | not tested | not tested | yes |
Agent compatibility table:
Agent Version | Collector 1.0.x | Collector 1.1.x | Collector 1.5.x | Collector 1.6.x | Collector 1.7.x |
---|---|---|---|---|---|
1.0.x | yes | yes | yes | yes | yes |
1.1.x | not tested | yes | yes | yes | yes |
1.5.x | no | no | yes | yes | yes |
1.6.x | no | no | not tested | yes | yes |
1.7.x | no | no | no | no | yes |
Pinpoint Web Supported Browsers:
- Chrome
生产环境部署
注意: 该文章是做生产环境部署,并非quick-start guide. 如需要quick-start guide 建议阅读官方文档quick-start guide
应用分布
ip | 机器名称 | appName |
---|---|---|
10.10.10.2 | vm_1 | zookeeper |
10.10.10.3 | vm_2 | zookeeper |
10.10.10.4 | vm_3 | zookeeper |
10.10.10.5 | vm_4 | hbase |
10.10.10.6 | vm_5 | Collector |
10.10.10.7 | vm_6 | Web |
所有机器添加 ‘/etc/hosts’
1 | 10.10.10.2 zk1.iqarr.com |
zookeeper部署
下载最新zookeeper
1
2
3
4
5
6
7
8
9
10
11
12
13配置 conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/zookeeper/data
clientPort=2181
maxClientCnxns=60
autopurge.snapRetainCount=3
autopurge.purgeInterval=24
dataLogDir=/opt/zookeeper/logs
server.1=10.10.10.2:2888:3888
server.2=10.10.10.3:2888:3888
server.3=10.10.10.4:2888:3888创建zk的数据目录和日志目录
1
2mkdir -p /opt/zookeeper/data/
mkdir -p /opt/zookeeper/logs创建myid文件,节点对应id
1
2
3
4
5
6
7
8
9# 在10.10.10.2 节点配置myid
cd /opt/zookeeper/data
echo 1 > myid
# 在10.10.10.3 节点配置myid
cd /opt/zookeeper/data
echo 2 > myid
# 在10.10.10.4 节点配置myid
cd /opt/zookeeper/data
echo 3 > myid分别启动每台机器zookeeper
开放端口
1
2firewall-cmd --add-port=2181/tcp --permanent
firewall-cmd --reload
hbase 部署
- 下载hbase
- 解压安装hbase (
HBASE_HOME
为 hbase安装目录) 配置
HBASE_HOME/conf/hbase-env.sh
使用独立zookeeper1
export HBASE_MANAGES_ZK=false
创建文件
HBASE_HOME/conf/zoo.cfg
(注意该文件就是zk 的配置文件)1
2
3
4
5
6
7
8
9
10
11
12tickTime=2000
initLimit=10
syncLimit=5
dataDir=/opt/zookeeper/data
clientPort=2181
maxClientCnxns=60
autopurge.snapRetainCount=3
autopurge.purgeInterval=24
dataLogDir=/opt/zookeeper/logs
server.1=10.10.10.2:2888:3888
server.2=10.10.10.3:2888:3888
server.3=10.10.10.4:2888:3888配置
hbase-site.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///opt/hbase/data</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>zk1.iqarr.com,zk2.iqarr.com,zk3.iqarr.com</value>
</property>
<property>
<name>zookeeper.session.timeout</name>
<value>60000000</value>
</property>
<property>
<name>hbase.regionserver.lease.period</name>
<value>900000</value> <!-- 900 000, 15 minutes -->
</property>
<property>
<name>hbase.rpc.timeout</name>
<value>900000</value> <!-- 15 minutes -->
</property>
</configuration>注:hbase data 目录在
/opt/hbase/data
启动hbase
1
2启动hbase
sh HBASE_HOME/bin/start-hbase.sh创建hbase表
1
sh HBASE_HOME/bin/hbase shell hbase-create.hbase
开放端口
1
2
3
4firewall-cmd --add-port=16010/tcp --permanent
firewall-cmd --add-port=16201/tcp --permanent
firewall-cmd --add-port=16301/tcp --permanent
firewall-cmd --reload注:
hbase-create.hbase
脚本,如果是下载release包脚本在pinpoint-x.x.x/hbase/scripts/
中
配置pinpoint-collector
- 下载tomcat和
pinpoint-collector-X.X.X.war
,解压pinpoint-collector-X.X.X.war
到tomcat的webapps目录中 配置
pinpoint-collector
配置信息1
2
3
4
5
6
7
8
9#编辑 tomcat/webapps/collector/WEB-INF/classes/pinpoint-collector.properties
#修改以下信息
#配置zk 地址
cluster.zookeeper.address=zk1.iqarr.com,zk2.iqarr.com,zk3.iqarr.com
cluster.enable=true
cluster.zookeeper.address=zk1.iqarr.com,zk2.iqarr.com,zk3.iqarr.com #zookeeper 集群地址
cluster.zookeeper.sessiontimeout=30000
cluster.listen.ip=0.0.0.0
cluster.listen.port=9997配置
hbase.properties
配置信息1
2
3#编辑tomcat/webapps/collector/WEB-INF/classes/hbase.properties
hbase.client.host=zk1.iqarr.com,zk2.iqarr.com,zk3.iqarr.com #zk集群地址
hbase.client.port=2181 #zk port启动tomcat
开放端口
1
2
3
4
5firewall-cmd --add-port=9994/tcp --permanent
firewall-cmd --add-port=9995/udp --permanent
firewall-cmd --add-port=9996/udp --permanent
firewall-cmd --add-port=9997/tcp --permanent
firewall-cmd --reload
配置pinpoint-web
- 下载tomcat和
pinpoint-web-x.x.x.war
,解压pinpoint-web-X.X.X.war
到tomcat的webapps目录中的ROOT目录(目前必须放到ROOT目录) 配置
hbase.properties
配置信息1
2
3#编辑tomcat/webapps/ROOT/WEB-INF/classes/hbase.properties
hbase.client.host=zk1.iqarr.com,zk2.iqarr.com,zk3.iqarr.com #zk集群地址
hbase.client.port=2181 #zk port配置
pinpoint-web.properties
配置信息1
2
3
4
5
6
7
8#编辑tomcat/webapps/ROOT/WEB-INF/classes/pinpoint-web.properties
#zk 地址
cluster.zookeeper.address=zk1.iqarr.com,zk2.iqarr.com,zk3.iqarr.com
cluster.enable=true
cluster.web.tcp.port=
cluster.zookeeper.sessiontimeout=30000
cluster.zookeeper.retry.interval=60000
cluster.connect.address=10.10.10.6:9997 # 注意这里是pinpoint-collector ip 地址启动tomcat
开放端口
1
2firewall-cmd --add-port=8080/tcp --permanent #注意tomcat port
firewall-cmd --reload
配置pinpoint-agent
- 下载
pinpoint-agent-x.x.x.tar.gz
解压配置
1
2# 修改文件pinpoint.config
profiler.collector.ip=agent.iqarr.com配置需要收集应用(这里以tomcat例子)
1
2
3
4
5
6
7
8
9
10
11
12#创建文件 TOMCAT_HOME/bin/setenv.sh
#添加如下内容
AGENT_PATH="$CATALINA_BASE/bin/ex"
# 这里agent版本号
PINPOINT_VERSION="1.7.1"
#默认取主机名称,这里必须唯一
AGENT_ID=`hostname`
#应用名称
APPLICATION_NAME="web-dome"
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:${AGENT_PATH}/pinpoint-bootstrap-${PINPOINT_VERSION}.jar"
export CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.agentId=$AGENT_ID"
export CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.applicationName=$APPLICATION_NAME"复制agent到tomcat目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93#复制 刚才解压配置好的agent到tomcat的 TOMCAT_HOME/bin/ex
# 目录结构如下
byzy@debian8:~/tomcat-8_web$ tree -L 3
.
├── bin
│ ├── bootstrap.jar
│ ├── catalina.bat
│ ├── catalina.sh
│ ├── catalina-tasks.xml
│ ├── commons-daemon.jar
│ ├── commons-daemon-native.tar.gz
│ ├── configtest.bat
│ ├── configtest.sh
│ ├── daemon.sh
│ ├── digest.bat
│ ├── digest.sh
│ ├── ex
│ │ ├── boot
│ │ ├── lib
│ │ ├── log
│ │ ├── pinpoint-bootstrap-1.7.1.jar
│ │ ├── pinpoint.config
│ │ ├── plugin
│ │ ├── script
│ │ └── tools
│ ├── setclasspath.bat
│ ├── setclasspath.sh
│ ├── setenv.sh
│ ├── shutdown.bat
│ ├── shutdown.sh
│ ├── startup.bat
│ ├── startup.sh
│ ├── tomcat-juli.jar
│ ├── tomcat-native.tar.gz
│ ├── tomcatService.sh
│ ├── tool-wrapper.bat
│ ├── tool-wrapper.sh
│ ├── version.bat
│ └── version.sh
├── change.log
├── conf
│ ├── Catalina
│ │ └── localhost
│ ├── catalina.policy
│ ├── catalina.properties
│ ├── context.xml
│ ├── jaspic-providers.xml
│ ├── jaspic-providers.xsd
│ ├── logging.properties
│ ├── server.xml
│ ├── tomcat-users.xml
│ ├── tomcat-users.xsd
│ └── web.xml
├── lib
│ ├── annotations-api.jar
│ ├── catalina-ant.jar
│ ├── catalina-ha.jar
│ ├── catalina.jar
│ ├── catalina-storeconfig.jar
│ ├── catalina-tribes.jar
│ ├── ecj-4.6.3.jar
│ ├── el-api.jar
│ ├── jasper-el.jar
│ ├── jasper.jar
│ ├── jaspic-api.jar
│ ├── jsp-api.jar
│ ├── org
│ │ └── apache
│ ├── servlet-api.jar
│ ├── spring-instrument-tomcat-4.3.4.RELEASE.jar
│ ├── tomcat-api.jar
│ ├── tomcat-coyote.jar
│ ├── tomcat-dbcp.jar
│ ├── tomcat-i18n-es.jar
│ ├── tomcat-i18n-fr.jar
│ ├── tomcat-i18n-ja.jar
│ ├── tomcat-jdbc.jar
│ ├── tomcat-jni.jar
│ ├── tomcat-util.jar
│ ├── tomcat-util-scan.jar
│ ├── tomcat-websocket.jar
│ └── websocket-api.jar
├── logs
├── temp
├── webapps
│ ├── ROOT
│ └── web
│ ├── META-INF
│ └── WEB-INF
└── work
└── Catalina
└── localhost
24 directories, 64 files启动应用,当有请求时候在pinpoint-web 可看到请求记录
注: TOMCAT_HOME为tomcat 安装目录
注: agent默认收集20%的请求所以可能请求一次无法看到的。当然也可以配置全部收集。
检查pinpoint-web界面
- 访问
http://10.10.10.7:8080
就出如界面。