上篇主要介紹了kingshard的工做流程、搭建及部分功能測試,今天來測試一下kingshard對sharding的支持node
1、kingshard的sharding介紹
1.1 kingshard的sharding優點
如今開源的MySQL Proxy已經有幾款了,而且有的已經在生產環境上普遍應用。但這些proxy在sharding方面,都是不能分子表的。也就是說一個node節點只能分一張表。但咱們的線上需求一般是這樣的:mysql
我有一張很是大的表,行數超過十億,須要進行拆分處理。假設拆分因子是512。 若是採用單node單數據庫的分表方式,那其實這512個子表仍是存在一個物理節點上,意義不大。 若是採用他們的sharding功能,就須要512個物理節點,也不現實。 面對這種需求,現有的proxy就不能很好地知足要求了。一般咱們但願將512張子表均分在幾個MySQL節點上,從而達到系統的橫向擴展。git
然而kingshard較好地實現了這種典型的需求。簡單來講,kingshard的分表方案採用兩級映射的方式:github
1.kingshard將該表分紅512張子表,例如:test_0000,test_0001,... test_511。 2.將shardKey經過hash或range方式定位到其要操做的記錄在哪張子表上。 3.子表落在哪一個node上經過配置文件設置。
1.2 sharding支持的操做
目前kingshard sharding支持insert, delete, select, update和replace語句, 全部這五類操做都支持跨子表。但寫操做僅支持單node上的跨子表,select操做則能夠跨node,跨子表。web
1.3 sharding方式
1.3.1 range方式
基於整數範圍劃分來獲得子表下標。該方式的優勢:基於範圍的查詢或更新速度快,由於查詢(或更新)的範圍有可能落在同一張子表中。這樣能夠避免所有子表的查詢(更新)。缺點:數據熱點問題。由於在一段時間內整個集羣的寫壓力都會落在一張子表上。此時整個mysql集羣的寫能力受限於單臺mysql server的性能。而且,當正在集中寫的mysql 節點若是宕機的話,整個mysql集羣處於不可寫狀態。基於range方式的分表字段類型受限。sql
1.3.2 hash方式
kingshard採用(shardKey%子表個數)的方式獲得子表下標。優勢:數據分佈均勻,寫壓力會比較平均地落在後端的每一個MySQL節點上,整個集羣的寫性能不會受限於單個MySQL節點。而且當某個分片節點宕機,只會影響到寫入該節點的請求,其餘節點的寫入請求不受影響。分表字段類型不受限。由於任何一個類型的分表字段,均可以經過一個hash函數計算獲得一個整數。缺點:基於範圍的查詢或更新,都須要將請求發送到所有子表,對性能有必定影響。但若是不是基於範圍的查詢或更新,則性能不會受到影響。數據庫
1.3.3 按時間分表
kingshard中的分表字段支持MySQL中三種類型的時間格式後端
- date類型,格式:YYYY-MM-DD,例如:2016-03-04,注意:2016-3-04,2016-03-4,2016-3-4等格式kingshard都是不支持的。
- datetime類型,格式:YYYY-MM-DD HH:MM:SS,例如:2016-03-04 13:23:43,注意:2016-3-04 13:23:43,2016-03-4 13:23:43,2016-3-4 13:23:43等格式kingshard都是不支持的,必須嚴格按照規定的格式,kingshard才支持。
- timestamp類型,整數類型,例如:1457165568,對應的是:2016-3-5 16:12:48
1.4 sharding相關的配置介紹
在配置文件中,有關sharding設置是經過schema設置:架構
schema : - nodes: [node1,node2] rules: default: node1 shard: - #分表所在的DB db : kingshard #分表名字 table: test_shard_hash #sharding key key: id #子表分佈的節點名字 nodes: [node1, node2] #sharding類型 type: hash #子表個數分佈,表示[test_shard_hash_0000, test_shard_hash_0001, test_shard_hash_0002, test_shard_hash_003]在node1上。 #[test_shard_hash_0004, test_shard_hash_0005, test_shard_hash_0006, test_shard_hash_007]在node2上 locations: [4,4] - #分表所在的DB db : kingshard #分表名字 table: test_shard_range #sharding key key: id #sharding類型 type: range #子表分佈的節點名字 nodes: [node1, node2] #子表個數分佈,表示[test_shard_range_0000, test_shard_range_0001, test_shard_range_0002, test_shard_range_003]在node1上。 #[test_shard_range_0004, test_shard_range_0005, test_shard_range_0006, test_shard_range_007]在node2上 locations: [4,4] #每張子表的記錄數。[0,10000)在test_shard_range_0000上,[10000,20000)在test_shard_range_0001上。.... table_row_limit: 10000
一個kingshard實例只能有一個schemas,從上面的配置能夠看出,schema能夠分爲三個部分:函數
1.db,表示這個schemas使用的數據庫。 2.nodes,表示子表分佈的節點名字。 3.rules,sharding規則。其中rules又能夠分爲兩個部分: - default,默認分表規則。全部操做不在shard(default規則下面的規則)中的表的SQL語句都會發向該node。 - hash,hash分表方式。 - range,range分表方式
1.5 分表架構圖
2、sharding方式演示
2.1 range分表方式演示
2.1.1 基礎環境準備
分別在三個節點建立測試表:
建表語句: CREATE TABLE `test_shard_range_0000` ( `id` bigint(64) unsigned NOT NULL, `str` varchar(256) DEFAULT NULL, `f` double DEFAULT NULL, `e` enum('test1','test2') DEFAULT NULL, `u` tinyint(3) unsigned DEFAULT NULL, `i` tinyint(4) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 node1: mysql> show tables; +-----------------------+ | Tables_in_test | +-----------------------+ | test_shard_range_0000 | | test_shard_range_0001 | +-----------------------+ 2 rows in set (0.00 sec) node2: mysql> show tables; +-----------------------+ | Tables_in_test | +-----------------------+ | test_shard_range_0002 | | test_shard_range_0003 | +-----------------------+ 2 rows in set (0.00 sec) node3: mysql> show tables; +-----------------------+ | Tables_in_test | +-----------------------+ | test_shard_range_0004 | | test_shard_range_0005 | +-----------------------+ 2 rows in set (0.00 sec)
kingshard配置及啓動:
配置文件
addr : 0.0.0.0:7676 user : tom password : 123456 web_addr : 0.0.0.0:9797 web_user : admin web_password : admin log_path : /home/mysql/3309_kingshard/log/ks.log log_level : debug log_sql: on allow_ips : 127.0.0.1 nodes : - name : node1 max_conns_limit : 32 user : tom password : 123456 master : xxxxxx:3309 down_after_noalive : 32 - name : node2 max_conns_limit : 32 user : tom password : 123456 master : xxxxxxx:3309 down_after_noalive: 32 - name : node3 max_conns_limit : 32 user : tom password : 123456 master : xxxxxxx:3309 down_after_noalive : 32 schema : nodes: [node1,node2,node3] default: node1 shard: #按hash分表 # - # db : test # table: test_shard_hasg # key: id # nodes: [node1, node2, node3] # type: hash # locations: [2,2,2] # #按range分表 # - # db : test # table: test_shard_range # key: id # type: range # nodes: [node1, node2, node3] # locations: [2,2,2] # table_row_limit: 10 #按year分表 - db : test table: test_shard_year key: ctime nodes: [node1, node2, node3] type: date_year date_range: [2016,2017,2018] # - # db : kingshard # table: test_shard_month # key: dtime # type: date_month # nodes: [node1,node2] # date_range: [201603-201605,201609-201612] # - # db : kingshard # table: test_shard_day # key: mtime # type: date_day # nodes: [node1,node2] # date_range: [20160306-20160307,20160308-20160309]
注意:nodes的信息要和表信息還有schema裏面的nodes信息對應,否則分表寫入會有問題
啓動
./bin/kingshard -config=./conf/ks.yaml
2.1.2 測試演示
在kingshard下面操做: mysql> insert into test_shard_range(id,str,f,e,u,i) values(1,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(11,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(21,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(31,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(41,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(51,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) 跨節點查詢: mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 2 | 3 | | 11 | flike | 3.14 | test2 | 2 | 3 | | 21 | flike | 3.14 | test2 | 2 | 3 | | 31 | flike | 3.14 | test2 | 2 | 3 | | 41 | flike | 3.14 | test2 | 2 | 3 | | 51 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 10 rows in set (0.00 sec) 跨節點更新: mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 2 | 3 | | 11 | flike | 3.14 | test2 | 2 | 3 | | 21 | flike | 3.14 | test2 | 2 | 3 | | 22 | flike | 3.14 | test2 | 2 | 3 | | 23 | flike | 3.14 | test2 | 2 | 3 | | 31 | flike | 3.14 | test2 | 2 | 3 | | 32 | flike | 3.14 | test2 | 2 | 3 | | 33 | flike | 3.14 | test2 | 2 | 3 | | 41 | flike | 3.14 | test2 | 2 | 3 | | 51 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 10 rows in set (0.00 sec) mysql> update test_shard_range set i=100; Query OK, 10 rows affected (0.00 sec) mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 2 | 100 | | 11 | flike | 3.14 | test2 | 2 | 100 | | 21 | flike | 3.14 | test2 | 2 | 100 | | 22 | flike | 3.14 | test2 | 2 | 100 | | 23 | flike | 3.14 | test2 | 2 | 100 | | 31 | flike | 3.14 | test2 | 2 | 100 | | 32 | flike | 3.14 | test2 | 2 | 100 | | 33 | flike | 3.14 | test2 | 2 | 100 | | 41 | flike | 3.14 | test2 | 2 | 100 | | 51 | flike | 3.14 | test2 | 2 | 100 | +----+-------+------+-------+------+------+ 10 rows in set (0.00 sec) 跨節點刪除: mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 2 | 100 | | 11 | flike | 3.14 | test2 | 2 | 100 | | 21 | flike | 3.14 | test2 | 2 | 100 | | 22 | flike | 3.14 | test2 | 2 | 100 | | 23 | flike | 3.14 | test2 | 2 | 100 | | 31 | flike | 3.14 | test2 | 2 | 100 | | 32 | flike | 3.14 | test2 | 2 | 100 | | 33 | flike | 3.14 | test2 | 2 | 100 | | 41 | flike | 3.14 | test2 | 2 | 100 | | 51 | flike | 3.14 | test2 | 2 | 100 | +----+-------+------+-------+------+------+ 10 rows in set (0.00 sec) mysql> delete from test_shard_range where id >11 and id <51; Query OK, 7 rows affected (0.00 sec) mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 2 | 100 | | 11 | flike | 3.14 | test2 | 2 | 100 | | 51 | flike | 3.14 | test2 | 2 | 100 | +----+-------+------+-------+------+------+ 3 rows in set (0.01 sec) 對子查詢的支持:(不支持) mysql> select * from test_shard_range where id in (select u from test_shard_range where id=1); ERROR 1146 (42S02): Table 'test.test_shard_range' doesn't exist 在node1下查看: mysql> select * from test_shard_range_0000; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.00 sec) mysql> select * from test_shard_range_0001; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 11 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.00 sec) 在node2下查看: mysql> select * from test_shard_range_0002; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 21 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 3 rows in set (0.00 sec) mysql> select * from test_shard_range_0003; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 31 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 3 rows in set (0.00 sec) 在node3下查看: mysql> select * from test_shard_range_0004; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 41 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.00 sec) mysql> select * from test_shard_range_0005; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 51 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.00 sec)
結論:range分表更能比較好用,不過不支持子查詢,若是支持子查詢就行了
2.2 hash分表方式演示
插入操做: mysql> insert into test_shard_range(id,str,f,e,u,i) values(1,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(2,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(3,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(4,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(5,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(6,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(7,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(8,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_range(id,str,f,e,u,i) values(9,"flike",3.14,'test2',2,3); Query OK, 1 row affected (0.00 sec) 查詢操做: mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 6 | flike | 3.14 | test2 | 2 | 3 | | 1 | flike | 3.14 | test2 | 2 | 3 | | 7 | flike | 3.14 | test2 | 2 | 3 | | 2 | flike | 3.14 | test2 | 2 | 3 | | 8 | flike | 3.14 | test2 | 2 | 3 | | 3 | flike | 3.14 | test2 | 2 | 3 | | 9 | flike | 3.14 | test2 | 2 | 3 | | 4 | flike | 3.14 | test2 | 2 | 3 | | 5 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 9 rows in set (0.01 sec) 更新操做: mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 6 | flike | 3.14 | test2 | 2 | 3 | | 1 | flike | 3.14 | test2 | 2 | 3 | | 7 | flike | 3.14 | test2 | 2 | 3 | | 2 | flike | 3.14 | test2 | 2 | 3 | | 8 | flike | 3.14 | test2 | 2 | 3 | | 3 | flike | 3.14 | test2 | 2 | 3 | | 9 | flike | 3.14 | test2 | 2 | 3 | | 4 | flike | 3.14 | test2 | 2 | 3 | | 5 | flike | 3.14 | test2 | 2 | 3 | +----+-------+------+-------+------+------+ 9 rows in set (0.01 sec) mysql> update test_shard_range set u=10; Query OK, 9 rows affected (0.00 sec) mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 6 | flike | 3.14 | test2 | 10 | 3 | | 1 | flike | 3.14 | test2 | 10 | 3 | | 7 | flike | 3.14 | test2 | 10 | 3 | | 2 | flike | 3.14 | test2 | 10 | 3 | | 8 | flike | 3.14 | test2 | 10 | 3 | | 3 | flike | 3.14 | test2 | 10 | 3 | | 9 | flike | 3.14 | test2 | 10 | 3 | | 4 | flike | 3.14 | test2 | 10 | 3 | | 5 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 9 rows in set (0.00 sec) distinct函數的支持: mysql> select * from test_shard_range; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 6 | flike | 3.14 | test2 | 10 | 3 | | 1 | flike | 3.14 | test2 | 10 | 3 | | 7 | flike | 3.14 | test2 | 10 | 3 | | 2 | flike | 3.14 | test2 | 10 | 3 | | 8 | flike | 3.14 | test2 | 10 | 3 | | 3 | flike | 3.14 | test2 | 10 | 3 | | 9 | flike | 3.14 | test2 | 10 | 3 | | 4 | flike | 3.14 | test2 | 10 | 3 | | 5 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 9 rows in set (0.00 sec) mysql> select count(distinct id) as tom from test_shard_range; +-----+ | tom | +-----+ | 9 | +-----+ 1 row in set (0.00 sec) mysql> select count(distinct u) as tom from test_shard_range; +-----+ | tom | +-----+ | 6 | +-----+ 1 row in set (0.00 sec) mysql> select count(distinct i) as tom from test_shard_range; +-----+ | tom | +-----+ | 6 | +-----+ 1 row in set (0.00 sec) group by的支持: mysql> select * from test_shard_range where id > 0 group by u limit 1; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 5 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.00 sec) mysql> select * from test_shard_range where id > 0 group by u limit 1; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 3 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.00 sec) mysql> select * from test_shard_range where id > 0 group by u limit 1; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.00 sec) mysql> select * from test_shard_range where id > 0 group by u limit 1; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 5 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 1 row in set (0.01 sec) order by的支持: mysql> select * from test_shard_range where id > 0 order by id; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 10 | 3 | | 2 | flike | 3.14 | test2 | 10 | 3 | | 3 | flike | 3.14 | test2 | 10 | 3 | | 4 | flike | 3.14 | test2 | 10 | 3 | | 5 | flike | 3.14 | test2 | 10 | 3 | | 6 | flike | 3.14 | test2 | 10 | 3 | | 7 | flike | 3.14 | test2 | 10 | 3 | | 8 | flike | 3.14 | test2 | 10 | 3 | | 9 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 9 rows in set (0.00 sec) mysql> select * from test_shard_range where id > 0 order by id limit 5; +----+-------+------+-------+------+------+ | id | str | f | e | u | i | +----+-------+------+-------+------+------+ | 1 | flike | 3.14 | test2 | 10 | 3 | | 2 | flike | 3.14 | test2 | 10 | 3 | | 3 | flike | 3.14 | test2 | 10 | 3 | | 4 | flike | 3.14 | test2 | 10 | 3 | | 5 | flike | 3.14 | test2 | 10 | 3 | +----+-------+------+-------+------+------+ 5 rows in set (0.00 sec)
注意:
一、當更新的記錄落在不一樣的子表,kingshard會以非事務的方式將更新操做發送到多個node上。
二、不支持distinct函數。
三、跨節點的group by可能每次出來的結果都不同。
2.3 date分表演示
建立測試表: CREATE TABLE `test_shard_year_2018` ( `id` int(10) NOT NULL, `name` varchar(40) DEFAULT NULL, `ctime` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 插入數據: mysql> insert into test_shard_year(id,name,ctime) values(12,"hello","2016-02-22 13:23:45"); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_year(id,name,ctime) values(12,"hello","2017-02-22 13:23:45"); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_year(id,name,ctime) values(12,"hello","2018-02-22 13:23:45"); Query OK, 1 row affected (0.00 sec) mysql> insert into test_shard_year(id,name,ctime) values(12,"hello","2019-02-22 13:23:45"); ERROR 1146 (42S02): Table 'test.test_shard_year_2019' doesn't exist 查看數據: mysql> select * from test_shard_year; +----+-------+---------------------+ | id | name | ctime | +----+-------+---------------------+ | 12 | hello | 2016-02-22 13:23:45 | | 12 | hello | 2017-02-22 13:23:45 | | 12 | hello | 2018-02-22 13:23:45 | +----+-------+---------------------+ 3 rows in set (0.01 sec) mysql> /*node1*/select * from test_shard_year_2016; +----+-------+---------------------+ | id | name | ctime | +----+-------+---------------------+ | 12 | hello | 2016-02-22 13:23:45 | +----+-------+---------------------+ 1 row in set (0.00 sec) mysql> /*node1*/select * from test_shard_year_2017; ERROR 1146 (42S02): Table 'test.test_shard_year_2017' doesn't exist mysql> /*node2*/select * from test_shard_year_2017; +----+-------+---------------------+ | id | name | ctime | +----+-------+---------------------+ | 12 | hello | 2017-02-22 13:23:45 | +----+-------+---------------------+ 1 row in set (0.00 sec) mysql> /*node3*/select * from test_shard_year_2018; +----+-------+---------------------+ | id | name | ctime | +----+-------+---------------------+ | 12 | hello | 2018-02-22 13:23:45 | +----+-------+---------------------+ 1 row in set (0.00 sec) mysql> /*node3*/select * from test_shard_year; ERROR 1146 (42S02): Table 'test.test_shard_year' doesn't exist
結論:date分表功能可用。
參考地址:https://github.com/flike/kingshard/
3、kingshard性能測試、優化
https://github.com/flike/kingshard/blob/master/doc/KingDoc/kingshard_performance_test.md
https://github.com/flike/kingshard/blob/master/doc/KingDoc/kingshard_performance_profiling.md