真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

MyCat分庫(kù)分表中怎么實(shí)現(xiàn)ER分片

這篇文章主要介紹“MyCat分庫(kù)分表中怎么實(shí)現(xiàn)ER分片”,在日常操作中,相信很多人在MyCat分庫(kù)分表中怎么實(shí)現(xiàn)ER分片問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”MyCat分庫(kù)分表中怎么實(shí)現(xiàn)ER分片”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

成都創(chuàng)新互聯(lián)公司堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的陽(yáng)城網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

項(xiàng)目環(huán)境: 

192.168.8.30  mycat

192.168.8.31  node1

192.168.8.32  node2

192.168.8.33  node3

三個(gè)節(jié)點(diǎn)MySQL均為單實(shí)例

一、配置schema.xml




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

二、配置rule.xml

     
        
                
                        order_id
                        mod-long
                
        
       
        
                9
        
 

三、配置server.xml


		mysql
		mycatdb

四、創(chuàng)建測(cè)試庫(kù)

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;

五、啟動(dòng)mycat

/usr/local/mycat/bin/mycat start

查看mycat日志

STATUS | wrapper  | 2018/11/22 14:12:55 | --> Wrapper Started as Daemon
STATUS | wrapper  | 2018/11/22 14:12:55 | Launching a JVM...
INFO   | jvm 1    | 2018/11/22 14:12:55 | OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=64M; support was removed in 8.0
INFO   | jvm 1    | 2018/11/22 14:12:58 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org
INFO   | jvm 1    | 2018/11/22 14:12:58 |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
INFO   | jvm 1    | 2018/11/22 14:12:58 | 
INFO   | jvm 1    | 2018/11/22 14:13:04 | MyCAT Server startup successfully. see logs in logs/mycat.log

六、登錄MySQL,查看邏輯表

mysql -uroot -pmysql -P8066 -h292.168.8.30
mysql> show databases;
+----------+
| DATABASE |
+----------+
| mycatdb  |
+----------+
1 row in set (0.02 sec)
mysql> use mycatdb
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+-------------------+
| Tables in mycatdb |
+-------------------+
| order01           |
| orderdetail01     |
| user01            |
| user02            |
+-------------------+
4 rows in set (0.00 sec)
mysql> select * from order01;
ERROR 1105 (HY000): Table 'testdb03.order01' doesn't exist
mysql> 
mysql> drop table if exists order01;
Query OK, 0 rows affected, 1 warning (0.46 sec)
mysql> drop table if exists orderdetail01;
Query OK, 0 rows affected, 1 warning (0.16 sec)
mysql> CREATE TABLE order01(
    -> order_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
    -> number VARCHAR(64),
    -> createtime DATETIME);
Query OK, 0 rows affected (0.58 sec)
mysql> CREATE TABLE orderdetail01(
    -> orderdetail_id INT AUTO_INCREMENT PRIMARY KEY,
    -> order_id INT,
    -> order_status CHAR(1),
    -> addresss VARCHAR(128),
    -> createtime DATETIME,
    -> CONSTRAINT fk_iorder01 FOREIGN KEY (order_id) REFERENCES order01
    -> (order_id));
Query OK, 0 rows affected (0.63 sec)

七、插入測(cè)試數(shù)據(jù)

父表和子表各插入9條記錄

INSERT INTO order01(order_id,number,createtime) VALUES(1,'steven101',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (1,1,'1','steven101(ID=1,steven101)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(2,'steven201',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (2,2,'1','steven201(ID=2,steven201)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(3,'steven301',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (3,3,'1','steven301(ID=3,steven301)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(4,'steven401',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (4,4,'1','steven401(ID=4,steven401)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(5,'steven501',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (5,5,'1','steven501(ID=5,steven501)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(6,'steven601',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (6,6,'1','steven601(ID=6,steven601)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(7,'steven701',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (7,7,'1','steven701(ID=7,steven701)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(8,'steven801',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (8,8,'1','steven801(ID=8,steven801)',NOW());
INSERT INTO order01(order_id,number,createtime) VALUES(9,'steven901',NOW());
INSERT INTO orderdetail01(orderdetail_id,order_id,order_status,addresss,createtime) VALUES (9,9,'1','steven901(ID=9,steven901)',NOW());

八、驗(yàn)證數(shù)據(jù)

schema.xml中,order01和orderdetail01分片只配置了testdb01-03,testdb13-15,testdb25-27,所以除了這9個(gè)物理庫(kù)之外,其他庫(kù)查不到分片。

下面在三個(gè)node分別驗(yàn)證出分片信息:

node1

mysql> select * from testdb01.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        9 | steven901 | 2018-11-22 14:21:20 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb01.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              9 |        9 | 1            | steven901(ID=9,steven901) | 2018-11-22 14:21:23 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.01 sec)
mysql> select * from testdb02.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        1 | steven101 | 2018-11-22 14:21:18 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb02.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              1 |        1 | 1            | steven101(ID=1,steven101) | 2018-11-22 14:21:18 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.01 sec)
mysql> select * from testdb03.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        2 | steven201 | 2018-11-22 14:21:18 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb03.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              2 |        2 | 1            | steven201(ID=2,steven201) | 2018-11-22 14:21:18 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.00 sec)

node2

mysql> select * from testdb13.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        3 | steven301 | 2018-11-22 14:21:17 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb13.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              3 |        3 | 1            | steven301(ID=3,steven301) | 2018-11-22 14:21:17 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.01 sec)
mysql> select * from testdb14.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        4 | steven401 | 2018-11-22 14:21:17 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb14.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              4 |        4 | 1            | steven401(ID=4,steven401) | 2018-11-22 14:21:17 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb15.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        5 | steven501 | 2018-11-22 14:21:18 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb15.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              5 |        5 | 1            | steven501(ID=5,steven501) | 2018-11-22 14:21:18 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.00 sec)

node3

mysql> select * from testdb25.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        6 | steven601 | 2018-11-22 14:21:20 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb25.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              6 |        6 | 1            | steven601(ID=6,steven601) | 2018-11-22 14:21:20 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb26.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        7 | steven701 | 2018-11-22 14:21:20 |
+----------+-----------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb26.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              7 |        7 | 1            | steven701(ID=7,steven701) | 2018-11-22 14:21:20 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.00 sec)
mysql> select * from testdb27.order01;
+----------+-----------+---------------------+
| order_id | number    | createtime          |
+----------+-----------+---------------------+
|        8 | steven801 | 2018-11-22 14:21:20 |
+----------+-----------+---------------------+
1 row in set (0.01 sec)
mysql> select * from testdb27.orderdetail01;
+----------------+----------+--------------+---------------------------+---------------------+
| orderdetail_id | order_id | order_status | addresss                  | createtime          |
+----------------+----------+--------------+---------------------------+---------------------+
|              8 |        8 | 1            | steven801(ID=8,steven801) | 2018-11-22 14:21:20 |
+----------------+----------+--------------+---------------------------+---------------------+
1 row in set (0.00 sec)

到此,關(guān)于“MyCat分庫(kù)分表中怎么實(shí)現(xiàn)ER分片”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!


網(wǎng)頁(yè)標(biāo)題:MyCat分庫(kù)分表中怎么實(shí)現(xiàn)ER分片
鏈接URL:http://weahome.cn/article/pieijg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部