单机版cat3.x搭建


1 前期准备

版本:jdk8 + mysql5.7 + cat3.0.0 + tomcat8 + centos7(virtualbox虚拟机运行) + spirngboot2.x + slf4j+ logback

创建软件安装目录

mkdir -p /usr/local/server

查看服务器IP

安装JDK环境

yum install -y java-1.8.0-openjdk.x86_64
yum install -y java-devel

2 MySQL部署

创建mysql日志目录和配置文件

###
mkdir -p /mydata/mysql/log /mydata/mysql/data /mydata/mysql/conf
###
vi /mydata/mysql/conf/my.cnf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci' 
init_connect='SET NAMES utf8' 
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve

docker启动mysql

docker run \
-p 33060:3306 \
--name mysql_cat \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:5.7

jdbc:mysql://10.4.42.36:33060/?serverTimezone=UTC

创建cat数据库

# 建库
CREATE DATABASE cat DEFAULT CHAR SET utf8mb4;
USE cat;
# 建表
CREATE TABLE `dailyreport`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `name`          varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
    `ip`            varchar(50) NOT NULL COMMENT '报表来自于哪台cat-consumer机器',
    `domain`        varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
    `period`        datetime    NOT NULL COMMENT '报表时间段',
    `type`          tinyint(4)  NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 默认1',
    `creation_date` datetime    NOT NULL COMMENT '报表创建时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `period` (`period`, `domain`, `name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='天报表';
CREATE TABLE `weeklyreport`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `name`          varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
    `ip`            varchar(50) NOT NULL COMMENT '报表来自于哪台cat-consumer机器',
    `domain`        varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
    `period`        datetime    NOT NULL COMMENT '报表时间段',
    `type`          tinyint(4)  NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 默认1',
    `creation_date` datetime    NOT NULL COMMENT '报表创建时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `period` (`period`, `domain`, `name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='周报表';
CREATE TABLE `monthreport`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `name`          varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
    `ip`            varchar(50) NOT NULL COMMENT '报表来自于哪台cat-consumer机器',
    `domain`        varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
    `period`        datetime    NOT NULL COMMENT '报表时间段',
    `type`          tinyint(4)  NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 默认1',
    `creation_date` datetime    NOT NULL COMMENT '报表创建时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `period` (`period`, `domain`, `name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='月报表';
CREATE TABLE `hostinfo`
(
    `id`                 int(11)      NOT NULL AUTO_INCREMENT,
    `ip`                 varchar(50)  NOT NULL COMMENT '部署机器IP',
    `domain`             varchar(200) NOT NULL COMMENT '部署机器对应的项目名',
    `hostname`           varchar(200) DEFAULT NULL COMMENT '机器域名',
    `creation_date`      datetime     NOT NULL,
    `last_modified_date` datetime     NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `ip_index` (`ip`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='IP和项目名的对应关系';
CREATE TABLE `hourlyreport`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `type`          tinyint(4)  NOT NULL COMMENT '报表类型, 1/xml, 9/binary 默认1',
    `name`          varchar(20) NOT NULL COMMENT '报表名称',
    `ip`            varchar(50) DEFAULT NULL COMMENT '报表来自于哪台机器',
    `domain`        varchar(50) NOT NULL COMMENT '报表项目',
    `period`        datetime    NOT NULL COMMENT '报表时间段',
    `creation_date` datetime    NOT NULL COMMENT '报表创建时间',
    PRIMARY KEY (`id`),
    KEY `IX_Domain_Name_Period` (`domain`, `name`, `period`),
    KEY `IX_Name_Period` (`name`, `period`),
    KEY `IX_Period` (`period`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  ROW_FORMAT = COMPRESSED COMMENT ='用于存放实时报表信息,处理之后的结果';
CREATE TABLE `hourly_report_content`
(
    `report_id`     int(11)  NOT NULL COMMENT '报表ID',
    `content`       longblob NOT NULL COMMENT '二进制报表内容',
    `period`        datetime NOT NULL COMMENT '报表时间段',
    `creation_date` datetime NOT NULL COMMENT '创建时间',
    PRIMARY KEY (`report_id`),
    KEY `IX_Period` (`period`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  ROW_FORMAT = COMPRESSED COMMENT ='小时报表二进制内容';
CREATE TABLE `daily_report_content`
(
    `report_id`     int(11)  NOT NULL COMMENT '报表ID',
    `content`       longblob NOT NULL COMMENT '二进制报表内容',
    `period`        datetime COMMENT '报表时间段',
    `creation_date` datetime NOT NULL COMMENT '创建时间',
    PRIMARY KEY (`report_id`),
    KEY `IX_Period` (`period`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  ROW_FORMAT = COMPRESSED COMMENT ='天报表二进制内容';
CREATE TABLE `weekly_report_content`
(
    `report_id`     int(11)  NOT NULL COMMENT '报表ID',
    `content`       longblob NOT NULL COMMENT '二进制报表内容',
    `period`        datetime COMMENT '报表时间段',
    `creation_date` datetime NOT NULL COMMENT '创建时间',
    PRIMARY KEY (`report_id`),
    KEY `IX_Period` (`period`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  ROW_FORMAT = COMPRESSED COMMENT ='周报表二进制内容';
CREATE TABLE `monthly_report_content`
(
    `report_id`     int(11)  NOT NULL COMMENT '报表ID',
    `content`       longblob NOT NULL COMMENT '二进制报表内容',
    `period`        datetime COMMENT '报表时间段',
    `creation_date` datetime NOT NULL COMMENT '创建时间',
    PRIMARY KEY (`report_id`),
    KEY `IX_Period` (`period`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  ROW_FORMAT = COMPRESSED COMMENT ='月报表二进制内容';

CREATE TABLE `businessReport`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `type`          tinyint(4)  NOT NULL COMMENT '报表类型 报表数据格式, 1/Binary, 2/xml , 3/json',
    `name`          varchar(20) NOT NULL COMMENT '报表名称',
    `ip`            varchar(50) NOT NULL COMMENT '报表来自于哪台机器',
    `productLine`   varchar(50) NOT NULL COMMENT '指标来源于哪个产品组',
    `period`        datetime    NOT NULL COMMENT '报表时间段',
    `content`       longblob COMMENT '用于存放报表的具体内容',
    `creation_date` datetime    NOT NULL COMMENT '报表创建时间',
    PRIMARY KEY (`id`),
    KEY `IX_Period_productLine_name` (`period`, `productLine`, `name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8
  ROW_FORMAT = COMPRESSED COMMENT ='用于存放业务监控实时报表信息,处理之后的结果';

CREATE TABLE `task`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `producer`      varchar(20) NOT NULL COMMENT '任务创建者ip',
    `consumer`      varchar(20) NULL COMMENT '任务执行者ip',
    `failure_count` tinyint(4)  NOT NULL COMMENT '任务失败次数',
    `report_name`   varchar(20) NOT NULL COMMENT '报表名称, transaction, problem...',
    `report_domain` varchar(50) NOT NULL COMMENT '报表处理的Domain信息',
    `report_period` datetime    NOT NULL COMMENT '报表时间',
    `status`        tinyint(4)  NOT NULL COMMENT '执行状态: 1/todo, 2/doing, 3/done 4/failed',
    `task_type`     tinyint(4)  NOT NULL DEFAULT '1' COMMENT '0表示小时任务,1表示天任务',
    `creation_date` datetime    NOT NULL COMMENT '任务创建时间',
    `start_date`    datetime    NULL COMMENT '开始时间, 这次执行开始时间',
    `end_date`      datetime    NULL COMMENT '结束时间, 这次执行结束时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `task_period_domain_name_type` (`report_period`, `report_domain`, `report_name`, `task_type`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='后台任务';

CREATE TABLE `project`
(
    `id`               int(11)      NOT NULL AUTO_INCREMENT,
    `domain`           varchar(200) NOT NULL COMMENT '项目名称',
    `cmdb_domain`      varchar(200) DEFAULT NULL COMMENT 'cmdb项目名称',
    `level`            int(5)       DEFAULT NULL COMMENT '项目级别',
    `bu`               varchar(50)  DEFAULT NULL COMMENT 'CMDB事业部',
    `cmdb_productline` varchar(50)  DEFAULT NULL COMMENT 'CMDB产品线',
    `owner`            varchar(50)  DEFAULT NULL COMMENT '项目负责人',
    `email`            longtext     DEFAULT NULL COMMENT '项目组邮件',
    `phone`            longtext     DEFAULT NULL COMMENT '联系电话',
    `creation_date`    datetime     DEFAULT NULL COMMENT '创建时间',
    `modify_date`      datetime     DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `domain` (`domain`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='项目基本信息';

CREATE TABLE `topologyGraph`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `ip`            varchar(50) NOT NULL COMMENT '报表来自于哪台cat-client机器ip',
    `period`        datetime    NOT NULL COMMENT '报表时间段,精确到分钟',
    `type`          tinyint(4)  NOT NULL COMMENT '报表数据格式, 1/xml, 2/json, 3/binary',
    `content`       longblob COMMENT '用于存放报表的具体内容',
    `creation_date` datetime    NOT NULL COMMENT '报表创建时间',
    PRIMARY KEY (`id`),
    KEY `period` (`period`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='用于存储历史的拓扑图曲线';

CREATE TABLE `config`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `name`          varchar(50) NOT NULL COMMENT '配置名称',
    `content`       longtext COMMENT '配置的具体内容',
    `creation_date` datetime    NOT NULL COMMENT '配置创建时间',
    `modify_date`   datetime    NOT NULL COMMENT '配置修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `name` (`name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='用于存储系统的全局配置信息';

CREATE TABLE `baseline`
(
    `id`            int(11) NOT NULL AUTO_INCREMENT,
    `report_name`   varchar(100) DEFAULT NULL,
    `index_key`     varchar(100) DEFAULT NULL,
    `report_period` datetime     DEFAULT NULL,
    `data`          blob,
    `creation_date` datetime     DEFAULT NULL,
    PRIMARY KEY (`id`),
    KEY `period_name_key` (`report_period`, `report_name`, `index_key`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

CREATE TABLE `alteration`
(
    `id`            int(11)      NOT NULL AUTO_INCREMENT COMMENT '自增长ID',
    `type`          varchar(64)  NOT NULL COMMENT '分类',
    `title`         varchar(128) NOT NULL COMMENT '变更标题',
    `domain`        varchar(128) NOT NULL COMMENT '变更项目',
    `hostname`      varchar(128) NOT NULL COMMENT '变更机器名',
    `ip`            varchar(128) DEFAULT NULL COMMENT '变更机器IP',
    `date`          datetime     NOT NULL COMMENT '变更时间',
    `user`          varchar(45)  NOT NULL COMMENT '变更用户',
    `alt_group`     varchar(45)  DEFAULT NULL COMMENT '变更组别',
    `content`       longtext     NOT NULL COMMENT '变更内容',
    `url`           varchar(200) DEFAULT NULL COMMENT '变更链接',
    `status`        tinyint(4)   DEFAULT '0' COMMENT '变更状态',
    `creation_date` datetime     NOT NULL COMMENT '数据库创建时间',
    PRIMARY KEY (`id`),
    KEY `ind_date_domain_host` (`date`, `domain`, `hostname`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='变更表';

CREATE TABLE `alert`
(
    `id`            int(11)      NOT NULL AUTO_INCREMENT COMMENT '自增长ID',
    `domain`        varchar(128) NOT NULL COMMENT '告警项目',
    `alert_time`    datetime     NOT NULL COMMENT '告警时间',
    `category`      varchar(64)  NOT NULL COMMENT '告警分类:network/business/system/exception -alert',
    `type`          varchar(64)  NOT NULL COMMENT '告警类型:error/warning',
    `content`       longtext     NOT NULL COMMENT '告警内容',
    `metric`        varchar(128) NOT NULL COMMENT '告警指标',
    `creation_date` datetime     NOT NULL COMMENT '数据插入时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='存储告警信息';

CREATE TABLE `alert_summary`
(
    `id`            int(11)      NOT NULL AUTO_INCREMENT COMMENT '自增长ID',
    `domain`        varchar(128) NOT NULL COMMENT '告警项目',
    `alert_time`    datetime     NOT NULL COMMENT '告警时间',
    `content`       longtext     NOT NULL COMMENT '统一告警内容',
    `creation_date` datetime     NOT NULL COMMENT '数据插入时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='统一告警信息';

CREATE TABLE `operation`
(
    `id`            int(11)      NOT NULL AUTO_INCREMENT COMMENT '自增长ID',
    `user`          varchar(128) NOT NULL COMMENT '用户名',
    `module`        varchar(128) NOT NULL COMMENT '模块',
    `operation`     varchar(128) NOT NULL COMMENT '操作',
    `time`          datetime     NOT NULL COMMENT '修改时间',
    `content`       longtext     NOT NULL COMMENT '修改内容',
    `creation_date` datetime     NOT NULL COMMENT '数据插入时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='用户操作日志';

CREATE TABLE `overload`
(
    `id`            int(11)    NOT NULL AUTO_INCREMENT COMMENT '自增长ID',
    `report_id`     int(11)    NOT NULL COMMENT '报告id',
    `report_type`   tinyint(4) NOT NULL COMMENT '报告类型 1:hourly 2:daily 3:weekly 4:monthly',
    `report_size`   double     NOT NULL COMMENT '报告大小 单位MB',
    `period`        datetime   NOT NULL COMMENT '报表时间',
    `creation_date` datetime   NOT NULL COMMENT '创建时间',
    PRIMARY KEY (`id`),
    KEY `period` (`period`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='过大容量表';

CREATE TABLE `config_modification`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT COMMENT '自增长ID',
    `user_name`     varchar(64) NOT NULL COMMENT '用户名',
    `account_name`  varchar(64) NOT NULL COMMENT '账户名',
    `action_name`   varchar(64) NOT NULL COMMENT 'action名',
    `argument`      longtext COMMENT '参数内容',
    `date`          datetime    NOT NULL COMMENT '修改时间',
    `creation_date` datetime    NOT NULL COMMENT '创建时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='配置修改记录表';

CREATE TABLE `user_define_rule`
(
    `id`            int(11)  NOT NULL AUTO_INCREMENT COMMENT '自增长ID',
    `content`       text     NOT NULL COMMENT '用户定义规则',
    `creation_date` datetime NOT NULL COMMENT '创建时间',
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='用户定义规则表';

CREATE TABLE `business_config`
(
    `id`         int(11)     NOT NULL AUTO_INCREMENT,
    `name`       varchar(20) NOT NULL DEFAULT '' COMMENT '配置名称',
    `domain`     varchar(50) NOT NULL DEFAULT '' COMMENT '项目',
    `content`    longtext COMMENT '配置内容',
    `updatetime` datetime    NOT NULL,
    PRIMARY KEY (`id`),
    KEY `updatetime` (`updatetime`),
    KEY `name_domain` (`name`, `domain`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8;

CREATE TABLE `metric_screen`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `name`          varchar(50) NOT NULL COMMENT '配置名称',
    `graph_name`    varchar(50) NOT NULL DEFAULT '' COMMENT 'Graph名称',
    `view`          varchar(50) NOT NULL DEFAULT '' COMMENT '视角',
    `endPoints`     longtext    NOT NULL,
    `measurements`  longtext    NOT NULL COMMENT '配置的指标',
    `content`       longtext    NOT NULL COMMENT '配置的具体内容',
    `creation_date` datetime    NOT NULL COMMENT '配置创建时间',
    `updatetime`    datetime    NOT NULL COMMENT '配置修改时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `name_graph` (`name`, `graph_name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='系统监控的screen配置';

CREATE TABLE `metric_graph`
(
    `id`            int(11)     NOT NULL AUTO_INCREMENT,
    `graph_id`      int(11)     NOT NULL COMMENT '大盘ID',
    `name`          varchar(50) NOT NULL COMMENT '配置ID',
    `content`       longtext COMMENT '配置的具体内容',
    `creation_date` datetime    NOT NULL COMMENT '配置创建时间',
    `updatetime`    datetime    NOT NULL COMMENT '配置修改时间',
    PRIMARY KEY (`id`),
    UNIQUE `name` (`name`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='系统监控的graph配置';

CREATE TABLE `server_alarm_rule`
(
    `id`            int(11)      NOT NULL AUTO_INCREMENT,
    `category`      varchar(50)  NOT NULL COMMENT '监控分类',
    `endPoint`      varchar(200) NOT NULL COMMENT '监控对象ID',
    `measurement`   varchar(200) NOT NULL COMMENT '监控指标',
    `tags`          varchar(200) NOT NULL DEFAULT '' COMMENT '监控指标标签',
    `content`       longtext     NOT NULL COMMENT '配置的具体内容',
    `type`          varchar(20)  NOT NULL DEFAULT '' COMMENT '数据聚合方式',
    `creator`       varchar(100)          DEFAULT '' COMMENT '创建人',
    `creation_date` datetime     NOT NULL COMMENT '配置创建时间',
    `updatetime`    datetime     NOT NULL COMMENT '配置修改时间',
    PRIMARY KEY (`id`),
    KEY `updatetime` (`updatetime`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8 COMMENT ='系统告警的配置';

3 Tomcat部署

下载tomcat

### 下载
wget https://mirror-hk.koddos.net/apache/tomcat/tomcat-8/v8.5.61/bin/apache-tomcat-8.5.61.tar.gz
###
tar -zxvf apache-tomcat-8.5.61.tar.gz -C /usr/local/server

修改tomcat配置文件

vi /usr/local/server/apache-tomcat-8.5.61/conf/server.xml
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="utf-8"
               redirectPort="8443" />

下载cat并解压到tomcat的webapps目录里面,注意文件需要重命名为cat.war

###
wget http://unidal.org/nexus/service/local/repositories/releases/content/com/dianping/cat/cat-home/3.0.0/cat-home-3.0.0.war
###
mv cat-home-3.0.0.war /usr/local/server/apache-tomcat-8.5.61/webapps/cat.war

创建setenv.sh

###
vi /usr/local/server/apache-tomcat-8.5.61/bin/setenv.sh
export CAT_HOME=/data/appdatas/cat/
CATALINA_OPTS="$CATALINA_OPTS -server -DCAT_HOME=$CAT_HOME -Djava.awt.headless=true -Xms1G -Xmx1G -XX:PermSize=256m -XX:MaxPermSize=256m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:SurvivorRatio=10 -XX:+UseParNewGC -XX:ParallelGCThreads=4 -XX:MaxTenuringThreshold=13 -XX:+UseConcMarkSweepGC -XX:+DisableExplicitGC -XX:+UseCMSInitiatingOccupancyOnly -XX:+ScavengeBeforeFullGC -XX:+UseCMSCompactAtFullCollection -XX:+CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=9 -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSClassUnloadingEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:-ReduceInitialCardMarks -XX:+CMSPermGenSweepingEnabled -XX:CMSInitiatingPermOccupancyFraction=70 -XX:+ExplicitGCInvokesConcurrent -Djava.nio.channels.spi.SelectorProvider=sun.nio.ch.EPollSelectorProvider -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationConcurrentTime -XX:+PrintHeapAtGC -Xloggc:/data/applogs/heap_trace.txt -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/data/applogs/HeapDumpOnOutOfMemoryError -Djava.util.Arrays.useLegacyMergeSort=true"

修改文件权限

mkdir /data
chmod -R 777 /data/

创建/data/appdatas/cat/client.xml

mkdir -p /data/appdatas/cat/ && vi /data/appdatas/cat/client.xml
<?xml version="1.0" encoding="utf-8"?>
<config mode="client">
    <servers>
        <server ip="10.4.42.36" port="2280" http-port="8080"/>
    </servers>
</config>

创建/data/appdatas/cat/server.xml(可以不配,后面有空在研究)

mkdir -p /data/appdatas/cat/ && vi /data/appdatas/cat/server.xml
<?xml version="1.0" encoding="utf-8"?>
<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>10.4.42.36:8080</remote-servers>		
	</console>
</config>

创建/data/appdatas/cat/datasources.xml

vi /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://10.4.42.36:33060/cat]]></url>
			<user>root</user>
			<password>123456</password>
			<connectionProperties><![CDATA[useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&socketTimeout=120000]]></connectionProperties>
		</properties>
	</data-source>
</data-sources>

启动tomcat

cd /usr/local/server/apache-tomcat-8.5.61/bin/ && ./startup.sh

登录cat(admin:admin)修改配置

http://10.4.42.36:8080/cat/s/config?op=routerConfigUpdate

<?xml version="1.0" encoding="utf-8"?>
<router-config backup-server="10.4.42.36" backup-server-port="2280">
   <default-server id="10.4.42.36" 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="10.4.42.36"/>
   </server-group>
   <domain id="cat">
      <group id="default">
         <server id="10.4.42.36" port="2280" weight="1.0"/>
      </group>
   </domain>
</router-config>

http://10.4.42.36:8080/cat/s/config?op=serverConfigUpdate

<?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="10.4.42.36: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://127.0.0.1/" base-dir="/user/cat/dump"/>
         <harfs id="dump" max-size="128M" server-uri="har://127.0.0.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-config>

重启Tomcat

cd /usr/local/server/apache-tomcat-8.5.61/bin/

4 查看日志

!!! 有问题先看日志

cd /data/appdatas/cat/
tail -f cat_yyyyMMdd.log

5 客户端部署

https://gitee.com/yuanyu1997/doc3/tree/master/Cat/code

项目的根目录放置 /data/appdatas/cat/client.xml(例如代码放在Windows桌面:C:\data\appdatas\cat\client.xml

<?xml version="1.0" encoding="utf-8"?>
<config mode="client">
    <servers>
        <server ip="10.4.42.36" port="2280" http-port="8080"/>
    </servers>
</config>


6 问题总结

1、服务器系统时间不对

### 查询系统时间
date
### 更改系统时间
yum install -y ntpdate
sudo ntpdate cn.pool.ntp.org

 

 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:白松林 返回首页