Pinpoint是一個開源的APM工具,分佈式事務跟蹤系統的平臺,思路基於google Dapper,用於基於java的大規模分佈式系統,經過跟蹤分佈式應用之間的調用來提供解決方案,以幫助分析系統的整體結構和內部模塊之間如何相互聯繫。html
git地址爲:https://github.com/naver/pinpointjava
架構mysql
Pinpoint的特色以下:linux
分佈式事務跟蹤,跟蹤跨分佈式應用的消息 自動檢測應用拓撲,幫助你搞清楚應用的架構 水平擴展以便支持大規模服務器集羣 提供代碼級別的可見性以便輕鬆定位失敗點和瓶頸 使用字節碼加強技術,添加新功能而無需修改代碼 安裝探針不須要修改哪怕一行代碼及trace server端部署簡單,支持hdfs存儲 具備簡單的閥值觸發報警功能 移植性比較強的,會比較討人喜歡(相比cat) 插件化功能可擴展(https://github.com/naver/pinpoint/wiki/Pinpoint-Plugin-Developer-Guide)
apache-tomcat-8.0.37.tar.gz
(下載地址:http://tomcat.apache.org/download-80.cgi#8.0.37)git
hbase-1.0.3-bin.tar.gz
(下載地址:http://apache.fayea.com/hbase/)github
jdk-8u102-linux-x64.rpm
(下載地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)web
pinpoint-agent-1.5.2.tar.gz
(下載地址:https://github.com/naver/pinpoint/releases/tag/1.5.2)sql
pinpoint-collector-1.5.2.war
(下載地址:https://github.com/naver/pinpoint/releases/tag/1.5.2)shell
pinpoint-web-1.5.2.war
(下載地址:https://github.com/naver/pinpoint/releases/tag/1.5.2)數據庫
zookeeper-3.4.6-10.el6.x86_64.rpm
(下載地址:http://apache.fayea.com/zookeeper/)
所有放入/root/pp目錄
192.168.80.144 CentOS6(jdk1.8.0) Pinpoint-collector,Pinpoint-web,zookeeper,Hbase
192.168.80.143 CentOS6(jdk1.8.0) Pinpoint-agent(demo應用)
[root@localhost ~]# rpm -ivh jdk-8u102-linux-x64.rpm
定義好環境變量中jdk的位置
[root@localhost ~]# vim ~/.bashrc export JAVA_HOME=/usr/java/default export PATH=$PATH:$JAVA_HOME/bin [root@localhost ~]# source ~/.bashrc
安裝配置hbase
[root@localhost ~]# tar xf /root/pp/hbase-1.0.3-bin.tar.gz /usr/local/ [root@localhost ~]# cd /usr/local/hbase-1.0.3/conf [root@localhost ~]# vim hbase-env.sh 這裏修改成環境變量中JAVA_HOME的位置 export JAVA_HOME=/usr/java/default/ [root@localhost ~]# vim hbase-site.xml <configuration> <property> <name>hbase.rootdir</name> <value>file:///data/hbase</value> # 這裏咱們指定Hbase本地來存儲數據,生產環境將數據建議存入HDFS中。 </property> </configuration>
啓動HBASE
[root@localhost ~]# /usr/local/hbase-1.0.3/bin/start-hbase.sh
關閉方法
[root@localhost ~]# /usr/local/hbase-1.0.3/bin/stop-hbase.sh
下載HBASE初始化腳本
[root@localhost ~]# wget https://raw.githubusercontent.com/naver/pinpoint/master/hbase/scripts/hbase-create.hbase [root@localhost ~]# /usr/local/hbase-1.0.3/bin/hbase shell /root/hbase-create.hbase [root@localhost ~]# /usr/local/hbase-1.0.3/bin/hbase shell hbase(main):001:0> status 'detailed'
啓動HBASE驗證
[root@localhost ~]# /usr/local/hbase-1.0.3/bin/start-hbase.sh [root@localhost ~]# jps 12659 Jps 5115 HMaster
進入HBASE頁面查看
http://192.168.80.144:16010/master-status
若是部署的hadoop或者hbase,全部須要部署的主機的主機名必定要和hadoop、hbase中配置的一致
安裝啓動zookeeper
[root@localhost ~]# rpm -ivh /root/zookeeper-3.4.6-10.el6.x86_64.rpm [root@localhost ~]# /etc/init.d/zookeeper start
啓動時間有點長
[root@localhost ~]# ss -tnlp | grep 2181
安裝配置pinpoint-collector
[root@localhost ~]# mkdir -pv /data/service/ [root@localhost ~]# tar xf /root/pp/apache-tomcat-8.0.37.tar.gz -C /data/service/ [root@localhost ~]# cd /data/service/ [root@localhost ~]# mv apache-tomcat-8.0.37/ pinpoint-collector 修改tomcat端口不要讓collector的端口和web的端口衝突 [root@localhost ~]# vim /data/service/pinpoint-collector/conf/server.xml <Server port="8005" shutdown="SHUTDOWN"> #修改端口 <Connector port="8085" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> #修改端口 <!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> --> # 註釋該行 [root@localhost ~]# rm -rf /data/service/pinpoint-collector/webapps/* [root@localhost ~]# unzip pinpoint-collector-1.5.2.war -d /data/service/pinpoint-collector/webapps/ROOT/ [root@localhost ~]# cd /data/service/pinpoint-collector/webapps/ROOT/WEB-INF/classes [root@localhost ~]# vim hbase.properties hbase.client.host=192.168.80.144 # 修改這裏讓collector向hbase存儲數據 hbase.client.port=2181
安裝配置pinpoint-web
[root@localhost ~]# cd /data/service/ [root@localhost ~]# tar xf /root/pp/apache-tomcat-8.0.37.tar.gz -C /data/service/ [root@localhost ~]# mv apache-tomcat-8.0.37 pinpoint-web [root@localhost ~]# cd /data/service/pinpoint-web/webapps/ [root@localhost ~]# rm -rf /data/service/pinpoint-web/webapps/* [root@localhost ~]# mkdir /data/service/pinpoint-web/webapps/ROOT [root@localhost ~]# cd /data/service/pinpoint-web/webapps/ROOT/ [root@localhost ~]# unzip /root/pinpoint-web-1.5.2.war -d /data/service/pinpoint-web/webapps/ROOT/ [root@localhost ~]# vim /data/service/pinpoint-web/conf/server.xml <Server port="8006" shutdown="SHUTDOWN"> #修改端口 <Connector port="8086" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> #修改端口 <!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> --> # 註釋該行 [root@localhost ~]# vim /data/service/pinpoint-web/webapps/ROOT/WEB-INF/classes/hbase.properties hbase.client.host=192.168.80.144 hbase.client.port=2181
啓動collector和web
[root@localhost ~]# /data/service/pinpoint-web/bin/catalina.sh start [root@localhost ~]# /data/service/pinpoint-collector/bin/catalina.sh start 驗證web端口是否啓動 [root@localhost ~]# ss -tnlp | grep 8086 驗證collector端口是否啓動 [root@localhost ~]# ss -tnlp | grep 8085
查看頁面是否能打開
http://192.168.80.144:8086/#/main/
demo應用我選擇了一個簡單的blog
[root@localhost ~]# yum install java-1.7.0-openjdk [root@localhost ~]# yum install java-1.7.0-openjdk-devel.x86_64 [root@localhost ~]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz [root@localhost ~]# vim /etc/profile.d/java.sh export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64 export PATH=$JAVA_HOME/bin:$PATH [root@localhost ~]# . /etc/profile.d/java.sh [root@localhost ~]# java -version [root@localhost ~]# tar xf apache-tomcat-7.0.70.tar.gz -C /usr/local [root@localhost ~]# ln -sv /usr/local/apache-tomcat-7.0.70 /usr/local/tomcat [root@localhost ~]# vim /etc/profile.d/tomcat.sh export CATALINA_HOME=/usr/local/tomcat export PATH=$CATALINA_HOME/bin:$PATH
應用介紹地址:http://git.oschina.net/94fzb/zrlog
下載zrlog到本地:http://dl.zrlog.com/release/zrlog.war
[root@localhost ~]# wget http://dl.zrlog.com/release/zrlog.war [root@localhost ~]# cp -a /root/zrlog.war /usr/local/tomcat/webapps/ROOT.war
安裝配置mysql
[root@localhost ~]# yum install mariadb-server [root@localhost ~]# service mariadb start [root@localhost ~]# mysql MariaDB [(none)]> create database zrlog; MariaDB [(none)]> grant all privileges on zrlog.* to java1234@'%' identified by 'abc123'; MariaDB [(none)]> grant all privileges on zrlog.* to java1234@localhost identified by 'abc123'; MariaDB [(none)]> flush privileges; [root@localhost ~]# catalina.sh start
訪問應用設置基本配置
訪問地址:http://192.168.80.143:8080/install 數據庫服務器:127.0.0.1 數據庫名:zrlog 數據庫用戶名:java1234 數據庫密碼:abc123 數據庫端口:3306 系統郵箱:405812999@qq.com 管理員帳號:admin 管理員密碼:abc123 管理員 Email:405812999@qq.com 網站標題:個人Blog 網站副標題:zrLog
[root@localhost ~]# mkdir -pv /data/projects/service/ [root@localhost ~]# tar xf /root/pp/pinpoint-agent-1.5.2.tar.gz -C /data/projects/service/ 改成colletor地址 [root@localhost ~]# vim /data/projects/service/pinpoint-agent-1.5.2/pinpoint.config profiler.collector.ip=192.168.80.144 停掉應用 [root@localhost ~]# catalina.sh stop 建議必定要在應用的catalina.sh最開頭處添加一下內容 [root@localhost ~]# vim /usr/local/tomcat/bin/catalina.sh CATALINA_OPTS="$CATALINA_OPTS -javaagent:/data/projects/service/pinpoint-agent-1.5.2/pinpoint-bootstrap-1.5.2.jar" CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.agentId=0000003" CATALINA_OPTS="$CATALINA_OPTS -Dpinpoint.applicationName=192.168.80.143_8080_blog" 啓動應用 [root@localhost ~]# catalina.sh start
先進入demo應用隨便點幾個按鈕操做一下
打開pinpoint頁面,選中對應的主機和查看時間,查詢時間不能超過2天外的
框選指定時間段的散點圖,框選後會彈出這個時間段對應的數據
本文參考了扁豆燜面先生的博客:https://sconts.com/11
感謝扁豆燜面先生的分享