/mycat start mysql -uroot -p123456 -P8066 -h127.0.0.1 -DTESTDB 查看会写到哪个库 explain insert into travelrecord...(id,user_id,traveldate,fee,days) values(101,'lmkzxh',20160101,100,10); insert into travelrecord(id,user_id...select * from travelrecord; more /root/mycat/logs/mycat.log 可以看到是从备mysql。...insert into travelrecord(id,user_id,traveldate,fee,days) values(1011,'ok',20160101,100,10);
新增加 mycat 字符前缀标志 Hintsql:"/** mycat: */" 从 1.6 开始支持三种注解方式: /*#mycat:db_type=master*/ select * from travelrecord...mycat:db_type=slave*/ select * from travelrecord /**mycat:db_type=master*/ select * from travelrecord...mycat:db_type=master*/ select * from travelrecord /*!...mycat:db_type=slave*/ select * from travelrecord /*#mycat:db_type=master*/ select * from travelrecord.../*#mycat:db_type=slave*/ select * from travelrecord 多租户支持 通过注解方式在配置多个 schema 情况下,指定走哪个配置的 schema。
创建数据库表:travelrecord 。...CREATE TABLE `travelrecord` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `name` varchar(255) CHARACTER...io.mycat/"> <table name="<em>travelrecord</em>...使用 MySQL 客户端连接 MyCAT : HOST :127.0.0.1 PORT :8066 USERNAME :root PASSWORD :123456 mysql> insert into <em>travelrecord</em>...(name) values ('haha'); Query OK, 1 rows affected (0.01 sec) mysql> select * from <em>travelrecord</em>; +---
分片表的录入性能测试-T01测试案例:分片表的并发录入性能测试,测试 DEMO 中的 travelrecord 表,此表的基准 DDL 语句: create travelrecord: create table...travelrecord (id bigint not null primary key,user_id varchar(100),traveldate DATE, fee decimal,days...travelrecord (id bigint not null primary key,user_id varchar(100),traveldate DATE, fee decimal,days...表的最大 ID,可以执行 select max(id) from travelrecord 来获取。...记录,然后进行并发更新操作,update travelrecord set user =?
--splitTableNames 启用 <table name="<em>travelrecord</em>,address" dataNode...CREATE TABLE `travelrecord` ( `id` int(11) NOT NULL AUTO_INCREMENT , `uid` int(11) NULL , PRIMARY...| +------------------+ mysql> desc travelrecord; +-------+---------+------+-----+---------+-----...` (`id`, `uid`) VALUES(1, 1); Query OK, 1 row affected (0.03 sec) mysql> INSERT INTO `travelrecord` (...`id`, `uid`) VALUES(501, 501); Query OK, 1 row affected (0.03 sec) mysql> INSERT INTO `travelrecord`
-- auto sharding by id (long) --> <table name="<em>travelrecord</em>" dataNode="dn1,dn2,dn3" rule="auto-sharding-long...' already exists MySQL [TESTDB]> insert into <em>travelrecord</em>(id,user_id,traveldate,fee,days) values(1,@..., route={ 1 -> dn1{SELECT * FROM <em>travelrecord</em> LIMIT 100} 2 -> dn2{SELECT * FROM <em>travelrecord</em> LIMIT...100} 3 -> dn3{SELECT * FROM <em>travelrecord</em> LIMIT 100} } rrs 2017-07-07 06:28:24.474 DEBUG [$_NIOREACTOR...(MultiNodeQueryHandler.java:101)) - execute mutinode query select * from <em>travelrecord</em> 2017-07-07
标签解释 schema name:对应Server.xml中配置的逻辑库名TESTDB checkSQLschema:当该值设置为true时,如果我们执行语句select * from TESTDB.travelrecord...;则MyCat会把语句修改为select * from travelrecord;即把表示schema的字符去掉,避免发送到后端数据库执行时报(ERROR 1146 (42S02): Table ‘testdb.travelrecord...不过,即使设置该值为 true ,如果语句所带的是并非是schema指定的名字,例如:select * from db1.travelrecord; 那么MyCat并不会删除db1这个字段,如果没有定义该库的话则会报错...例如设置值为100,执行select * from TESTDB.travelrecord;的效果为和执行select * from TESTDB.travelrecord limit 100;相同设置该值的话
q-header-list=&q-url-param-list=&q-signature=0dd74d69e5de1c89288b450851b31de71476ba16] 在db1、db2、db3、创建表travelrecord...CREATE TABLE `travelrecord` ( `id` int(11) NOT NULL AUTO_INCREMENT , `uid` int(11) NULL , PRIMARY...KEY (`id`) ); 连接mycat,插入数据 INSERT INTO `travelrecord` (`id`, `uid`) VALUES(1, 1); INSERT INTO `travelrecord...` (`id`, `uid`) VALUES(5000001, 5000001); INSERT INTO `travelrecord` (`id`, `uid`) VALUES(10000001, 10000001...q-url-param-list=&q-signature=4674dd75853107c70a63c4569fbaaf219983e1c0] 执行sql,查看查询过程 EXPLAIN SELECT * FROM travelrecord
.* to 'mycat_user'@'%' ; 初始化数据 初始化数据库,我还是选用一个经典的标travelrecord,然后插入两行记录。在3个数据库db1,db2,db3中创建。...mysql> create table travelrecord (id bigint not null primary key,user_id varchar(100),traveldate DATE..., fee decimal,days int); mysql> insert into travelrecord(id,user_id,traveldate,fee,days) values(1,...@@hostname,20160101,100,10); mysql> insert into travelrecord(id,user_id,traveldate,fee,days) values...mysql> show tables; +---------------+ | Tables_in_db1 | +---------------+ | travelrecord | +--------
DEBUG [$_NIOREACTOR-0-RW] (EnchachePool.java:76) -SQLRouteCache miss cache ,key:testdbselect * from travelrecord... DEBUG [$_NIOREACTOR-0-RW] (EnchachePool.java:59) -SQLRouteCache add cache ,key:testdbselect * from travelrecord...value:select * from travelrecord, route={ 1 -> dn1{SELECT * FROM travelrecord LIMIT 100} 2 ->...testdb, host=0:0:0:0:0:0:0:1, user=test,txIsolation=3, autocommit=true, schema=testdb]select * from travelrecord..., route={ 1 -> dn1{SELECT * FROM travelrecord LIMIT 100} 2 -> dn2{SELECT * FROM travelrecord LIMIT
employee | | goods | | hotnews | | orders | | order_items | | travelrecord...创建完成之后再创建 travelrecord 表。...create table travelrecord (id bigint not null primary key,user_id varchar(100),traveldate DATE, fee decimal...You can turn off this feature to get a quicker startup with -A Database changed mysql> select * from travelrecord... <table name="<em>travelrecord</em>" dataNode
-- auto sharding by id (long) --> <table name="<em>travelrecord</em>" primaryKey="id" dataNode="dn1" autoIncrement
mycat:db_type=slave*/ select * from travelrecord /*#mycat:db_type=slave*/ select * from travelrecord...强制走写: /*#mycat:db_type=master*/ select * from travelrecord /*!...mycat:db_type=master*/ select * from travelrecord 1.3.2 根据主从延时切换: 1.4 开始支持 MySQL 主从复制状态绑定的读写分离机制,让读更加安全可靠
mycat:sql=select id from travelrecord where id=2*/ select * from travelrecord where id=2; 其中/*!...mycat: sql = select id from travelrecord where id=2*/ select * from travelrecord where id=2; Mycat 1.3...mycat:catlet=demo.catlets.MyHellowJoin */select a.*, b.title from travelrecord a ,hotnews b where a.id...根据ID主键的范围进行分片: create travelrecord: create table travelrecord (id bigint not null primary key,user_id...,fee,days) values(1,'wang','2014-01-05',510.5,3); explain insert into travelrecord (id,user_id,traveldate
employee | | goods | | hotnews | | orders | | order_items | | travelrecord
checkSQLschema="true" sqlMaxLimit="100" dataNode="dn1"> #需注释掉table标签,否则通过mycayt连接时创建的逻辑库中只会生成这travelrecord...-- <table name="<em>travelrecord</em>,address" dataNode="dn1,dn2,dn3" rule="auto-sharding-long" splitTableNames
领取专属 10元无门槛券
手把手带您无忧上云