In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 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.
First, create test data
Node1
Create database testdb01;create database testdb02;create database testdb03;create database testdb04;create database testdb05;create database testdb06;create database testdb07;create database testdb08;create database testdb09;create database testdb10;create database testdb11;create database testdb12
Node2
Create database testdb13;create database testdb14;create database testdb15;create database testdb16;create database testdb17;create database testdb18;create database testdb19;create database testdb20;create database testdb21;create database testdb22;create database testdb23;create database testdb24
Node3
Create database testdb25;create database testdb26;create database testdb27;create database testdb28;create database testdb29;create database testdb30;create database testdb31;create database testdb32;create database testdb33;create database testdb34;create database testdb35
2. Configure schema.xml
Select user () select user () select user ()
3. Configure rule.xml
Province hash-int partition-hash-int-mycatdb-kk_user.txt 1 0
4. Configure partition-hash-int-mycatdb-kk_user.txt
Beijing = 0 Shanghai = 1 Yunnan = 2 Inner Mongolia = 3 Guizhou Province = 4 Taiwan Province = 6 Jilin Province = 7 Sichuan Province = 8 Tianjin = 9 Ningxia Province = 11 Shandong Province = 12 Shanxi Province = 13 Guangdong Province = 14 Guangxi Province = 15 Xinjiang Province = 16 Jiangsu Province = 17 Jiangxi Province = 18 Hebei Province = 20 Zhejiang Province = 21 Hainan Province = 22 Hubei Province = 24 Macao = 25 Gansu Province = 26 Fujian Province = 27 Xizang = 28 Liaoning Province = 29 Shaanxi Province Province = 30 Qinghai Province = 31 Hong Kong = 32 Heilongjiang Province = 33DEFAULT_NODE=34
5. Configure server.xml
Mysql mycatdb
6. Start mycat
/ usr/local/mycat/bin/mycat start
View mycat Log
STATUS | wrapper | 10:07:48 on 2018-11-22 |-- > Wrapper Started as DaemonSTATUS | wrapper | 10:07:48 on 2018-11-22 | Launching a JVM...INFO | jvm 1 | 10:07:48 on 2018-11-22 | OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=64M Support was removed in 8.0INFO | jvm 1 | 10:07:50 on 2018-11-22 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.orgINFO | jvm 1 | 10:07:50 on 2018-11-22 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved.INFO | jvm 1 | 10:07:50 on 2018-11-22 | INFO | jvm 1 | 10:07:57 on 2018-11-22 | MyCAT Server startup successfully. See logs in logs/mycat.log
Log in to mysql for data verification
Mysql-uroot-pmysql-P8066-h292.168.8.30mysql > show databases;+-+ | DATABASE | +-+ | mycatdb | +-+ 1 row in set (0.01 sec) mysql > 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 | +-+ 1 row in set (0.01 sec)
Because the properties of table are configured in schema.xml, you will see this table when you log in to MySQL, but you cannot view the data and cannot delete it directly with drop table.
You need to use the command DROP TABLE IF EXISTS `user01` to delete this table for the first time; otherwise, you will be prompted that the table cannot be found.
To create a table, a province field is required.
Mysql > DROP TABLE IF EXISTS `user01`; Query OK, 0 rows affected (0.84 sec) mysql > create table user01 (province varchar (40)); Query OK, 0 rows affected (1.74 sec)
Insert test data into the user01 table, with 20 records per province
View some of the data in node1
Mysql > select count (*), province from testdb01.user01 group by province;+-+-+ | count (*) | province | +-+-+ | 20 | Beijing | +-+-+ 1 row in set (0.01sec) mysql > select count (*), province from testdb05.user01 group by province +-+-+ | count (*) | province | +-+-+ | 20 | Guizhou Province | +-+-+ 1 row in set (0.00 sec) mysql > select count (*), province from testdb12.user01 group by province +-+ | count (*) | province | +-+-+ | 20 | Anhui Province | +-+-+ 1 row in set (0.00 sec)
View some of the data in node2
Mysql > select count (*), province from testdb16.user01 group by province;+-+-+ | count (*) | province | +-+-+ | 20 | Guangxi Province | +-+-+ 1 row in set (0.00 sec) mysql > select count (*), province from testdb19.user01 group by province +-+-+ | count (*) | province | +-+-+ | 20 | Jiangxi Province | +-+-+ 1 row in set (0.00 sec) mysql > select count (*), province from testdb22.user01 group by province +-+ | count (*) | province | +-+-+ | 20 | Zhejiang Province | +-+-+ 1 row in set (0.00 sec)
View some of the data in node3
Mysql > select count (*), province from testdb25.user01 group by province;+-+-+ | count (*) | province | +-+-+ | 20 | Hunan Province | +-+-+ 1 row in set (0.00 sec) mysql > select count (*), province from testdb30.user01 group by province +-+-+ | count (*) | province | +-+-+ | 20 | Liaoning Province | +-+-+ 1 row in set (0.01sec) mysql > select count (*), province from testdb33.user01 group by province +-+ | count (*) | province | +-+-+ | 20 | Hong Kong | +-+-+ 1 row in set (0.00 sec)
8. Check the size of each part
Node1
Mysql > select table_schema,table_name as "Tables", ROUND (data_length +-> index_length) / 1024), 2) "Size in KB"-> from information_schema.TABLES-> where TABLE_NAME = "user01"-> order by (data_length + index_length) desc +-+ | table_schema | Tables | Size in KB | +-+ | testdb09 | user01 | 16.00 | testdb08 | user01 | 16.00 | testdb07 | user01 | 16.00 | | testdb06 | user01 | 16.00 | | testdb05 | user01 | 16.00 | testdb04 | user01 | 16.00 | testdb03 | user01 | 16.00 | testdb02 | user01 | testdb12 | user01 | 16.00 | testdb01 | user01 | 16.00 | testdb11 | user01 | 16.00 | testdb10 | user01 | 16.00 | +-| -+ 12 rows in set (0.00 sec)
Node2
Mysql > select table_schema,table_name as "Tables", ROUND (data_length +-> index_length) / 1024), 2) "Size in KB"-> from information_schema.TABLES-> where TABLE_NAME = "user01"-> order by (data_length + index_length) desc +-+ | table_schema | Tables | Size in KB | +-+ | testdb18 | user01 | 16.00 | testdb17 | user01 | 16.00 | testdb16 | user01 | 16.00 | | testdb15 | user01 | 16.00 | | testdb14 | user01 | 16.00 | testdb24 | user01 | 16.00 | testdb13 | user01 | 16.00 | testdb23 | user01 | testdb22 | user01 | 16.00 | testdb21 | user01 | 16.00 | testdb20 | user01 | 16.00 | testdb19 | user01 | 16.00 | +-| -+ 12 rows in set (0.00 sec)
Node3
Mysql > select table_schema,table_name as "Tables", ROUND (data_length +-> index_length) / 1024), 2) "Size in KB"-> from information_schema.TABLES-> where TABLE_NAME = "user01"-> order by (data_length + index_length) desc +-+ | table_schema | Tables | Size in KB | +-+ | testdb26 | user01 | 16.00 | testdb25 | user01 | 16.00 | testdb35 | user01 | 16.00 | | testdb34 | user01 | 16.00 | | testdb33 | user01 | 16.00 | testdb32 | user01 | 16.00 | testdb31 | user01 | 16.00 | testdb30 | user01 | testdb29 | user01 | 16.00 | testdb28 | user01 | 16.00 | testdb27 | user01 | 16.00 | +- +-+ 11 rows in set (0.00 sec)
At this point, the fragment enumeration is over.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.