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的事務,所以只是跑的讀操作