Cat installation and use (Meituan open source monitoring)

1. Cat source code download and packaging

1. Download the source code of cat and the dependent packages required by cat on the mirror website

Download address: https://hub.fastgit.org/dianping/cat

cat source code: download master branch code;

cat dependency package: download mvn-repo branch code;

 

You can also download cat source code and dependency packages in my own gitee code repository;

cat source code:

cat dependency package:

 

2. Cat the war package locally

1) First, rename the downloaded cat source project to cat;

 

2) Read the instructions in the manual, and look at the README.md file in the root directory of the cat project

README.md description:

  • 1. The cat-client module in the root directory will no longer be maintained, and will be removed in the next major version update. New Java client reference: lib/java; --Operation: Delete the cat-client module in pom.xml in the cat root directory (delete <module>cat-client</module>)
  • 2. The management end, server end, and alarm service can all be deployed using the cat-home module
  • 3. Other modules:
    • - integration: content integrated by cat and some third-party tools (part of this part is contributed by the community, part of which is officially contributed)
      - lib: client of CAT, including Java, C/C++, Python, Node.js, Go
      - script: CAT database script

 

3) Execute the compilation command in the cat project 

Compile command:

mvn clean compile

 

报错1:Could not find artifact org.unidal.framework:foundation-service:jar:2.5.0

[ERROR] Failed to execute goal on project cat-core: Could not resolve dependencies for project com.dianping.cat:cat-core:jar:3.0.0: The following artifacts could not be resolved: org.unidal.framework:foundation-ser
vice:jar:2.5.0, org.unidal.framework:web-framework:jar:2.4.0, org.unidal.framework:dal-jdbc:jar:2.4.0: Could not find artifact org.unidal.framework:foundation-service:jar:2.5.0 in alimaven (http://maven.aliyun.com/
nexus/content/groups/public) -> [Help 1]

Solution: Unzip the downloaded mvn-repo branch and put it into the local .m2 warehouse;

Decompress the local mvn-repo branch and extract the org directory;

Copy the org directory to the local .m2 warehouse;

 

Then execute the compile command:

报错2:Failure to find org.codehaus.plexus:plexus-container-default:jar:3.1.0

[ERROR] Failed to execute goal org.unidal.maven.plugins:codegen-maven-plugin:2.5.8:dal-model (generate data model) on project cat-core: Execution generate data model of goal org.unidal.maven.plugins:codegen-maven-p
lugin:2.5.8:dal-model failed: Plugin org.unidal.maven.plugins:codegen-maven-plugin:2.5.8 or one of its dependencies could not be resolved: Failure to find org.codehaus.plexus:plexus-container-default:jar:3.1.0 in h
ttp://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of alimaven has elapsed or updates are forced -> [Help 1]

Solution: Find the org.unidal.maven.plugins:codegen-maven-plugin:2.5.8 version of the pom file codegen-maven-plugin-2.5.8.pom in the .m2 warehouse, open it with idea, click the default of the parent reference, and jump Go to the default-2.5.8.pom file and modify the foundation-service.version in the file from version 3.1.0 to version 4.0.0;

<parent>
      <groupId>org.unidal.maven.plugins</groupId>
      <artifactId>default</artifactId>
      <version>2.5.8</version>
</parent>

 <foundation-service.version>4.0.0</foundation-service.version>

 

Execute the compile command again: here is the problem that the JDK11 version will encounter

Error 3: The package sun.misc cannot find the symbol class BASE64Encoder

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project cat-consumer: Compilation failure: Compilation failure:
[ERROR] /D:/Nikey/Project/Repository/gitee/cat/cat/cat-consumer/src/main/java/com/dianping/cat/consumer/util/InvidStringBuilder.java:[21,16] 找不到符号
[ERROR] 符号:   类 BASE64Encoder
[ERROR] 位置: 程序包 sun.misc

Solution: Find the class InvidStringBuilder.java,

  • Replace import sun.misc.BASE64Encoder; with import org.apache.commons.codec.binary.Base64;
  • Replace the return statement with return "Base64." + Base64.encodeBase64(key.getBytes());
//import sun.misc.BASE64Encoder;
import org.apache.commons.codec.binary.Base64;
//			return "Base64." + new BASE64Encoder().encodeBuffer(key.getBytes()).trim();
			return "Base64." + Base64.encodeBase64(key.getBytes());

 

Execute the compilation command again: the compilation is successful

 

4) Execute the install command in the cat root directory

Execute the install command:

mvn clean install -DskipTests

报错:Could not find artifact org.unidal.framework:test-framework:jar:2.4.0

[ERROR] Failed to execute goal on project cat-core: Could not resolve dependencies for project com.dianping.cat:cat-core:jar:3.0.0: Could not find artifact org.unidal.framework:test-framework:jar:2.4.0 in alimaven
(http://maven.aliyun.com/nexus/content/groups/public) -> [Help 1]

Solution: Modify the version of test-framework in the pom.xml file in the cat root directory to 2.5.0

 

Then execute the install command:

After the install is successful, get the war package in the following path, and change cat-home-3.0.0.war to cat.war

Installing D:\Nikey\Project\Repository\gitee\cat\cat\cat-home\target\cat-alpha-3.0.0.war to C:\Users\nikey.lee\.m2\repository\com\dianping\cat\cat-home\3.0.0\cat-home-3.0.0.war
 

5) View the specific effective pom information of each module

Execute the command in the cat root directory: open cat.txt, you can see the version defined by cat-home

mvn help:effective-pom > cat.txt

 

2. Server installation and configuration

1. Prepare the environment

  • tomcat:apache-tomcat-8.5.68
  • mysql:mysql5.7.22
  • jdk1.8
  • The war package created by meituan cat source code: cat.war

 

2. Install the CAT database

1) Use the MySQL Workbench tool to connect to the local mysql database

2) Create a database, the database name is cat, and the database code uses utf8mb4, otherwise it may cause problems such as Chinese garbled characters;

CREATE SCHEMA `cat` DEFAULT CHARACTER SET utf8mb4 ;

3) Copy the sql in the script directory in the cat project to the cat database and run

script directory: CatApplication.sql

Copy the sql to the cat database to run, and initialize the data table;

 

Since the default configuration of the MySQL system parameter max_allowed_packet is small, it may limit the size of the data packet accepted by the server. Sometimes large inserts and updates will be limited by the max_allowed_packet parameter, resulting in failure. Therefore, you need to modify the value of max_allowed_packet. After the modification, you need to restart mysql ;

Modify the configuration file in the mysql installation directory (if not, create one yourself): C:\Program Files\MySQL\MySQL Server 5.7\my.ini

[mysqld]
port=3306
max_allowed_packet=1000M

[client]
port=3306

restart mysql:

net stop mysql
net start mysql

Use the MySQL Workbench tool to connect to the local mysql database and execute the command:

show VARIABLES like '%max_allowed_packet%';

 

3. Cat configuration file

In the disk directory where tomcat is installed, create the following two directories, and grant read and write permissions; my tomcat is installed on the D drive, so create the following two directories on the D drive:

  • D:\data\appdatas\cat
  • D:\data\applogs\cat

In the D:\data\appdatas\cat directory, add client.xml, datasources.xml, server.xml configuration files

client.xml configuration file

<?xml version="1.0" encoding="utf-8"?>
<config mode="client">
    <servers>
          <!-- 服务端地址, 端口固定-->
		  <!-- 如果有多个Server, 就继续增加相应的节点配置 -->
		  <!-- 这是告诉客户端应该去链接哪个服务端,从哪个服务端里获取配置信息 ,相关源码也在 DefaultClientConfigManager中 -->
		 <server ip="127.0.0.1" port="2280" http-port="8080" />
    </servers>
</config>

datasources.xml configuration file

<?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://127.0.0.1:3306/cat]]></url>  <!-- 请替换为真实数据库URL及Port  -->
            <user>root</user>  <!-- 请替换为真实数据库用户名  -->
            <password>root</password>  <!-- 请替换为真实数据库密码  -->
            <connectionProperties><![CDATA[useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&socketTimeout=120000]]></connectionProperties>
        </properties>
    </data-source>
</data-sources>

 

4. Tomcat starts the cat project

Copy cat.war to the webapps directory of tomcat, and then start tomcat;

Run the command to start tomcat: D:\Tool\apache-tomcat-8.5.68\bin\startup.bat

If mysql version 8.0 is used, after starting tomcat, an error will be reported: [ChannelManager] Error when try connecting to /127.0.0.1:2280, solution: install mysql version 5.7 and there will be no problem;

After successful startup, visit: http://127.0.0.1:8080/cat/r

 

5. Modify the server configuration and client routing according to actual needs

Login with admin/admin

 

Enter the [Server Configuration] page to modify the IP address

Link address: http://127.0.0.1:8080/cat/s/config?op=serverConfigUpdate

 

Enter the [Client Routing] page to modify the IP address

Link address: http://127.0.0.1:8080/cat/s/config?op=routerConfigUpdate

 

3. Client integration case

Write a case of springboot and cat integration

1. Install cat-client to the local warehouse through source code

Source path of cat-client: D:\cat\lib\java

After entering the source path, execute the command: mvn clean install -DskipTests

After the installation is successful, the cat-client-3.0.0.jar package exists in the local warehouse;

Local repository C:\Users\nikey.lee\.m2\repository\com\dianping\cat\cat-client\3.0.0\cat-client-3.0.0.jar

 

If an error is reported: target option 1.5 is no longer supported. Please use version 1.6 or later.

Solution: Modify the pom file, add the compiled version number in the property label, and then execute the install command to install successfully;

pom file path: D:\cat\lib\java\pom.xml

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/nikeylee/article/details/117712209