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 read-write separation simple sub-library

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

First, environment configuration

Center7 jdk1.8 is used in the experiment (center7 comes with default jdk, no jdk needs to be installed)

192.168.0.19 (mycat)

192.168.0.14 (master Master)

192.168.0.13 (slave from)

1. Go to the official website to download mycat first.

Http://www.mycat.io/

two。 Extract the downloaded mycat file to / usr/local/

3. Configure the environment

Configure the master and slave of mysql, which is not explained here. Configure to create a library called K1, and then verify it from the library.

Second, configure the separation of read and write

1.vim / usr/local/mycat/conf/server.xml # # configure the account and permissions of mycat

123456

K1

# means to create a root account with a password of 123456 and grant full permissions to K1 (the logical library of mycat)

2.vim / usr/local/mycat/conf/schema.xml # # configure the logical library of mycat

Show slave status

3. Start mycat and test

/ usr/local/mycat/bin/mycat start

three。 Sharding database (based on table score)

1. Add a database 192.168.0.16

Create K1 library and b2 table in the database, and modify the configuration as follows

Select user () select user () select user ()

Structure diagram

According to the above configuration, the user requests to arrive at mycat,mycat. If it is a fenpian1 shard group, it will be forwarded to the real server group for shitizu1 processing, read to slave processing, and write to master processing. If it is a fenpian2 sharding group, it will be forwarded to the real server group shitizu2 for processing, and both reads and writes will be handed over to 192.168.0.16 for processing.

In this way, when the front end queries the logic library K1, it can obtain the complete data of b1 and b2 tables, but in fact, only one table is stored in each real database group, and the complete data is organized by two real server groups at the back end of mycat.

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: 266

*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

Servers

Wechat

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

12
Report