#linux版
http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20180122220033-linux.tar.gz
#启动命令 进入bin文件夹,最好放在/usr/local/mycat/
cd /usr/local/mycat/bin
./mycat start
#window版
http://dl.mycat.io/1.6.5/Mycat-server-1.6.5-release-20180122220033-win.tar.gz
#启动命令 进入bin文件夹,最好放在盘符根目录,无中文
startup_nowrap.bat
1、server.xml
utf8mb4
0
1
0
0
2
false
0
8066
9066
0.0.0.0
4096
0
1
64k
1k
0
384m
false
test
TESTDB1,TESTDB2
true
root
TESTDB1,TESTDB2
dev
TESTDB1,TESTDB2
true
2、schema.xml
select user()
3、rule.xml
id
func1
user_id
func1
sharding_id
hash-int
id
rang-long
id
mod-long
id
murmur
id
crc32slot
create_time
partbymonth
calldate
latestMonth
id
rang-mod
id
jump-consistent-hash
province_no
stringenum
partition-by-string-enum.txt
1
0
2
160
2
partition-hash-int.txt
autopartition-long.txt
3
8
128
24
yyyy-MM-dd
2015-01-01
partition-range-mod.txt
3
4、partition-by-string-enum.txt
HUBEI=0
HUNAN=0
GUANGXI=1
GUANGDONG=1
HEILONGJIANG=1
YUNNAN=2
SICHUAN=2
JIANGXI=2
DDL(数据定义语言)
将新建数据库插入到4002或4004端口中,并将建表语句插入到每个数据库中
CREATE DATABASE db1;
CREATE DATABASE db2;
CREATE DATABASE db3;
DROP TABLE IF EXISTS `shop`;
CREATE TABLE `shop` (
`id` int(11) NOT NULL,
`shop_name` char(18) CHARACTER SET utf8mb4 NOT NULL,
`address` varchar(128) CHARACTER SET utf8mb4 DEFAULT NULL,
`phone_number` varchar(21) CHARACTER SET utf8mb4 DEFAULT NULL,
`province_no` varchar(16) CHARACTER SET utf8mb4 DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
DML(数据操作语言)
将DML插入到8066端口中
INSERT into shop (id,shop_name,address,phone_number,province_no) values (1,'深圳第一连锁店','深圳市南山区科技南五路1号','075584569789','GUANGDONG');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (2,'武汉第一连锁店','武汉市洪山区太平路1号','02784569789','HUBEI');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (3,'武汉第二连锁店','武汉市南山区科技南五路1号','02784569789','HUBEI');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (4,'南昌第一连锁店','南昌市红军路1号','053284569789','JIANGXI');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (5,'岳阳市第一连锁店','岳阳市南和平路1号','073084569789','HUNAN');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (6,'哈尔滨第一连锁店','哈尔滨市沿江路1号','045184569789','HEILONGJIANG');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (7,'成都市第一连锁店','成都市和平路1号','02884569789','SICHUAN');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (8,'深圳第2连锁店','深圳市罗湖区红岗路1号','075584569789','GUANGDONG');
INSERT into shop (id,shop_name,address,phone_number,province_no) values (9,'桂林市第2连锁店','桂林市梅雨路1号','077384569789','GUANGXI');
4002/4004每个负载均衡的每个数据库按枚举分片分到不同数据库中
3007,3008,3009,3010,3011 每个节点数据库中也都有相同的数据