文章目录
背景
在进行微服务开发过程中,链路追踪功能是必要的。本文将进行pinpoint链路追踪搭建实战。
具体文档参考pinpoint官网:https://github.com/naver/pinpoint
部署hbase
下载hbase的jar包
解压后配置 hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///Users/acheron/Tmp/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/Users/acheron/Tmp/zookeeper</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2182</value>
</property>
</configuration>
配置hbase-env.sh
启动hbase的时候,hbase用得是自带的zk,在hbase的配置里可见 export HBASE_MANAGES_ZK=true;
JAVA_HOME配置
启动hbase
./start-hbase.sh
创建hbase表
/hbase shell hbase-create.hbase
查看启动情况
http://localhost:16010/master-status
部署pinpoint-web
部署tomcat
解压web的包,并且启动tomcat
查看启动情况
http://localhost:8088
部署pinpoint-collector
解压collector的包,启动tomcat,然后查看本地端口9994,9995,9996是否开放
启动服务的时候同时使用agent
- 把附件的pinpoint-agent下载并解压。
- 配置pinpoint.config
- profiler.collector.ip=172.16.202.33
- (可选,配置采样率)profiler.sampling.rate=1
启动服务的时候启动,添加上报
-javaagent:/data/java_server/pinpoint/agent/pinpoint-bootstrap-1.8.0-SNAPSHOT.jar
-Dpinpoint.agentId=$AGENTID -Dpinpoint.applicationName=$APPNAME
-Dspring.profiles.active=rc
-Dspring.cloud.config.enabled=true
-Dspring.cloud.config.uri=http://127.0.0.1:8093/
#!/bin/bash
# you must set the APPNAME
APPNAME=ztjy-comment-server.jar
AGENTID=1
#PARAMS="-Dspring.profiles.active=rc -Dspring.cloud.config.enabled=true -Dspring.cloud.config.uri=http://127.0.0.1:8093/"
PARAMS="-javaagent:/data/java_server/pinpoint/agent/pinpoint-bootstrap-1.8.0-SNAPSHOT.jar
-Dpinpoint.agentId=$AGENTID -Dpinpoint.applicationName=$APPNAME
-Dspring.profiles.active=rc
-Dspring.cloud.config.enabled=true
-Dspring.cloud.config.uri=http://127.0.0.1:8093/"
source /etc/profile
if [ $# -lt 1 ]; then
echo "args: jarname appname action"
exit 1
fi
DATE=$(date +%Y%m%d%H%M%S)
export JAVA_HOME PATH CLASSPATH
DIR=$(cd `dirname $0`; pwd)
start() {
cd $DIR
check=`ps -ef | grep "${APPNAME}" | grep -v grep | awk '{print $2}'`
if [ ! -z $check ]; then
echo "${APPNAME} is running, pid is ${check}"
exit 1
fi
java -jar ${PARAMS} ${DIR}/${APPNAME} > /dev/null 2>&1 &
check=`ps -ef | grep "${APPNAME}" | grep -v grep | awk '{print $2}'`
echo "$APPNAME start, pid is $check ..."
}
stop() {
check=`ps -ef | grep "${APPNAME}" | grep -v grep | awk '{print $2}'`
if [ -z $check ]; then
echo "${APPNAME} is not running"
exit 1
fi
echo "${APPNAME} pid is $check"
sudo kill -9 ${check}
}
case "$1" in
start)
start;
exit $?;
;;
stop)
stop;
exit $?;
;;
restart|force-reload)
${0} stop
${0} start
exit $?;
;;
*)
echo "Usage: deploy.sh {start|stop|restart|force-reload}" >&2
exit 1
esac
进入pinpoint-web观测数据服务运行情况
评价
- 代码无侵入
- 展示效果好