您的位置:首页 > 其它

sysbench 使用指北

2020-08-28 17:10 330 查看

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

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

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

源码安装:

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脚本位置(指定测试用例)

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

1、数据准备阶段

# 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

2、数据测试阶段

# 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  //非只读操作测试

3、数据清理阶段

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

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: