美团CAT服务端安装部署(单机版)

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/d6619309/article/details/53510585

CAT 是大众点评开源的一套基于java的实时应用监控平台,主要应用于服务中间件框架(MVC 框架、RPC 框架、持久层框架、分布式缓存框架)的监控,为开发和运维提供各项性能指标、健康检查、自动报警等可视化服务

记录美团点评CAT监控平台单机版的编译、安装、部署,搭建平台为win7,其他平台也是相同的做法。

CAT源码地址: https://github.com/dianping/cat

1. 环境准备

  • git (拉源码)
  • jdk6+
  • maven3+
  • mysql5+ (CAT web后台数据库使用mysql)
  • tomcat7+ (我们会使用tomcat来跑cat-home)

网上其他博客都说cat的编译不能使用jdk8,然而截止目前-2016-12-07,最新的CAT已经支持使用jdk8进行编译了。当前cat最新版本为1.4.0,网上大部分博客讲述的版本是1.3.6。还有最新的界面好像跟旧版本有些差别。

2. 具体步骤

2.1 获取最新源码

git clone dianping/cat

2.2 使用maven构建安装包

使用命令行工具进入cat源码目录并执行以下命令:

mvn install -Dmaven.test.skip=true

得到以下输出表示编译成功:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................. SUCCESS [ 1.450 s]
[INFO] cat-client ......................................... SUCCESS [ 16.617 s]
[INFO] cat-core ........................................... SUCCESS [ 18.583 s]
[INFO] cat-hadoop ......................................... SUCCESS [ 3.566 s]
[INFO] cat-consumer ....................................... SUCCESS [ 19.762 s]
[INFO] cat-home ........................................... SUCCESS [02:08 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:08 min
[INFO] Finished at: 2016-11-25T14:07:05+08:00
[INFO] Final Memory: 51M/771M
[INFO] ------------------------------------------------------------------------

cat官方提到部分依赖有可能因为网络问题下载不到,在github上面提供了依赖包供下载:

cat github 官网 branch 选择 mvn-repo,点击右侧按钮Clone or download直接下载依赖zip包,将zip包里面的依赖copy到你的本地maven仓库,然后再执行上面的编译命令即可。

2.3 cat环境配置

注: 前提条件

  • CAT 安装包已构建
  • 源码所在盘符创建/data/appdatas/cat/data/applogs/cat目录 (示例所在的具体位置为e:/data/appdatas/cate:/data/appdlogs/cat)

这一步主要完成自动化配置cat数据库初始化环境,以及运行所需要的一些配置文件。

官方文档提示这一步执行

mvn cat:install

但是发现会报如下错误:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................. SKIPPED
[INFO] cat-client ......................................... SKIPPED
[INFO] cat-core ........................................... SKIPPED
[INFO] cat-hadoop ......................................... SKIPPED
[INFO] cat-consumer ....................................... SKIPPED
[INFO] cat-home ........................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.796 s
[INFO] Finished at: 2016-11-25T14:07:49+08:00
[INFO] Final Memory: 11M/212M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'cat' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the reposi
tories [local (d:\mvn-repo), central (http://repo1.maven.org/maven2), unidal.releases (Index of /repositories/releases)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] NoPluginFoundForPrefixException - Apache Maven - Apache Software Foundation

后来发现cat下有个cat-maven-plugin没有成功install到我的本地maven仓库,需要单独cd到cat-maven-plugin目录下去执行构建

后来发现是cat下的pom.xml里面把cat-maven-plugin这个module给注释掉了- -。这里也可以将注释去掉,然后重新在cat目录下执行mvn install即可。

# 在cat的源码根目录前提下
cd cat-maven-plugin
mvn install

等待构建成功后,可以在你的本地maven仓库里面找到这个plugin的jar:

D:\mvn-repo\com\dianping\cat\cat-maven-plugin\1.4.0\cat-maven-plugin-1.4.0.jar

我的本地maven仓库是d:\mvn-repo

成功后在cat源码根目录执行:

mvn cat:install

需要输入mysql jdbc连接串、 登陆用户和密码,如下所示,红色圈出部分需要自己输入:

input-db-info

成功后会看到如下输出信息:

Connecting to database(jdbc:mysql://localhost:3306) ...
Connected to database(jdbc:mysql://localhost:3306)
Creating database(cat) ...
Database(cat) is created successfully
Creating tables ...
Tables are created successfully
Generating the configuration files to /data/appdatas/cat ...
Configuration files are generated successfully
Preparing Cat environment ... DONE
Use following command line to start local Cat server:
cd cat-home; mvn jetty:run
Please open http://localhost:2281/cat in your browser
------------------------------------------------------------------------
Reactor Summary:

parent ............................................. SUCCESS [ 54.572 s]
cat-client ......................................... SKIPPED
cat-core ........................................... SKIPPED
cat-hadoop ......................................... SKIPPED
cat-consumer ....................................... SKIPPED
cat-home ........................................... SKIPPED
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 55.360 s
Finished at: 2016-11-25T14:14:57+08:00
Final Memory: 12M/150M
------------------------------------------------------------------------

成功后,

  • 会在你的mysql数据库上自动创建cat数据库,还有表结构
  • 会在e:/data/appdatas/cat里面生成client.xmldatasources.xmlserver.xml

2.4 修改配置文件

需要对 /data/appdatas/cat下的配置文件: client.xmlserver.xml 做修改。进入本地目录e:/data/appdatas/cat,作如下修改:

  • client.xml
<?xml version="1.0" encoding="utf-8"?>

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" />
</servers>
</config>

其中http-port指定为tomcat默认端口(8080)

  • server.xml
<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>

注意remote-servers的配置,端口也是tomcat的默认端口

2.5 tomcat中运行

在cat-home的target子目录里面找到cat-alpha-1.4.0.war(必须成功执行前面的mvn install)

放到tomcat的webapps目录下并重命名为cat.war

进入tomcat bin目录,打开命令行,执行startup.bat,成功运行cat后,通过以下地址访问cat:

http://localhost:8080/cat/r

cat-web-ui

点击实时按钮进入监控主页面。

下篇文章将介绍客户端如何接入CAT

展开阅读全文

没有更多推荐了,返回首页