Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MyCAT Source Code Analysis of Database Middleware-- Construction of debugging Environment

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Follow the official account of * * Wechat: [the back-end cabin of Taro] * * has benefits:

RocketMQ / MyCAT / Sharding-JDBC list of all source code analysis articles

RocketMQ / MyCAT / Sharding-JDBC Chinese comment source code GitHub address

Every message you have questions about the source code will be answered seriously. You can ask for advice if you don't even know how to read the source code.

New source code parsing articles are notified in real time. Update about one article a week.

1. Dependent tool

two。 Source code pull

3. Database configuration

4. MyCat configuration

5. MyCAT startup

6. MyCAT test

7. Communication

1. Dependent tool

Maven

Git

JDK

MySQL

IntelliJ IDEA

two。 Source code pull

From the official warehouse https://github.com/MyCATApache/Mycat-Server Fork out of their own warehouse. Why Fork? Now that we have started to read and debug the source code, we may write some comments and have our own warehouse and be free to submit.

Use IntelliJ IDEA to pull the code from the warehouse out of Fork. After pulling, Maven will download the dependency package, which may take some time and wait patiently.

3. Database configuration

What we want to build is a debugging environment for non-sharded tables, and we need to create a database and tables:

Create the database: db01.

Create a database table: travelrecord.

CREATE TABLE `travelrecord` (`id` bigint (20) NOT NULL AUTO_INCREMENT, `name` varchar (255) CHARACTER SET latin1 DEFAULT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin

4. MyCAT configuration

In order to avoid having an impact on the implementation source code, we chose to make changes to the test directory.

1. Create a new folder backups under the resources directory, and move all the files under the original resources to backups, so that our environment is clean.

2. Create a new schema.xml file under the resources directory, and configure the logical library, table, data node and data source of MyCAT.

Select user ()

3. Create a new server.xml file in the resources directory to configure the MyCAT system configuration.

0 10 0 2 0 0 164k 1k 0 384m false 123456 dbtest

5. MyCAT startup

1. Create a new debugger package under the java directory and distinguish it from the existing package.

2. Create a new MycatStartupTest.java under the debbuger package:

Package debugger;import io.mycat.MycatStartup;/*** {@ link io.mycat.MycatStartup} Test * * Created by yunai on 2017/5/22.*/public class MycatStartupTest {public static void main (String [] args) {MycatStartup.main (args);}}

3. Run MycatStartupTest.java, when you see the output log MyCAT Server startup successfully. See logs in logs/mycat.log means that the startup is successful.

So far, the test directory is as follows:

6. MyCAT test

The debugging environment has been set up, let's see if it is correct.

Use the MySQL client to connect to MyCAT:

HOST: 127.0.0.1

PORT: 8066

USERNAME: root

PASSWORD: 123456

Mysql > insert into travelrecord (name) values (''); Query OK, 1 rows affected (0.01 sec) mysql > select * from travelrecord +-+-+ | id | name | +-+-+ | 866707181398003712 | | +-+-+ 1 rows in set (0.05 sec)

Success.

7. Communication

Thank you for reading, collecting and paying attention.

I know it, but I know why. Learning MyCAT will be a pleasant journey. If there is your communication, I believe it will be more pleasant. Welcome to add Wechat: wangwenbin-server for discussion.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report