0.在mycat1.4中做好配置
1.首先在物理数据库上创建sbtest
2.在sbtest中创建10个sbtest表从1到10
这里之所以要手工建是因为sysbench自动建表功能在mycat上不可以用
CREATE TABLE `sbtest1` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest10 -- ---------------------------- CREATE TABLE `sbtest10` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest2 -- ---------------------------- CREATE TABLE `sbtest2` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest3 -- ---------------------------- CREATE TABLE `sbtest3` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest4 -- ---------------------------- CREATE TABLE `sbtest4` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest5 -- ---------------------------- CREATE TABLE `sbtest5` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest6 -- ---------------------------- CREATE TABLE `sbtest6` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest7 -- ---------------------------- CREATE TABLE `sbtest7` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest8 -- ---------------------------- CREATE TABLE `sbtest8` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for sbtest9 -- ---------------------------- CREATE TABLE `sbtest9` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `k` int(10) unsigned NOT NULL DEFAULT '0', `c` char(120) NOT NULL DEFAULT '', `pad` char(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `k_1` (`k`) ) ENGINE=InnoDB AUTO_INCREMENT=9999991 DEFAULT CHARSET=utf8;
3.往10个表中灌数据,每个表中10万数据
./sysbench --mysql-host=127.0.0.1 --mysql-port=8066 --mysql-user=test --mysql-password=test --test=/home/cailin/sysbench-0.5/sysbench/tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=100000 --rand-init=on prepare
4.测试读
./sysbench --mysql-host=127.0.0.1 --mysql-port=8066 --mysql-user=test --mysql-password=test --test=/home/cailin/sysbench-0.5/sysbench/tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=10000000 --num-threads=8 --oltp-read-only=on --report-interval=10 --rand-type=uniform --max-time=3600 --max-requests=0 --percentile=99 run >> /home/cailin/sysbench-0.5/sysbenchbin/bin/log/sysbench_oltpX_mysql_20151020.log
5.结果
自己查看上面的日志吧,附件我自己的日志
6.结论
在第4步时,mycat不支持sysbench的事务,所以只是跑的读操作