一、源码下载
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目录下 /框架埋点方案集成