CAT (Central Application Tracking) 简介:
CAT 是大众点评开源的一套基于java的实时应用监控平台,主要应用于服务中间件框架(MVC 框架、RPC 框架、持久层框架、分布式缓存框架)的监控,为开发和运维提供各项性能指标、健康检查、自动报警等可视化服务。
最近在公司部署大众点评的CAT,下面是我的部署过程:
系统和软件:
CAT GitHub网址:https://github.com/dianping/cat
Centos6.5
apache-maven-3.2.3-bin.zip
jdk-7u60-linux-x64.gz
cat-master.zip
#这个程序可以不用下载,直接git clone https://github.com/dianping/cat.git即可
简述安装过程:
在最初安装时,按时官方文档遇到了很多小问题,最后总结其实安装CAT很简单,大至可分为
(1)系统准备:安装git、jdk、mavent、mysql、tomcat(可以不装)
(2)CAT部署:1、Clone CAT:git clone https://github.com/dianping/cat.git
2、在CAT目录下,用maven构建项目:mvn clean install -DskipTests
3、配置CAT的环境:进入CAT目录: mvn cat:install
注(需要对/data/appdatas/cat和/data/applogs/cat有读写权限)
4、运行CAT,进入cat-home文件夹:mvn jetty:run
一、系统准备
安装git
[root@cat ~]# yum install git #yum安装git [root@cat ~]# git --version #验证版本 git version 1.7.1
2.安装mavent、jdk和解压cat
[root@cat ~]# mkdir /application #创建上面的文件夹用来做程序文件夹 [root@cat ~]# cd /home/zdw/tools/ #用来存放程序文件 [root@cat tools]# ls apache-maven-3.2.3-bin.zip cat-master.zip jdk-7u60-linux-x64.gz #已上传maven、cat、jdk文件到/home/zdw/tools/下 [root@cat tools]# yum -y install unzip #安装unzip解压软件 [root@cat tools]# unzip apache-maven-3.2.3-bin.zip -d /application #解压maven到/application/下 [root@cat tools]# ls /application/ #已复制 apache-maven-3.2.3 [root@cat tools]# unzip cat-master.zip -d /application #解压cat到/application/下 [root@cat tools]# tar xf jdk-7u60-linux-x64.gz -C /application #解压jdk到application下 [root@cat tools]# ls /application/ 查看 apache-maven-3.2.3 cat-master jdk1.7.0_60
3.配置mavent和jdk环境变量
[root@cat tools]# vi /etc/profile #配置jdk环境变量,/application/jdk1.7.0_60是程序所放在路径,版本不同,替换此项即可 export JAVA_HOME=/application/jdk1.7.0_60 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin #配置maven环境变量 export M2_HOME=/application/apache-maven-3.2.3 export M2=$M2_HOME/bin export PATH=$M2:$PATH [root@cat tools]# source /etc/profile [root@cat tools]# java -version #java验证 java version "1.7.0_60" Java(TM) SE Runtime Environment (build 1.7.0_60-b19) Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode) [root@cat tools]# mvn -v #mavent验证 Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-12T04:58:10+08:00) Maven home: /application/apache-maven-3.2.3 Java version: 1.7.0_60, vendor: Oracle Corporation Java home: /application/jdk1.7.0_60/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-431.el6.x86_64", arch: "amd64", family: "unix"
4.安装tomcat
[root@cat tools]# tar xf apache-tomcat-7.0.69.tar.gz -C /application [root@cat tools]# ls /application/ apache-maven-3.2.3 apache-tomcat-7.0.69 jdk1.7.0_60 [root@cat application]# pwd /application [root@cat application]# ln -sv apache-tomcat-7.0.69 tomcat `tomcat' -> `apache-tomcat-7.0.69'
5.安装mysql
[root@cat ~]# yum -y install mysql mysql-server mysql-devel [root@mysql ~]# chkconfig mysqld on #开机启动 [root@mysql ~]# chkconfig --list | grep mysqld #查询是否开机启动 mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@mysql ~]# service mysqld start #启动服务 Starting mysqld: [ OK ] [root@mysql ~]# mysql #进入mysql mysql> set password for root@localhost=password('root'); #用上面的命令设置root的密码为root mysql> exit Bye [root@cat ~]# mysql -u root -p #进入mysql输入刚才设置的root密码 Enter password:
6.上面已经把所需要的环境准备好,现在来处理cat
注:可以直接从第11行[root@cat cat]# git clone https://github.com/dianping/cat.git 开始操作,此操作会自动下载cat文件夹及里面的内容。
[root@cat application]# cp -r cat-master cat [root@cat cat]# pwd /application/cat [root@cat cat]# mvn clean install -DskipTests #在CAT目录下,用maven构建项目 [INFO] Scanning for projects... [WARNING] [WARNING] Some problems were encountered while building the effective model for com.dianping.cat:cat-home:war:1.3.6 [WARNING] The expression ${version} is deprecated. Please use ${project.version} instead. [WARNING] ..............................略 [root@cat cat]# git clone https://github.com/dianping/cat.git #如果mvn clean install -DskipTests不成功。使用上面命令将mvn-repo下的jar包复制到本机maven仓库,直到最后显示100% Initialized empty Git repository in /cat/cat/.git/ remote: Counting objects: 153895, done. remote: Total 153895 (delta 0), reused 0 (delta 0), pack-reused 153895 Receiving objects: 100% (153895/153895), 77.30 MiB | 32 KiB/s, done. Resolving deltas: 100% (69288/69288), done. [root@cat cat]# mvn clean install -DskipTests #再次用maven构建项目,提示100%,完成 .............略 [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:07 h [INFO] Finished at: 2016-05-19T16:47:05+08:00 [INFO] Final Memory: 33M/173M [INFO] ------------------------------------------------------------------------ [root@cat cat]# mvn cat:install #配置CAT的环境,填写数据库地址、用户名、密码 Please input jdbc url:[jdbc:mysql://127.0.0.1:3306] Please input username:root Please input password:[]root #1.官方文档有说明: #2.Linux\Mac 需要对/data/appdatas/cat和/data/applogs/cat有读写权限 #3.正好我在操作中,出现错误[ERROR] 提示,根据提示,操作下面三条命令创建文件夹,并赋予读写权限。 [root@cat cat]# mkdir -p /data/appdatas/cat [root@cat cat]# chmod 777 /data/appdatas/cat [root@cat cat]# chmod 777 /data/applogs/cat [root@cat cat]# mvn cat:install #再次配置CAT的环境,填写数据库地址、用户名、密码,完成没有出现错误 [root@cat ~]#cd cat-home [root@cat-home]#pwd /application/cat/cat-home [root@cat-home]#mvn jetty:run #最后,在cat-home下运行mvn jetty:run
到此可以用http://127.0.0.1:2281/cat/r来访问cat
下面是tomcat下访问cat的操作
tomcat下运行cat
[root@cat target]# pwd /application/cat/cat-home/target [root@cat target]# ls #在/cat-home/target下有个cat-alpha-1.3.6.war cat-alpha-1.3.6.war cat-home-1.3.6-sources.jar generated-sources test-classes cat-home-1.3.6 classes maven-archiver work [root@cat target]# cp cat-alpha-1.3.6.war /application/tomcat/webapps/cat.war #把cat-alpha-1.3.6.war改名为cat.war并复制到tomcat的webapps文件夹 [root@cat webapps]# pwd #进入tomcat的webapps文件夹 /application/tomcat/webapps [root@cat webapps]# ls cat cat.war docs examples host-manager manager ROOT [root@cat webapps]# cd /application/tomcat/bin/ #进入tomcat的bin文件夹 [root@cat bin]# ./startup.sh #启动tomcat Using CATALINA_BASE: /application/tomcat Using CATALINA_HOME: /application/tomcat Using CATALINA_TMPDIR: /application/tomcat/temp Using JRE_HOME: /application/jdk1.7.0_60 Using CLASSPATH: /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar Tomcat started.
完成