Local deployment of distributed monitoring CAT server

Posted by lillyapps on Wed, 09 Feb 2022 12:49:45 +0100

1, Introduction to CAT

CAT (Central Application Tracking) is an open source distributed real-time monitoring system developed by meituan review based on Java. Meituan comment infrastructure department hopes to provide industry-leading and unified solutions in the fields of basic storage, high-performance communication, large-scale online access, service governance, real-time monitoring, containerization and cluster intelligent scheduling. CAT's current product positioning in meituan comment is the unified monitoring component of the application layer, It is widely used in the framework of Middleware (RPC, database, cache, MQ, etc.) to provide system performance indicators, health status, real-time alarm and other services for each business line.

2, Deployment environment

  • Windows 7
  • CAT 3.0
  • Java 8
  • Tomcat 8.5
  • Maven 3
  • MySQL 5.7
  • Intranet IP: 192.168.1.111

3, Start deployment

1. Download CAT source code

git clone https://github.com/dianping/cat.git

2. Initialize the database

Create a cat database in MySQL, and then execute script / cat SQL statements in SQL.

3. Create a profile

Create the / data / appdata / cat folder in the disk where Tomcat is located, and then create / data / appdata / cat / client XML file, write the following contents:

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

Among them, 192.168.1.111 is changed to the intranet IP of your computer, 2280 is the default port of CAT server to accept data, and modification is not allowed. HTTP port is the port started by Tomcat, and the default is 8080. It is recommended to use the default port.

Then create / data / appdata / cat / datasources XML file, write the following contents:

<?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.111:3306/cat]]></url>  <!--  Please replace with the real database URL and port -- >
            <user>root</user>  <!-- Please replace with the real database user name  -->
            <password>root</password>  <!-- Please replace with the real database password  -->
            <connectionProperties><![CDATA[useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&socketTimeout=120000]]></connectionProperties>
        </properties>
    </data-source>
</data-sources>

Among them, the database IP, port, user name and password need to be replaced.

4. war deployment of cat

Build AT's war using Maven:

mvn clean install -DskipTests

After successful construction, cat home / target / cat-alpha-3.0.0 Rename war to cat War, copy it to Tomcat's webapps and start Tomcat.

5. Modify routing configuration

visit http://192.168.1.111:8080/cat/s/config?op=routerConfigUpdate , default user name: admin, default password: admin, modify client routing configuration:

<?xml version="1.0" encoding="utf-8"?>
<router-config backup-server="192.168.1.111" backup-server-port="2280">
   <default-server id="192.168.1.111" weight="1.0" port="2280" enable="true"/>
   <network-policy id="default" title="default" block="false" server-group="default_group">
   </network-policy>
   <server-group id="default_group" title="default-group">
      <group-server id="192.168.1.111"/>
   </server-group>
   <domain id="cat">
      <group id="default">
         <server id="192.168.1.111" port="2280" weight="1.0"/>
      </group>
   </domain>
</router-config>

Configuration Description:

  • Backup server attribute: set to the external IP address of the current server, and the port is fixed to 2280
  • Default server attribute: defines the route addresses that can be jumped, and multiple can be set. The id attribute of default server configures the routable cat home service IP address, and the port is fixed to 2280; If you need to disable the routing address, set enable to false
  • Multiple different network segments can be configured on the network policy side, which means that this network segment uses the cat node of the server group. Its main function is to divide the cat into multiple sub clusters when deploying cat in multiple machine rooms, and then multiple sub clusters handle different clients to avoid cross leased line access
  • domain id=cat this part is mainly about customized routing. When you find that some items have a large amount of data or other scenarios, you can isolate the monitoring requests of these domains separately

6. Modify the server configuration

visit http://192.168.1.111:8080/cat/s/config?op=serverConfigUpdate , modify the server configuration:

<?xml version="1.0" encoding="utf-8"?>
<server-config>
   <server id="default">
      <properties>
         <property name="local-mode" value="false"/>
         <property name="job-machine" value="true"/>
         <property name="send-machine" value="false"/>
         <property name="alarm-machine" value="true"/>
         <property name="hdfs-enabled" value="false"/>
         <property name="remote-servers" value="192.168.1.111: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 id="192.168.1.111">
      <properties>
         <property name="job-machine" value="true"/>
         <property name="send-machine" value="false"/>
         <property name="alarm-machine" value="true"/>
      </properties>
   </server>
</server-config>

Configuration Description:
Server node: represents the configuration of a machine. If the id is default, it represents the default configuration; If the id is ip, it represents the configuration of the server

  • Local mode: defines whether the service is in local mode (development mode). In the production environment, set it to false and start the remote listening mode. The default is false;
  • HDFS machine: defines whether to enable HDFS storage mode. The default value is false;
  • Job machine: defines whether the current service is a report machine (only one service machine is required to start the task of generating summary reports and statistical reports). The default is false;
  • Alarm machine: defines whether the current service is an alarm machine (only one service machine is required to enable all kinds of alarm monitoring). The default is false;
  • Send machine: defines whether the current service alarm is sent (at that time, in order to solve the problem that the alarm thread is started in the test environment, but the alarm is not notified in the end, this configuration will be gradually removed later. It is recommended that when the alarm machine is turned on to true, this synchronization is true)

Storage node: defines data storage configuration information

  • Local report storage time: defines the storage time of local reports, in days
  • Local logivew storage time: defines the storage time of local logs, in days
  • Local base dir: defines the local data storage directory
  • HDFS: define HDFS configuration information to facilitate direct login to the system
  • Server URI: defines the HDFS service address
  • Console: defines the service console information
  • Remote servers: defines the HTTP service list (this value is taken when the remote listener updates the server information synchronously)
  • LDAP: define LDAP configuration information (this can be ignored)
  • ldapUrl: defines the LDAP service address (this can be ignored)

Restart Tomcat.

4, Verify

visit http://192.168.1.111:8080/cat/r , click "State" to see "CAT server normal" and some basic CAT states, as shown below:

Click "Transaction" to the monitoring information of CAT itself, as shown in the following figure:

Topics: Java