安装
[root@centos02 ~]# yum -y install mysql mysql-server
启动
[root@centos02 ~]# service mysqld start
进入控制台,修改root密码
[root@centos02 ~]# mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');
Query OK, 0 rows affected (0.00 sec)
安装sysbench
[root@centos02 ~]# wget https://github.com/akopytov/sysbench/archive/0.5.zip
[root@centos02 ~]# unzip 0.5.zip
[root@centos02 ~]# cd sysbench-0.5
[root@centos02 sysbench-0.5]# yum -y install gcc gcc-c++ autoconf automake mysql-devel libtool*
[root@centos02 sysbench-0.5]# ./autogen.sh
[root@centos02 sysbench-0.5]# ./configure --with-mysql --prefix=/usr/local/sysbench-0.5 && make && make install
新建测试库
[root@centos02 sysbench-0.5]# mysql -uroot -p123456
mysql> create database pressure_test_db;
Query OK, 0 rows affected (0.00 sec)
准备数据
[root@centos02 sysbench-0.5]# /usr/local/sysbench-0.5/bin/sysbench --test=/root/sysbench-0.5/sysbench/tests/db/select.lua --oltp-table-size=20000 --mysql-table-engine=innodb --mysql-user=root --mysql-password=123456 --mysql-port=3306 --mysql-host=127.0.0.1 --mysql-db=pressure_test_db --max-requests=0 --max-time=60 --oltp-tables-count=20 --report-interval=10 --num_threads=2 prepare
执行测试
[root@centos02 sysbench-0.5]# /usr/local/sysbench-0.5/bin/sysbench --test=/root/sysbench-0.5/sysbench/tests/db/select.lua --oltp-table-size=20000 --mysql-table-engine=innodb --mysql-user=root --mysql-password=123456 --mysql-port=3306 --mysql-host=127.0.0.1 --mysql-db=pressure_test_db --max-requests=0 --max-time=60 --oltp-tables-count=20 --report-interval=10 --num_threads=2 run
测试结果
因为是虚拟机,读的qps=303731/60≈5061,并不是很高,主要演示过程