sysbench 使用指北

sysbench
是一个模块化、跨平台、多线程基准测试工具,主要用于测试各类不一样系统参数下的数据库负载状况。
主要包括如下几种方式的测试:CPU性能、磁盘IO性能,线程调度性能。内存分配以及传输速度和数据库性能。
下面主要使用它用来测试数据库。mysql

sysbench github地址:https://github.com/akopytov/sysbench
sysbench安装:git

curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.rpm.sh | sudo bash
sudo yum -y install sysbench

源码安装:github

Building and Installing From Source
yum -y install make automake libtool pkgconfig libaio-devel
# For MySQL support, replace with mysql-devel on RHEL/CentOS 5
yum -y install mariadb-devel openssl-devel
# For PostgreSQL support
yum -y install postgresql-devel

 ./autogen.sh
# Add --with-pgsql to build with PostgreSQL support
./configure
make -j
make install

sysbench测试过程
lua脚本位置(指定测试用例)sql

find / -name oltp.lua
/usr/share/sysbench/tests/include/oltp_legacy

一、数据准备阶段数据库

# sysbench  /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-table-engine=innodb --table_size=100000 --threads=20 --oltp-tables-count=3  --mysql-db=test --mysql-user=root --mysql-host=localhost --mysql-password=MyNewPass4! prepare

二、数据测试阶段bash

# sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-table-engine=innodb --oltp-table-size=1000000 --oltp-tables-count=3 --mysql-db=test --mysql-user=root --mysql-host=localhost --mysql-password=MyNewPass4! --time=60 --max-requests=0 --threads=8 --report-interval=10 run

--threads=8     //线程数为8
--time=60       //测试时间为60s
--report-interval=10  //报告打印周期为10s,每10s打印一次
--oltp-read-only=off  //非只读操做测试多线程

三、数据清理阶段curl

# sysbench /usr/share/sysbench/tests/include/oltp_legacy/oltp.lua --mysql-table-engine=innodb --oltp-tables-count=3 --oltp-table-size=1000000 --mysql-db=test --mysql-user=root --mysql-host=localhost --mysql-password=MyNewPass4! cleanup

下次再仔细分析下测试结果。ide

相关文章
相关标签/搜索