Pinpoint本地环境搭建
Pinpoint的特点如下
- 分布式事务跟踪,跟踪跨分布式应用的消息
- 自动检测应用拓扑,帮助你搞清楚应用的架构
- 水平扩展以便支持大规模服务器集群
- 提供代码级别的可见性以便轻松定位失败点和瓶颈
- 使用字节码增强技术,添加新功能而无需修改代码
- 安装探针不需要修改哪怕一行代码及trace server端部署简单,支持hdfs存储
- 具有简单的阀值触发报警功能
- 移植性比较强的,会比较讨人喜欢
搭建环境及相关软件
- Mac OS (Version 10.12.3)
- JDK 8
- HBase 1.2.4
- Tomcat 8.5.11
- Pinpoint 1.6.1-SNAPSHOT
环境变量
方面解释设定的一些环境变量
- JAVA_HOME : Java 8的安装目录
- HBASE_HOME : HBase 1.2.4的安装目录
- TOMCAT_HOME : Tomcat 8.5.11的安装目录
- PINPOINT_SOURCE : 从github clone的Pinponit项目目录
- PINPOINT_AGENT : Pinpoint Agent安装目录
生成Pinpoint的安装包
- 用命令"git clone https://github.com/naver/pinpoint.git" 把Pinpoint项目克隆到PINPOINT_SOURCE目录。
- 在PINPOINT_SOURCE目录下执行命令"mvn install -Dmaven.test.skip=true" or "mvn install -Prelease -Dmaven.test.skip=true"生成相关的jar或war包。
HBase安装
下载HBase1.2.4安装包,并解压到HBASEHOME目录;
通过$HBASE_HOME/conf/hbase-env.sh文件设置一些环境变量:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
export HBASE_OPTS="-XX:+UseConcMarkSweepGC"
export SERVER_GC_OPTS="-verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/Users/zhuzhi/hbase124/logs/jdk8.log"
通过$HBASE_HOME/conf/hbase-site.xml文件对HBase做简单的配置:
hbase.rootdir : file:///Users/zhuzhi/hbase124/data
hbase.zookeeper.property.dataDir : /Users/zhuzhi/hbase124/data/zookeeper
hbase.zookeeper.property.clientPort : 2181
hbase.zookeeper.quorum : localhost
执行下面的命令启动HBase
$HBASE_HOME/bin/start-hbase.sh
执行下面的命令验证HBase是否正常启动
$HBASE_HOME/bin/hbase shell
如果有类似下面的输出,就表示HBase已经正常启动:
1 active master, 0 backup masters, 1 servers, 1 dead, 499.0000 average load
在HBase中创建Pinpoint相关的表
$HBASE_HOME/bin/hbase shell $PINPOINT_SOURCE/hbase/scripts/hbase-create.hbase
Pinpoint Collector安装
执行下面的命令安装Collector
cp $PINPOINT_SOURCE/collector/target/pinpoint-collector-1.6.1-SNAPSHOT.war $TOMCAT_HOME/webapps
cd $TOMCAT_HOME/webapps
mv pinpoint-collector-1.6.1-SNAPSHOT.war collector.war
unzip collector.war -d $TOMCAT_HOME/webapps/collector
检查$TOMCAT_HOME/webapps/collector/WE_B-INF/classes/pinpoint-collector.properties中的属性设置:
collector.tcpListenPort
(agent's profiler.collector.tcp.port - default: 9994)collector.udpStatListenPort
(agent's profiler.collector.stat.port - default: 9995)collector.udpSpanListenPort
(agent's profiler.collector.span.port - default: 9996)
检查$TOMCAT_HOME/webapps/collector/WE_B-INF/classes/hbase.properties中的属性设置:
hbase.client.host
(default: localhost)hbase.client.port
(default: 2181)
Pinpoint Web安装
执行下面的命令安装Web
cp $PINPOINT_SOURCE/collector/web/pinpoint-web-1.6.1-SNAPSHOT.war $TOMCAT_HOME/webapps
cd $TOMCAT_HOME/webapps
mv pinpoint-web-1.6.1-SNAPSHOT.war pinpointWeb.war
unzip pinpointWeb.war -d $TOMCAT_HOME/webapps/pinpointWeb
检查$TOMCAT_HOME/webapps/pinpointWeb/WE_B-INF/classes/hbase.properties中的属性设置:
hbase.client.host
(default: localhost)hbase.client.port
(default: 2181)
在文件$TOMCAT_HOME/conf/server.xml中<Host>下添加配置:
<Context docBase="pinpointWeb" path="" reloadable="true"/>
Pinpoint Agent安装
执行下面的命令安装Agent
tar zxvf $PINPOINT_SOURCE/agent/target/pinpoint-agent-1.6.1-SNAPSHOT.tar.gz $PINPOINT_AGENT
touch $TOMCAT_HOME/bin/setenv.sh
把下面的内容添加到$TOMCAT_HOME/bin/setenv.sh
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home"
CATALINA_OPTS="$CATALINA_OPTS -javaagent:$PINPOINT_AGENT/pinpoint-bootstrap-1.6.1-SNAPSHOT.jar"
CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.agentId=testweb-01"
CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.applicationName=testweb"
检查$PINPOINT_AGENT/pinpoint.config中的属性设置:
profiler.collector.ip
(default: 127.0.0.1)profiler.collector.tcp.port
(collector's collector.tcpListenPort - default: 9994)profiler.collector.stat.port
(collector's collector.udpStatListenPort- default: 9995)profiler.collector.span.port
(collector's collector.udpSpanListenPort - default: 9996)- profiler.sampling.enable=true (Allow Sampling)
- profiler.sampling.rate=1 (1 out of n transaction will be sampled where is the rate. (1:100%)
$PINPOINT_AGENT/pinpoint.config中的Configuration for Masking out privacy information (like mysql query params, http post body, etc.)
- JDBC Parameter
####################################################### #########
# JDBC #
####################################################### #########
#restricts the number of parameters to be displayed.
Profiler.jdbc.maxsqlbindvaluesize = 0
- HTTP Post Body
####################################################### #########
# Apache HTTP Client 3.x #
####################################################### #########
profiler.apache.httpclient3.cookie=false
Profiler.apache.httpclient3.entity = false
####################################################### #########
# Apache HTTP Client 4.x #
####################################################### #########
profiler.apache.httpclient4.cookie=false
profiler.apache.httpclient4.entity = false
####################################################### #########
# TOMCAT #
####################################################### #########
Profiler.tomcat.excludemethod = POST, PUT
Do not collect the contents of the HTTP body, cookie through the above setting.
启动Tomcat
执行下面的命令启动Tomcat
$TOMCAT_HOME/bin/startup.sh
访问URL:http://localhost:8080/ 启动Pinpoint Web
访问URL: http://localhost:8080/testapp 来测试Pinpoint Agent
可以看到下面的log:
2017-03-09 15:36:31 [DEBUG](c.n.p.p.s.UdpDataSender :136) Data sent. size:199, TSpan(agentId:testweb-01, applicationName:testweb, agentStartTime:1489044811915, transactionId:00 01 8B E1 F2 8F AB 2B 57, spanId:-6439797679680554860, parentSpanId:-6000146233548070491, startTime:1489044991620, elapsed:6, rpc:/getCurrentTimestamp.pinpoint, serviceType:1010, endPoint:172.29.20.114:8080, remoteAddr:172.29.20.114, flag:0, spanEventList:[TSpanEvent(sequence:0, startElapsed:1, endElapsed:5, serviceType:1011, depth:1, apiId:1)], parentApplicationName:testweb, parentApplicationType:1010, acceptorHost:172.29.20.114:8080, apiId:2, applicationServiceType:1010)