本机IP:192.168.15.1 本机IP自行查看
GitHub:https://github.com/dianping/cat
Gitee:https://gitee.com/mirrors/CAT
1、源码编译
1.1 克隆源码到本地(以Gitee为例)
git clone https://gitee.com/mirrors/CAT.git
1.2 编译
# 切换到CAT目录
cd CAT
# 编译
mvn clean install -DskipTests
产出:cat-home.war
路径: /CAT/cat-home/target/cat-home.war
2、创建数据库
2.1 创建数据库(IP:192.168.1.211),以下参数自行修改
数据库名:cat
用户名:root
密码:123456
2.2 初始化脚本
运行 script/CatApplication.sql (直接用navicate运行)
3、部署CAT
3.1 新建⽬录/data/appdatas/cat、/data/applogs/cat 并赋予读写权限
3.2 新建⽂件/data/appdatas/cat/client.xml
<?xml version="1.0" encoding="utf-8"?>
<config mode="client">
<servers>
<server ip="192.168.15.1" port="2280" http-port="8080"/>
</servers>
</config>
3.3 新建⽂件/data/appdatas/cat/datasources.xml
<?xml version="1.0" encoding="utf-8"?>
<data-sources>
<data-source id="cat">
<maximum-pool-size>3</maximum-pool-size>
<connection-timeout>1s</connection-timeout>
<idle-timeout>10m</idle-timeout>
<statement-cache-size>1000</statement-cache-size>
<properties>
<driver>com.mysql.jdbc.Driver</driver>
<url><![CDATA[jdbc:mysql://192.168.1.211:3306/cat]]></url> <!-- 请替换为真实数据库URL及Port -->
<user>root</user> <!-- 请替换为真实数据库⽤户名 -->
<password>123456</password> <!-- 请替换为真实数据库密码 -->
<connectionProperties><![CDATA[useUnicode=true&characterEncoding=UTF8&autoReconnect=true&socketTimeout=120000]]></connectionProperties>
</properties>
</data-source>
</data-sources>
3.4 启动cat
3.4.1 把/CAT/cat-home/target/cat-home.war 复制到 tomcat的webapps目录下并重命名为cat.war
3.4.2 启动tomcat,默认端口为8080,修改端口请自行编辑tomcat/conf/server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
访问:http://192.168.15.1:8080/cat
会出现 如下错误:
出问题CAT的服务端:[127.0.0.1]
4、配置
4.1 打开控制台的URL,http://192.168.15.1:8080/cat/s/config?op=routerConfigUpdate
把相关IP换成:192.168.15.1
<?xml version="1.0" encoding="utf-8"?>
<router-config backup-server="192.168.15.1" backup-server-port="2280">
<default-server id="192.168.15.1" weight="1.0" port="2280" enable="true"/>
<network-policy id="default" title="默认" block="false" server-group="default_group">
</network-policy>
<server-group id="default_group" title="default-group">
<group-server id="192.168.15.1"/>
</server-group>
<domain id="cat">
<group id="default">
<server id="192.168.15.1" port="2280" weight="1.0"/>
</group>
</domain>
</router-config>
4.2 打开控制台的URL,http://192.168.15.1:8080/cat/s/config?op=serverConfigUpdate
把相关IP换成:192.168.15.1
<?xml version="1.0" encoding="utf-8"?>
<server-config>
<server id="default">
<properties>
<property name="local-mode" value="false"/>
<property name="job-machine" value="false"/>
<property name="send-machine" value="false"/>
<property name="alarm-machine" value="false"/>
<property name="hdfs-enabled" value="false"/>
<property name="remote-servers" value="192.168.15.1:8080"/>
</properties>
<storage local-base-dir="/data/appdatas/cat/bucket/" max-hdfs-storage-time="15" local-report-storage-time="2" local-logivew-storage-time="1" har-mode="true" upload-thread="5">
<hdfs id="dump" max-size="128M" server-uri="hdfs://192.168.15.1/" base-dir="/user/cat/dump"/>
<harfs id="dump" max-size="128M" server-uri="har://192.168.15.1/" base-dir="/user/cat/dump"/>
<properties>
<property name="hadoop.security.authentication" value="false"/>
<property name="dfs.namenode.kerberos.principal" value="hadoop/dev80.hadoop@testserver.com"/>
<property name="dfs.cat.kerberos.principal" value="cat@testserver.com"/>
<property name="dfs.cat.keytab.file" value="/data/appdatas/cat/cat.keytab"/>
<property name="java.security.krb5.realm" value="value1"/>
<property name="java.security.krb5.kdc" value="value2"/>
</properties>
</storage>
<consumer>
<long-config default-url-threshold="1000" default-sql-threshold="100" default-service-threshold="50">
<domain name="cat" url-threshold="500" sql-threshold="500"/>
<domain name="OpenPlatformWeb" url-threshold="100" sql-threshold="500"/>
</long-config>
</consumer>
</server>
<server id="192.168.15.1">
<properties>
<property name="job-machine" value="true"/>
<property name="send-machine" value="true"/>
<property name="alarm-machine" value="true"/>
</properties>
</server>
</server-config>
配置完后,恢复正常
CAT服务端正常