sysbench简介
该工具目前有三个版本0.4, 0.5和1.0, 版本间语法和参数上有些许差别. 本文为最新版本1.0.9, 其是基于LuaJIT的多线程基准测试工具, 常用于数据库基准测试; 另, 还可对操作系统关键子系统进行测试. 除內建测试, 还可编写Lua脚本, 实现特定业务的测试.
sysbench下载
链接, https://github.com/akopytov/sysbench
安装依赖环境
1. yum -y install make automake libtool pkgconfig libaio-devel vim-common
2. 设置从何处加载MySQL数据库的客户端库文件.
[[email protected] ~]# cat /etc/ld.so.conf.d/mysql.conf
/opt/mysql/lib
[[email protected] ~]# ldconfig
[[email protected] ~]# ldconfig --print-cache | grep ‘mysql‘
libmysqlclient.so.18 (libc6,x86-64) => /opt/mysql/lib/libmysqlclient.so.18
安装
1. [[email protected] sysbench-1.0.9]# ./autogen.sh
[[email protected] sysbench-1.0.9]# ./configure --prefix=/usr/local/sysbench-1.0.9
[[email protected] sysbench-1.0.9]# make -j 4
[[email protected] sysbench-1.0.9]# make install
2. 将命令sysbench的路径写入环境变量PATH中.
[[email protected] ~]# grep ‘PATH‘ .bash_profile
PATH=/usr/local/sysbench-1.0.9/bin:/opt/mysql/bin:$PATH:$HOME/bin
export PATH
[[email protected] ~]# source .bash_profile
3. 查看命令sysbench使用的MySQL数据库的客户端库文件.
[[email protected] ~]# ldd /usr/local/sysbench-1.0.9/bin/sysbench | grep ‘mysql‘
libmysqlclient.so.18 => /opt/mysql/lib/libmysqlclient.so.18 (0x00007f4376099000)
下面分别是fileio和oltp的测试实例.
1. [[email protected] sysbench_test]# sysbench fileio --file-num=4 --file-block-size=16384 --file-total-size=100G --file-test-mode=rndrd --file-extra-flags=direct --threads=16 --events=0 --time=14400 --report-interval=4 --verbosity=3 [prepare | run | cleanup]
2. [[email protected] sysbench_test]# sysbench /usr/local/sysbench-1.0.9/share/sysbench/oltp_insert.lua --auto_inc=on --tables=10 --mysql_storage_engine=innodb --table_size=5000000 --threads=16 --events=0 --time=14400 --report-interval=4 --verbosity=3 --mysql-host=localhost --mysql-port=3306 --mysql-socket=/data/3306/mysql.sock --mysql-user=root --mysql-password=123456 --mysql-db=sbtest [prepare | run | cleanup]
若感兴趣可关注订阅号”数据库最佳实践”(DBBestPractice).