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

How to divide the database and table of MyCat

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how to divide the database and table in MyCat". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Project environment:

192.168.8.30 mycat

192.168.8.31 node1

192.168.8.32 node2

192.168.8.33 node3

The MySQL of three nodes is a single instance.

First, create a test library

Node1

Create database testdb01;create database testdb02;create database testdb03

Node2

Create database testdb13;create database testdb14;create database testdb15

Node3

Create database testdb25;create database testdb26;create database testdb27

2. Configure schema.xml

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

3. Configure rule.xml

Id autopartition-long-user03 autopartition-long-user03.txt 0

4. Configure autopartition-long-user03.txt

1-10: 011-20: 121-30: 231-40: 41-50: 451-60: 561-70: 671-80: 781-10000: 8

5. Configure server.xml

Mysql mycatdb

6. Start mycat

/ usr/local/mycat/bin/mycat start

View mycat Log

STATUS | wrapper | 15:27:14 on 2018-11-22 |-- > Wrapper Started as DaemonSTATUS | wrapper | 15:27:14 on 2018-11-22 | Launching a JVM...INFO | jvm 1 | 15:27:14 on 2018-11-22 | OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=64M Support was removed in 8.0INFO | jvm 1 | 15:27:16 on 2018-11-22 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.orgINFO | jvm 1 | 15:27:16 on 2018-11-22 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.INFO | jvm 1 | 15:27:16 on 2018-11-22 | INFO | jvm 1 | 15:27:20 on 2018-11-22 | MyCAT Server startup successfully. See logs in logs/mycat.log

Log in to MySQL and view the logic table

Mysql > use mycatdb;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with-ADatabase changedmysql > show tables +-+ | Tables in mycatdb | +-+ | order01 | | orderdetail01 | | user01 | | user02 | | user03 | +-+ 5 rows in set (0.00 sec) mysql > drop table if exists user03 Query OK, 0 rows affected, 1 warning (0.23 sec) mysql > create table user03 (- > id int not null auto_increment,-> name varchar (64),-> primary key (id)->); Query OK, 0 rows affected (0.43 sec)

Insert test data

Insert a total of 50 pieces of data

Insert into user03 (id,name) values (1); insert into user03 (id,name) values (2); insert into user03 (id,name) values (3); insert into user03 (id,name) values (4); insert into user03 (id,name) values (5); insert into user03 (id,name) values (11); insert into user03 (id,name) values (12) Insert into user03 (id,name) values (13 lemons steven`); insert into user03 (id,name) values (14 recordssteven`); insert into user03 (id,name) values (15); insert into user03 (id,name) values (21); insert into user03 (id,name) values (22); insert into user03 (id,name) values (23); insert into user03 (id,name) values (24) Insert into user03 (id,name) values; insert into user03 (id,name) values (31); insert into user03 (id,name) values (32); insert into user03 (id,name) values (3); insert into user03 (id,name) values (34); insert into user03 (id,name) values (35); insert into user03 (id,name) values (41) Insert into user03 (id,name) values (42 memorials); insert into user03 (id,name) values (43); insert into user03 (id,name) values (44); insert into user03 (id,name) values (45); insert into user03 (id,name) values (51); insert into user03 (id,name) values (52); insert into user03 (id,name) values (53) Insert into user03 (id,name) values (54 memorials steven`); insert into user03 (id,name) values (55 recordssteven`); insert into user03 (id,name) values (61 recordssteven`); insert into user03 (id,name) values (62pime steven`s); insert into user03 (id,name) values (63lementists steven`); insert into user03 (id,name) values (64meme steven`); insert into user03 (id,name) values (65lemensteven`) Insert into user03 (id,name) values (71 memorials steven`); insert into user03 (id,name) values (72 recordings steven`); insert into user03 (id,name) values (73 recordings steven`); insert into user03 (id,name) values (74 recordings steven`); insert into user03 (id,name) values (75 recordssteven`); insert into user03 (id,name) values (81 memorials steven`); insert into user03 (id,name) values (82 minions steven`) Insert into user03 (id,name) values (83 memorials steven`); insert into user03 (id,name) values (84 memorials steven`); insert into user03 (id,name) values (85 recordings steven`); insert into user03 (id,name) values (91 recollection steven`); insert into user03 (id,name) values (92 memorials steven'); insert into user03 (id,name) values (93 memorials steven'); insert into user03 (id,name) values (94 minions steven`) Insert into user03 (id,name) values (95m)

IX. Data verification

The three node are only in testdb01-03MagneTestDB 13-15 testdb25-27, so except for these nine physical libraries, there are no fragments found in other libraries.

The following validates the sharding information in the three node:

Node1

Mysql > select count (*) from testdb01.user03;+-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec) mysql > select count (*) from testdb02.user03 +-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec) mysql > select count (*) from testdb03.user03;+-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec)

Node2

Mysql > select count (*) from testdb13.user03;+-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec) mysql > select count (*) from testdb14.user03 +-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec) mysql > select count (*) from testdb15.user03;+-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec)

Node3

Mysql > select count (*) from testdb25.user03;+-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec) mysql > select count (*) from testdb26.user03 +-+ | count (*) | +-+ | 5 | +-+ 1 row in set (0.00 sec) mysql > select count (*) from testdb27.user03 +-+ | count (*) | +-+ | 10 | +-+ 1 row in set (0.00 sec) "how to divide the database and sub-table" is introduced here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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