1 安裝後進入
Schema.xml配置信息如下,數據節點名稱dn1、dn2、dn3:
安裝完後登錄測試:
mysql -utest -ptest -h127.0.0.1 -P8066 -DTESTDB
2 , 創建表
create table travelrecord (id bigint not null primary key,user_id varchar(100),traveldate DATE, fee decimal,days int);
3,錄入數據
3.1插入在分片0上:
explain insert into travelrecord (id,user_id,traveldate,fee,days) values(100001,’xiaohong’,’2014-01-06’,510.5,3);
insert into travelrecord (id,user_id,traveldate,fee,days) values(100001,’xiaohong’,’2014-01-06’,510.5,3);
3.2錄入在分片1上:
explain insert into travelrecord (id,user_id,traveldate,fee,days) values(8000004,’mazi’,’2014-01-06’,510.5,3);
insert into travelrecord (id,user_id,traveldate,fee,days) values(8000004,’mazi’,’2014-01-06’,510.5,3);
3.3錄入在分片2上:
explain insert into travelrecord (id,user_id,traveldate,fee,days) values(10000004,’suqi’,’2014-01-06’,510.5,3);
insert into travelrecord (id,user_id,traveldate,fee,days) values(10000004,’suqi’,’2014-01-06’,510.5,3);
4,查詢數據
4.1在mycat後台的db上面,路由看到是分在3個片上面,
explain select * from Travelrecord;
4.2單個數據路由分析,都在不同的datanode上:
4.3去實際的mysql上面測試,查詢數據,已經分到3個分片 db1、db2、db3上面了,如下所示: