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 sub-library sub-table-- actual combat 03muri-global table

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

Share

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

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.

1. Configure schema.xml

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

2. Configure server.xml

Mysql mycatdb

Third, 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

4. Start mycat

/ usr/local/mycat/bin/mycat start

View mycat Log

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

Log in to MySQL to view the global table

Mysql-uroot-pmysql-P8066-h292.168.8.30mysql > use mycatdbReading 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 | +-+ | user01 | | user02 | +-+ 2 rows in set (sec) mysql > drop table user02;ERROR 1105 (HY000): Unknown table 'testdb11.user02'mysql > select * from user02 ERROR 1146 (HY000): Table 'testdb01.user02' doesn't existmysql > drop table if exists user02;Query OK, 0 rows affected, 1 warning (0.40 sec

Create a table user02 and insert three records

Mysql > create table user02 (- > id INT (10) NOT NULL AUTO_INCREMENT,-> name varchar (30),-> PRIMARY KEY (id)->); Query OK, 0 rows affected (1.74 sec) mysql > insert into user02 (name) values ('steven'); Query OK, 1 row affected (0.29 sec) mysql > insert into user02 (name) values (' steven'); Query OK, 1 row affected (0.33 sec) mysql > insert into user02 (name) values ('steven') Query OK, 1 row affected (0.31 sec)

VI. Data verification

Node1

Mysql > select * from testdb01.user02;+----+-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+ 3 rows in set (0.00 sec) mysql > select * from testdb05.user02 +-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+-- + 3 rows in set (0.01sec) mysql > select * from testdb12.user02 +-+-- +-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+-+ 3 rows in set (0.00 sec)

Node2

Mysql > select * from testdb16.user02;+----+-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+ 3 rows in set (0.00 sec) mysql > select * from testdb19.user02 +-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+ 3 rows in set (0.00 sec) mysql > select * from testdb22.user02 +-+-- +-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+-+ 3 rows in set (0.00 sec)

Node3

Mysql > select * from testdb25.user02;+----+-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+ 3 rows in set (0.00 sec) mysql > select * from testdb30.user02 +-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+ 3 rows in set (0.00 sec) mysql > select * from testdb33.user02 +-+-+ | id | name | +-+-+ | 1 | steven | | 2 | steven | | 3 | steven | +-+-+

You can see that the data stored in each node is exactly the same for each database, and the global table is validated.

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