In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
What are the Mycat slicing rules? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
1.sharding-by-intfilehash fragmentation
Sharding rules corresponding to the table
Check rule.xml to view the corresponding relationship
Sharding_id is sliced according to this field
The method of hash-int slicing
Check the corresponding method of rule.xml
Partition-hash-int.txt-corresponding file
one
View Fil
[root@localhost conf] # more partition-hash-int.txt
1000000 # sharding_id is 10000 sent to 1 node
10010 # sharding_id is 10010 sent to 2 nodes
DEFAULT_NODE=1 # others insert to 2 nodes
Experiment
Mysql > create table employee (id int not null primary key,name varchar, sharding_id int not null)
Query OK, 0 rows affected (0.02 sec)
Mysql > insert into employee (id,name,sharding_id) values (2dint leader us',10000)
Query OK, 1 row affected (0.01sec)
Mysql > insert into employee (id,name,sharding_id) values (4pm leader us',10000)
Query OK, 1 row affected (0.00 sec)
Mysql > insert into employee (id,name,sharding_id) values (3dint leader us',100003);-others are plugged into 2 nodes
Mysql > insert into employee (id,name,sharding_id) values (4pm leader us',10010)
Query OK, 1 row affected (0.01sec)
Mysql > insert into employee (id,name,sharding_id) values (5 dagger leader us',10010)
Query OK, 1 row affected (0.03 sec)
2.auto-sharding-long range fragmentation
The slicing table is as follows:
View the relationship corresponding to rule.xml
Id
Rang-long
Corresponding method
Autopartition-long.txt
Corresponding files:
# range start-end, data node index
# Knights 1000, Manners 10000.
0-500M=0 # range 0-500m insert to the first node
500M-1000M=1 # range 500m-1000M is inserted into the second node
1000M-1500M=2 . Analogy
3.mod-log module slicing
Fun:
three
Id
Mod-long
4. Sharding-by-month is fragmented by month.
Tab:
Rule:
Create_time
Partbymonth
Yyyy-MM-dd
2015-01-01 # # start time
Test:
Mysql > insert into month_tab (id,name,sharding_id,create_time) values
Query OK, 1 row affected (0.43 sec)
Mysql > insert into month_tab (id,name,sharding_id,create_time) values.
Query OK, 1 row affected (0.01sec)
Mysql > insert into month_tab (id,name,sharding_id,create_time) values.
Query OK, 1 row affected (0.49 sec)
Mysql > insert into month_tab (id,name,sharding_id,create_time) values (4 minutes, 4 minutes, 4 minutes, 2015-04-04); # monthly slicing, with only three nodes, can only be plugged into 1pm in February and March, and errors have been reported since April.
ERROR 1064 (HY000): Can't find a valid data node for specified node index: MONTH_TAB-> CREATE_TIME-> 2015-04-04-> Index: 3
5 sharding-by-day daily sharding (1.6default files are not written, self-configured)
Tab:
Rule:
Create_time
Partbyday
Yyyy-MM-dd
2015-01-01 # # start date
3 # # how many days will it start slicing?
Test:
Nine days before it was inserted, it was divided into three pieces.
Mysql > select * from day_tab
+-- +
| | id | name | sharding_id | create_time | |
+-- +
| | 7 | 1 | 1 | 2015-01-08 00:00:00 |
| | 8 | 1 | 1 | 2015-01-09 00:00:00 |
| | 13 | 1 | 1 | 2015-01-07 00:00:00 |
| | 7 | 1 | 1 | 2015-01-01 00:00:00 |
| | 8 | 1 | 1 | 2015-01-02 00:00:00 |
| | 9 | 1 | 1 | 2015-01-03 00:00:00 |
| | 10 | 1 | 1 | 2015-01-04 00:00:00 |
| | 11 | 1 | 1 | 2015-01-05 00:00:00 |
| | 12 | 1 | 1 | 2015-01-06 00:00:00 |
+-- +
9 rows in set (0.01 sec)
Mysql > insert into day_tab (id,name,sharding_id,create_time) values (17pr), (18pas); # if you insert it for the 10th day, start to report an error.
ERROR 1064 (HY000): Index: 3, Size: 3
This is the answer to the question about what the Mycat slicing rules are. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
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.