一、源碼下載
CAT源碼地址: https://github.com/dianping/cat
網絡原因,下載過慢建議使用國內資源如:
馬雲源碼下載 https://gitee.com/zz20160215/cat
二、Maven配置
由於很多需要的jar包需要國外maven中央倉庫,建議配置國內maven鏡像
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
三、編譯Cat源碼
1、下載源碼後,在源碼目錄執行maven命令 mvn clean install -Dmaven.test.skip=true(跳過測試代碼)
2、編譯成功後,會在Cat統計目錄下生產Data文件夾。此時需要對此文件夾進行開放讀寫權限操作。
3、在cat目錄下執行 mvn cat:install
此命令執行過程中需要你輸入mysql數據庫地址、賬戶、密碼,確保賬戶有創建庫、表的權限
注意:此過程中出現此錯誤問題
java.sql.SQLException: java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long
解決辦法:將cat文件中pom.xml中mysql-connector-java版本改爲如下
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>
mvn cat:install執行成功後,即可在數據庫看到cat數據庫
4、修改data目錄下配置文件
client.xml 客戶端配置文件
<?xml version="1.0" encoding="utf-8"?>
<config mode="client" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="config.xsd">
<servers>
<!-- Local mode for development -->
<server ip="127.0.0.1" port="2280" http-port="8080" />
<!-- If under production environment, put actual server address as list. -->
<!--
<server ip="192.168.7.71" port="2280" />
<server ip="192.168.7.72" port="2280" />
-->
</servers>
</config>
server.xml服務端配置文件
<?xml version="1.0" encoding="utf-8"?>
<!-- Configuration for development environment-->
<config local-mode="false" hdfs-machine="false" job-machine="true" alert-machine="false">
<storage local-base-dir="/data/appdatas/cat/bucket/" max-hdfs-storage-time="15" local-report-storage-time="7" local-logivew-storage-time="7">
</storage>
<console default-domain="Cat" show-cat-domain="true">
<remote-servers>127.0.0.1:8080</remote-servers>
</console>
</config>
<!-- Configuration for production environment -->
<!-- Note: -->
<!-- 1. Set local-mode false to activate remote mode. -->
<!-- 2. If machine is job-machine, set job-machine true, you just need config only one machine. Job is offline for report aggreation, statistics report.-->
<!-- 3. If machine is alert-machine, set alert-machine true, you just need config only one machine. -->
<!-- 4. Cat can run without hdfs, you just config hdfs-machine false. If you have hdfs, you can config hdfs info for saving the logview info. -->
<!-- 5. If you don't need hdfs, the logview will be stored in local disk. You can config max local-logivew-storage-time for cleaning up old logview, the unit is day. -->
<!-- 6. Please set hadoop environment accordingly. -->
<!-- 7. Please set ldap info for login the system. -->
<!-- 8. Please config remote-server if you have many cat servers. -->
<!--
<config local-mode="false" hdfs-machine="false" job-machine="false" alert-machine="false">
<storage local-base-dir="/data/appdatas/cat/bucket/" max-hdfs-storage-time="15" local-report-storage-time="7" local-logivew-storage-time="7">
<hdfs id="logview" max-size="128M" server-uri="hdfs://10.1.77.86/user/cat" base-dir="logview"/>
<hdfs id="dump" max-size="128M" server-uri="hdfs://10.1.77.86/user/cat" base-dir="dump"/>
<hdfs id="remote" max-size="128M" server-uri="hdfs://10.1.77.86/user/cat" base-dir="remote"/>
</storage>
<console default-domain="Cat" show-cat-domain="true">
<remote-servers>192.168.0.1:2281,192.168.0.2:2281</remote-servers>
</console>
<ldap ldapUrl="ldap://192.168.50.11:389/DC=dianpingoa,DC=com"/>
</config>
-->
四、部署Cat服務
在tomcat下部署cat服務步驟:
1、在E:\cat\cat-home\target目錄下找到 cat-alpha-1.4.0.war文件
2、複製此文件到tomcat下的webapps下,修改名稱 cat.war
3、啓動tomcat,訪問127.0.0.1\cat
最後
至此美團分佈式監控系統cat服務端就部署完成,剩下就是客戶端進行相關配置來監控,這樣服務端就可以監控客戶端的各項指標。具體配置在cat目錄下 /框架埋點方案集成