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

A brief Analysis of MySQL Open Source cetus

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

Share

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

The following content mainly brings you a brief analysis of MySQL open source cetus, the knowledge here is slightly different from books, are summed up by professional and technical personnel in the process of contact with users, have a certain experience sharing value, hope to bring help to the majority of readers.

Cetus

Brief introduction

Cetus is the middleware of relational database MySQL developed by C language, which mainly provides a comprehensive database access agent function. The Cetus connection mode is basically compatible with MySQL, and the application can access the database through Cetus almost without modification, which realizes the horizontal expansion and high availability of the database layer.

Main functional features

Cetus is divided into two versions: read-write separation and sub-library (sub-table is a special form of sub-library).

For read-write separate versions:

Multi-process lock-free to improve operational efficiency support transparent back-end connection pool support SQL read-write separation enhanced SQL route parsing and injection support prepare statement support result set compression support security management support status monitoring support tcp stream streaming support domain name connection back-end SSL/TLS support (client) MGR support read strong consistency support (to be implemented)

For the sub-library version: multi-process lock-free to improve running efficiency support transparent back-end connection pool support SQL read-write separation support data sub-library support distributed transaction processing support insert batch operation support conditional distinct operation enhanced SQL route parsing and injection support result set compression with superior result set merging algorithm support security management support state monitoring support tcp stream streaming support domain name Connection backend SSL/TLS support (client) MGR support read strong consistency support (to be implemented)

= = Environmental preparation

Architecture:

Master: 192.168.1.222 from: 192.168.1.223 cetus:192.168.1.221

Database authorizes CREATE database if not exists testdb;create user 'cetus_app'@'192.168.1.221' identified by' cetus@123';GRANT all ON testdb.* TO 'cetus_app'@'192.168.1.221' to cetus users

Master-slave delay detection preparation

Create a heartbeat library and heartbeat table and authorize the user

For example:

The host ip where Cetus is located is 192.168.1.221

Create database if not exists proxy_heart_beat; use proxy_heart_beat;CREATE TABLE if not exists tb_heartbeat (p_id varchar 128NOT NULL, p_ts timestamp (3) NOT NULL DEFAULT CURRENT_TIMESTAMP (3), PRIMARY KEY (p_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;GRANT ALL ON proxy_heart_beat.* TO 'cetus_app'@'192.168.1.221'

Note: when creating a heartbeat table, the p_ts precision must be after the decimal point, otherwise the accuracy of master-slave delay detection will be affected.

(cetus will start an additional persistent connection main library and always execute a similar statement: INSERT INTO proxy_heart_beat.tb_heartbeat (p_id, p_ts) VALUES ('/ home/user/cetus_install/conf_2033375456_2567636547', '2019-02-27 17p_id 03p_id 37.106285') ON DUPLICATE KEY UPDATE p_ts='2019-02-27 17p_id 03virtual 37.106285'

At the same time, start a persistent connection from the library and execute similar statements all the time:

Select p_ts from proxy_heart_beat.tb_heartbeat where paired idwritten timestamps, read timestamps from the database, make a difference with the local time, and calculate the master-slave delay)

= = install cetus

Environmental dependence

Yum install cmake gcc glib2-devel flex mysql-devel gperftools-libs zlib-devel-y cd / usr/local/ & & git clone https://github.com/Lede-Inc/cetus.gitcd / usr/local/cetus/mkdir build/cd build/

Compile

Read-write separate version:

CFLAGS='-g-Wpointer-to-int-cast' cmake.. /-DCMAKE_BUILD_TYPE=Debug-DCMAKE_INSTALL_PREFIX=/home/user/cetus_install-DSIMPLE_PARSER=ON

Sub-library version:

CFLAGS='-g-Wpointer-to-int-cast' cmake.. /-DCMAKE_BUILD_TYPE=Debug-DCMAKE_INSTALL_PREFIX=/home/user/cetus_install-DSIMPLE_PARSER=OFFmake installcd / home/user/cetus_install/conf/

The configuration file has sample files after make insatll, ending with .example, and the directory / home/user/cetus_install/conf/, includes user settings file (users.json), variable processing configuration file (variables.json), split library version of sharding rule configuration file (sharding.json), read-write separate version of startup configuration file (proxy.conf), and sub-library version of startup configuration file (shard.conf).

Edit the relevant configuration files according to the specific compiled and installed version. If you use the read-write separation feature, you need to configure users.json and proxy.conf, and if you use the sharding function, you need to configure users.json, sharding.json and shard.conf. The two versions of variables.json are optional.

Read-write separation:

Cp proxy.conf.example proxy.confcp users.json.example users.json

Users.json is used to configure user login information, using the structure of key-value pairs, where the key is fixed and the value is the login user name and password created by the user in MySQL.

Where the value of user is the user name, the value of client_pwd is the password of the front-end login Cetus, and the value of server_pwd is the password of the Cetus login backend.

Chmod 660 conf/* startup service: bin/cetus-- defaults-file=conf/proxy.conf

Client connects to the database: the password is client_pwd in users.json and the address port is proxy-address in proxy.conf

Mysql-ucetus_app-paired cetus.123'-P6001-h292.168.1.221

Cetus native login management port:

Mysql-h227.0.0.1-uadmin-padmin-P7001

For the above analysis of MySQL open source cetus, if you need to know more, you can continue to pay attention to the innovation of our industry. If you need professional answers, you can contact those before and after sale on the official website. I hope this article can bring you some knowledge updates.

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