标签:report 个数 二进制 大众 task webapps 时间段 问题 基本
参考官方文档:https://github.com/dianping/cat/wiki/readme_server
1.数据库相关
(1)创建数据库cat,并执行以下sql创建相关表:
1 CREATE TABLE `dailyreport` ( 2 `id` int(11) NOT NULL AUTO_INCREMENT, 3 `name` varchar(20) NOT NULL COMMENT ‘报表名称, transaction, problem...‘, 4 `ip` varchar(50) NOT NULL COMMENT ‘报表来自于哪台cat-consumer机器‘, 5 `domain` varchar(50) NOT NULL COMMENT ‘报表处理的Domain信息‘, 6 `period` datetime NOT NULL COMMENT ‘报表时间段‘, 7 `type` tinyint(4) NOT NULL COMMENT ‘报表数据格式, 1/xml, 2/json, 默认1‘, 8 `creation_date` datetime NOT NULL COMMENT ‘报表创建时间‘, 9 PRIMARY KEY (`id`), 10 UNIQUE KEY `period` (`period`,`domain`,`name`) 11 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘天报表‘; 12 13 CREATE TABLE `weeklyreport` ( 14 `id` int(11) NOT NULL AUTO_INCREMENT, 15 `name` varchar(20) NOT NULL COMMENT ‘报表名称, transaction, problem...‘, 16 `ip` varchar(50) NOT NULL COMMENT ‘报表来自于哪台cat-consumer机器‘, 17 `domain` varchar(50) NOT NULL COMMENT ‘报表处理的Domain信息‘, 18 `period` datetime NOT NULL COMMENT ‘报表时间段‘, 19 `type` tinyint(4) NOT NULL COMMENT ‘报表数据格式, 1/xml, 2/json, 默认1‘, 20 `creation_date` datetime NOT NULL COMMENT ‘报表创建时间‘, 21 PRIMARY KEY (`id`), 22 UNIQUE KEY `period` (`period`,`domain`,`name`) 23 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘周报表‘; 24 25 CREATE TABLE `monthreport` ( 26 `id` int(11) NOT NULL AUTO_INCREMENT, 27 `name` varchar(20) NOT NULL COMMENT ‘报表名称, transaction, problem...‘, 28 `ip` varchar(50) NOT NULL COMMENT ‘报表来自于哪台cat-consumer机器‘, 29 `domain` varchar(50) NOT NULL COMMENT ‘报表处理的Domain信息‘, 30 `period` datetime NOT NULL COMMENT ‘报表时间段‘, 31 `type` tinyint(4) NOT NULL COMMENT ‘报表数据格式, 1/xml, 2/json, 默认1‘, 32 `creation_date` datetime NOT NULL COMMENT ‘报表创建时间‘, 33 PRIMARY KEY (`id`), 34 UNIQUE KEY `period` (`period`,`domain`,`name`) 35 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘月报表‘; 36 37 CREATE TABLE `hostinfo` ( 38 `id` int(11) NOT NULL AUTO_INCREMENT, 39 `ip` varchar(50) NOT NULL COMMENT ‘部署机器IP‘, 40 `domain` varchar(200) NOT NULL COMMENT ‘部署机器对应的项目名‘, 41 `hostname` varchar(200) DEFAULT NULL COMMENT ‘机器域名‘, 42 `creation_date` datetime NOT NULL, 43 `last_modified_date` datetime NOT NULL, 44 PRIMARY KEY (`id`), 45 UNIQUE KEY `ip_index` (`ip`) 46 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘IP和项目名的对应关系‘; 47 48 CREATE TABLE `hourlyreport` ( 49 `id` int(11) NOT NULL AUTO_INCREMENT, 50 `type` tinyint(4) NOT NULL COMMENT ‘报表类型, 1/xml, 9/binary 默认1‘, 51 `name` varchar(20) NOT NULL COMMENT ‘报表名称‘, 52 `ip` varchar(50) DEFAULT NULL COMMENT ‘报表来自于哪台机器‘, 53 `domain` varchar(50) NOT NULL COMMENT ‘报表项目‘, 54 `period` datetime NOT NULL COMMENT ‘报表时间段‘, 55 `creation_date` datetime NOT NULL COMMENT ‘报表创建时间‘, 56 PRIMARY KEY (`id`), 57 KEY `IX_Domain_Name_Period` (`domain`,`name`,`period`), 58 KEY `IX_Name_Period` (`name`,`period`), 59 KEY `IX_Period` (`period`) 60 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT=‘用于存放实时报表信息,处理之后的结果‘; 61 62 CREATE TABLE `hourly_report_content` ( 63 `report_id` int(11) NOT NULL COMMENT ‘报表ID‘, 64 `content` longblob NOT NULL COMMENT ‘二进制报表内容‘, 65 `period` datetime NOT NULL COMMENT ‘报表时间段‘, 66 `creation_date` datetime NOT NULL COMMENT ‘创建时间‘, 67 PRIMARY KEY (`report_id`), 68 KEY `IX_Period` (`period`) 69 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT=‘小时报表二进制内容‘; 70 71 CREATE TABLE `daily_report_content` ( 72 `report_id` int(11) NOT NULL COMMENT ‘报表ID‘, 73 `content` longblob NOT NULL COMMENT ‘二进制报表内容‘, 74 `period` datetime COMMENT ‘报表时间段‘, 75 `creation_date` datetime NOT NULL COMMENT ‘创建时间‘, 76 PRIMARY KEY (`report_id`), 77 KEY `IX_Period` (`period`) 78 )ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT=‘天报表二进制内容‘; 79 80 CREATE TABLE `weekly_report_content` ( 81 `report_id` int(11) NOT NULL COMMENT ‘报表ID‘, 82 `content` longblob NOT NULL COMMENT ‘二进制报表内容‘, 83 `period` datetime COMMENT ‘报表时间段‘, 84 `creation_date` datetime NOT NULL COMMENT ‘创建时间‘, 85 PRIMARY KEY (`report_id`), 86 KEY `IX_Period` (`period`) 87 )ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT=‘周报表二进制内容‘; 88 89 CREATE TABLE `monthly_report_content` ( 90 `report_id` int(11) NOT NULL COMMENT ‘报表ID‘, 91 `content` longblob NOT NULL COMMENT ‘二进制报表内容‘, 92 `period` datetime COMMENT ‘报表时间段‘, 93 `creation_date` datetime NOT NULL COMMENT ‘创建时间‘, 94 PRIMARY KEY (`report_id`), 95 KEY `IX_Period` (`period`) 96 )ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT=‘月报表二进制内容‘; 97 98 CREATE TABLE `businessReport` ( 99 `id` int(11) NOT NULL AUTO_INCREMENT, 100 `type` tinyint(4) NOT NULL COMMENT ‘报表类型 报表数据格式, 1/Binary, 2/xml , 3/json‘, 101 `name` varchar(20) NOT NULL COMMENT ‘报表名称‘, 102 `ip` varchar(50) NOT NULL COMMENT ‘报表来自于哪台机器‘, 103 `productLine` varchar(50) NOT NULL COMMENT ‘指标来源于哪个产品组‘, 104 `period` datetime NOT NULL COMMENT ‘报表时间段‘, 105 `content` longblob COMMENT ‘用于存放报表的具体内容‘, 106 `creation_date` datetime NOT NULL COMMENT ‘报表创建时间‘, 107 PRIMARY KEY (`id`), 108 KEY `IX_Period_productLine_name` (`period`,`productLine`,`name`) 109 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED COMMENT=‘用于存放业务监控实时报表信息,处理之后的结果‘; 110 111 CREATE TABLE `task` ( 112 `id` int(11) NOT NULL AUTO_INCREMENT, 113 `producer` varchar(20) NOT NULL COMMENT ‘任务创建者ip‘, 114 `consumer` varchar(20) NULL COMMENT ‘任务执行者ip‘, 115 `failure_count` tinyint(4) NOT NULL COMMENT ‘任务失败次数‘, 116 `report_name` varchar(20) NOT NULL COMMENT ‘报表名称, transaction, problem...‘, 117 `report_domain` varchar(50) NOT NULL COMMENT ‘报表处理的Domain信息‘, 118 `report_period` datetime NOT NULL COMMENT ‘报表时间‘, 119 `status` tinyint(4) NOT NULL COMMENT ‘执行状态: 1/todo, 2/doing, 3/done 4/failed‘, 120 `task_type` tinyint(4) NOT NULL DEFAULT ‘1‘ COMMENT ‘0表示小时任务,1表示天任务‘, 121 `creation_date` datetime NOT NULL COMMENT ‘任务创建时间‘, 122 `start_date` datetime NULL COMMENT ‘开始时间, 这次执行开始时间‘, 123 `end_date` datetime NULL COMMENT ‘结束时间, 这次执行结束时间‘, 124 PRIMARY KEY (`id`), 125 UNIQUE KEY `task_period_domain_name_type` (`report_period`,`report_domain`,`report_name`,`task_type`) 126 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘后台任务‘; 127 128 CREATE TABLE `project` ( 129 `id` int(11) NOT NULL AUTO_INCREMENT, 130 `domain` varchar(200) NOT NULL COMMENT ‘项目名称‘, 131 `cmdb_domain` varchar(200) DEFAULT NULL COMMENT ‘cmdb项目名称‘, 132 `level` int(5) DEFAULT NULL COMMENT ‘项目级别‘, 133 `bu` varchar(50) DEFAULT NULL COMMENT ‘CMDB事业部‘, 134 `cmdb_productline` varchar(50) DEFAULT NULL COMMENT ‘CMDB产品线‘, 135 `owner` varchar(50) DEFAULT NULL COMMENT ‘项目负责人‘, 136 `email` longtext DEFAULT NULL COMMENT ‘项目组邮件‘, 137 `phone` longtext DEFAULT NULL COMMENT ‘联系电话‘, 138 `creation_date` datetime DEFAULT NULL COMMENT ‘创建时间‘, 139 `modify_date` datetime DEFAULT NULL COMMENT ‘修改时间‘, 140 PRIMARY KEY (`id`), 141 UNIQUE KEY `domain` (`domain`) 142 )ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘项目基本信息‘; 143 144 CREATE TABLE `topologyGraph` ( 145 `id` int(11) NOT NULL AUTO_INCREMENT, 146 `ip` varchar(50) NOT NULL COMMENT ‘报表来自于哪台cat-client机器ip‘, 147 `period` datetime NOT NULL COMMENT ‘报表时间段,精确到分钟‘, 148 `type` tinyint(4) NOT NULL COMMENT ‘报表数据格式, 1/xml, 2/json, 3/binary‘, 149 `content` longblob COMMENT ‘用于存放报表的具体内容‘, 150 `creation_date` datetime NOT NULL COMMENT ‘报表创建时间‘, 151 PRIMARY KEY (`id`), 152 KEY `period` (`period`) 153 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘用于存储历史的拓扑图曲线‘; 154 155 CREATE TABLE `config` ( 156 `id` int(11) NOT NULL AUTO_INCREMENT, 157 `name` varchar(50) NOT NULL COMMENT ‘配置名称‘, 158 `content` longtext COMMENT ‘配置的具体内容‘, 159 `creation_date` datetime NOT NULL COMMENT ‘配置创建时间‘, 160 `modify_date` datetime NOT NULL COMMENT ‘配置修改时间‘, 161 PRIMARY KEY (`id`), 162 UNIQUE KEY `name` (`name`) 163 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘用于存储系统的全局配置信息‘; 164 165 CREATE TABLE `baseline` ( 166 `id` int(11) NOT NULL AUTO_INCREMENT, 167 `report_name` varchar(100) DEFAULT NULL, 168 `index_key` varchar(100) DEFAULT NULL, 169 `report_period` datetime DEFAULT NULL, 170 `data` blob, 171 `creation_date` datetime DEFAULT NULL, 172 PRIMARY KEY (`id`), 173 KEY `period_name_key` (`report_period`,`report_name`,`index_key`) 174 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 175 176 CREATE TABLE `alteration` ( 177 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增长ID‘, 178 `type` varchar(64) NOT NULL COMMENT ‘分类‘, 179 `title` varchar(128) NOT NULL COMMENT ‘变更标题‘, 180 `domain` varchar(128) NOT NULL COMMENT ‘变更项目‘, 181 `hostname` varchar(128) NOT NULL COMMENT ‘变更机器名‘, 182 `ip` varchar(128) DEFAULT NULL COMMENT ‘变更机器IP‘, 183 `date` datetime NOT NULL COMMENT ‘变更时间‘, 184 `user` varchar(45) NOT NULL COMMENT ‘变更用户‘, 185 `alt_group` varchar(45) DEFAULT NULL COMMENT ‘变更组别‘, 186 `content` longtext NOT NULL COMMENT ‘变更内容‘, 187 `url` varchar(200) DEFAULT NULL COMMENT ‘变更链接‘, 188 `status` tinyint(4) DEFAULT ‘0‘ COMMENT ‘变更状态‘, 189 `creation_date` datetime NOT NULL COMMENT ‘数据库创建时间‘, 190 PRIMARY KEY (`id`), 191 KEY `ind_date_domain_host` (`date`,`domain`,`hostname`) 192 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘变更表‘; 193 194 CREATE TABLE `alert` ( 195 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增长ID‘, 196 `domain` varchar(128) NOT NULL COMMENT ‘告警项目‘, 197 `alert_time` datetime NOT NULL COMMENT ‘告警时间‘, 198 `category` varchar(64) NOT NULL COMMENT ‘告警分类:network/business/system/exception -alert‘, 199 `type` varchar(64) NOT NULL COMMENT ‘告警类型:error/warning‘, 200 `content` longtext NOT NULL COMMENT ‘告警内容‘, 201 `metric` varchar(128) NOT NULL COMMENT ‘告警指标‘, 202 `creation_date` datetime NOT NULL COMMENT ‘数据插入时间‘, 203 PRIMARY KEY (`id`) 204 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘存储告警信息‘; 205 206 CREATE TABLE `alert_summary` ( 207 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增长ID‘, 208 `domain` varchar(128) NOT NULL COMMENT ‘告警项目‘, 209 `alert_time` datetime NOT NULL COMMENT ‘告警时间‘, 210 `content` longtext NOT NULL COMMENT ‘统一告警内容‘, 211 `creation_date` datetime NOT NULL COMMENT ‘数据插入时间‘, 212 PRIMARY KEY (`id`) 213 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘统一告警信息‘; 214 215 CREATE TABLE `operation` ( 216 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增长ID‘, 217 `user` varchar(128) NOT NULL COMMENT ‘用户名‘, 218 `module` varchar(128) NOT NULL COMMENT ‘模块‘, 219 `operation` varchar(128) NOT NULL COMMENT ‘操作‘, 220 `time` datetime NOT NULL COMMENT ‘修改时间‘, 221 `content` longtext NOT NULL COMMENT ‘修改内容‘, 222 `creation_date` datetime NOT NULL COMMENT ‘数据插入时间‘, 223 PRIMARY KEY (`id`) 224 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘用户操作日志‘; 225 226 CREATE TABLE `overload` ( 227 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增长ID‘, 228 `report_id` int(11) NOT NULL COMMENT ‘报告id‘, 229 `report_type` tinyint(4) NOT NULL COMMENT ‘报告类型 1:hourly 2:daily 3:weekly 4:monthly‘, 230 `report_size` double NOT NULL COMMENT ‘报告大小 单位MB‘, 231 `period` datetime NOT NULL COMMENT ‘报表时间‘, 232 `creation_date` datetime NOT NULL COMMENT ‘创建时间‘, 233 PRIMARY KEY (`id`), 234 KEY `period` (`period`) 235 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘过大容量表‘; 236 237 CREATE TABLE `config_modification` ( 238 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增长ID‘, 239 `user_name` varchar(64) NOT NULL COMMENT ‘用户名‘, 240 `account_name` varchar(64) NOT NULL COMMENT ‘账户名‘, 241 `action_name` varchar(64) NOT NULL COMMENT ‘action名‘, 242 `argument` longtext COMMENT ‘参数内容‘, 243 `date` datetime NOT NULL COMMENT ‘修改时间‘, 244 `creation_date` datetime NOT NULL COMMENT ‘创建时间‘, 245 PRIMARY KEY (`id`) 246 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘配置修改记录表‘; 247 248 CREATE TABLE `user_define_rule` ( 249 `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增长ID‘, 250 `content` text NOT NULL COMMENT ‘用户定义规则‘, 251 `creation_date` datetime NOT NULL COMMENT ‘创建时间‘, 252 PRIMARY KEY (`id`) 253 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘用户定义规则表‘; 254 255 CREATE TABLE `business_config` ( 256 `id` int(11) NOT NULL AUTO_INCREMENT, 257 `name` varchar(20) NOT NULL DEFAULT ‘‘ COMMENT ‘配置名称‘, 258 `domain` varchar(50) NOT NULL DEFAULT ‘‘ COMMENT ‘项目‘, 259 `content` longtext COMMENT ‘配置内容‘, 260 `updatetime` datetime NOT NULL, 261 PRIMARY KEY (`id`), 262 KEY `updatetime` (`updatetime`), 263 KEY `name_domain` (`name`,`domain`) 264 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 265 266 CREATE TABLE `metric_screen` ( 267 `id` int(11) NOT NULL AUTO_INCREMENT, 268 `name` varchar(50) NOT NULL COMMENT ‘配置名称‘, 269 `graph_name` varchar(50) NOT NULL DEFAULT ‘‘ COMMENT ‘Graph名称‘, 270 `view` varchar(50) NOT NULL DEFAULT ‘‘ COMMENT ‘视角‘, 271 `endPoints` longtext NOT NULL, 272 `measurements` longtext NOT NULL COMMENT ‘配置的指标‘, 273 `content` longtext NOT NULL COMMENT ‘配置的具体内容‘, 274 `creation_date` datetime NOT NULL COMMENT ‘配置创建时间‘, 275 `updatetime` datetime NOT NULL COMMENT ‘配置修改时间‘, 276 PRIMARY KEY (`id`), 277 UNIQUE KEY `name_graph` (`name`,`graph_name`) 278 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘系统监控的screen配置‘; 279 280 CREATE TABLE `metric_graph` ( 281 `id` int(11) NOT NULL AUTO_INCREMENT, 282 `graph_id` int(11) NOT NULL COMMENT ‘大盘ID‘, 283 `name` varchar(50) NOT NULL COMMENT ‘配置ID‘, 284 `content` longtext COMMENT ‘配置的具体内容‘, 285 `creation_date` datetime NOT NULL COMMENT ‘配置创建时间‘, 286 `updatetime` datetime NOT NULL COMMENT ‘配置修改时间‘, 287 PRIMARY KEY (`id`), 288 UNIQUE `name` (`name`) 289 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘系统监控的graph配置‘; 290 291 CREATE TABLE `server_alarm_rule` ( 292 `id` int(11) NOT NULL AUTO_INCREMENT, 293 `category` varchar(50) NOT NULL COMMENT ‘监控分类‘, 294 `endPoint` varchar(200) NOT NULL COMMENT ‘监控对象ID‘, 295 `measurement` varchar(200) NOT NULL COMMENT ‘监控指标‘, 296 `tags` varchar(200) NOT NULL DEFAULT ‘‘ COMMENT ‘监控指标标签‘, 297 `content` longtext NOT NULL COMMENT ‘配置的具体内容‘, 298 `type` varchar(20) NOT NULL DEFAULT ‘‘ COMMENT ‘数据聚合方式‘, 299 `creator` varchar(100) DEFAULT ‘‘ COMMENT ‘创建人‘, 300 `creation_date` datetime NOT NULL COMMENT ‘配置创建时间‘, 301 `updatetime` datetime NOT NULL COMMENT ‘配置修改时间‘, 302 PRIMARY KEY (`id`), 303 KEY `updatetime` (`updatetime`) 304 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘系统告警的配置‘;
(2)一套独立的CAT集群只需要一个数据库;
(3)数据库编码使用utf8mb4,否则可能造成中文乱码等问题;
2.服务端部署
(1)下载Tomcat服务器,如:https://tomcat.apache.org/download-80.cgi
(2)下载cat.war包,由于依赖问题,个人建议直接下载官网打好包的cat-home-3.0.0.war,然后重命名为cat.war,下载地址:http://unidal.org/nexus/service/local/repositories/releases/content/com/dianping/cat/cat-home/3.0.0/cat-home-3.0.0.war
(3)将cat.war放到解压后的Tomcat的webapps目录下
3.服务端配置
(1)创建相关目录并赋权限,并在/data/appdatas/cat目录下新建client.xml,server.xml,datasources.xml配置文件
mkdir -p /data/{appdatas,applogs}/cat
chmod -R 777 /data
(2)datasources.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 3 <data-sources> 4 <data-source id="cat"> 5 <maximum-pool-size>3</maximum-pool-size> 6 <connection-timeout>1s</connection-timeout> 7 <idle-timeout>10m</idle-timeout> 8 <statement-cache-size>1000</statement-cache-size> 9 <properties> 10 <driver>com.mysql.jdbc.Driver</driver> 11 <url><![CDATA[jdbc:mysql://192.168.0.1:3306/cat]]></url> <!-- 请替换为真实数据库URL及Port --> 12 <user>test</user> 13 <password>test</password> 14 <connectionProperties><![CDATA[useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&socketTimeout=120000]]></connectionProperties> 15 </properties> 16 </data-source> 17 </data-sources>
(3)server.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <!-- Configuration for development environment--> 3 <config local-mode="false" hdfs-machine="false" job-machine="true" alert-machine="true"> 4 <storage local-base-dir="/data/appdatas/cat/bucket/" max-hdfs-storage-time="15" local-report-storage-time="7" local-logivew-storage-time="7"> 5 </storage> 6 <console default-domain="Cat" show-cat-domain="true"> 7 <!--将172.16.90.114修改为部署CAT的内网IP,请不要写127.0.0.1和外网IP --> 8 <remote-servers>10.223.123.221:8080</remote-servers> 9 </console> 10 </config>
(4)client.xml
1 <?xml version="1.0" encoding="utf-8"?> 2 <config mode="client" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="config.xsd"> 3 <servers> 4 <!-- ip:部署CAT应用的服务器IP 5 port:CAT服务端接收客户端数据的端口(不允许更改) 6 http-port:CAT应用部署到的容器的端口(tomcat的端口) 7 <servers> 8 <server ip="192.168.126.101" port="2280" http-port="8080" /> 9 <server ip="192.168.126.102" port="2280" http-port="8080" /> 10 <server ip="192.168.126.103" port="2280" http-port="8080" /> 11 </servers> 12 --> 13 14 <server ip="10.223.123.221" port="2280" http-port="8080" /> 15 </servers> 16 </config>
4.重算客户端路由
(1)启动Tomcat,访问http://10.223.123.221:8080/cat/s/config?op=routerConfigUpdate
1 <?xml version="1.0" encoding="utf-8"?> 2 <router-config backup-server="部署CAT的服务器内网ip" backup-server-port="2280"> 3 <default-server id="部署CAT的服务器内网ip" weight="1.0" port="2280" enable="true"/> 4 <network-policy id="default" title="默认" block="false" server-group="default_group"> 5 </network-policy> 6 </router-config>
点击提交按钮,然后点击重算路由按钮,就绪后重启Tomcat即可(测试不重启Tomcat也能生效)
访问http://10.223.123.221:8080/cat/r,如果显示下图则表示服务端部署成功
如果显示“有问题的CAT服务器[ip]”,请核查一下配置文件以及客户端路由中,都修改为内网ip。
5.客户端springboot集成
(1)在项目的同一个盘符下创建client.xml配置文件和日志目录,文件结构与服务端一致即可,ip改为cat服务端对应的IP,内容如下:
<?xml version="1.0" encoding="utf-8"?> <config mode="client" xmlns:xsi="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="config.xsd"> <servers> <!-- ip:部署CAT应用的服务器IP port:CAT服务端接收客户端数据的端口(不允许更改) http-port:CAT应用部署到的容器的端口(tomcat的端口) <servers> <server ip="192.168.126.101" port="2280" http-port="8080" /> <server ip="192.168.126.102" port="2280" http-port="8080" /> <server ip="192.168.126.103" port="2280" http-port="8080" /> </servers> --> <server ip="10.223.123.221" port="2280" http-port="8080" /> </servers> </config>
(2)下载cat-client依赖包,安装到本地maven仓库:
先打开该网址:https://mvnrepository.com/artifact/com.dianping.cat/cat-client/3.0.0===》http://unidal.org/nexus/content/repositories/releases/然后即可下载需要的jar包
本人在测试过程中,发现maven依赖的方式下载不下来,固直接下载jar包下来安装到本地仓库:http://unidal.org/nexus/content/repositories/releases/com/dianping/cat/cat-client/3.0.0/cat-client-3.0.0.jar
需要下载如下图这两个jar:
执行命令安装:mvn install:install-file -Dfile=cat-client-3.0.0.jar -DgroupId=com.dianping.cat -DartifactId=cat-client -Dversion=3.0.0 -Dpackaging=jar
这样就能在springboot项目中进行依赖了。
(3)项目配置和埋点
埋点方式还在研究探索中,后续更新,简单做了一个,看下效果:
标签:report 个数 二进制 大众 task webapps 时间段 问题 基本
原文地址:https://www.cnblogs.com/shuo1208/p/11798873.html