--安装yum包
yum -y install bzr libtool
--对压缩包进行解
--注意不要在mysql的官网下载,因为其只支持mysql不支持pg
https://github.com/akopytov/sysbench/tree/0.4
tar zxf sysbench-0.4.12-1.1.tgz
mv sysbench-0.4.12-1.1 sysbench
unzip -d sysbench sysbench-0.5.zip
--如果MySQL不是安装在标准默认目录下,那么就还需要指定MySQL的路径
./autogen.sh
mkdir -p /usr/local/sysbencd_0.5/log
./configure --prefix=/usr/local/sysbencd_0.5 --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make && make install
./configure --prefix=/usr/local/sysbench/sysbench --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
编译sysbench的问题
drv_pgsql.c:29:22: error: libpq-fe.h: No such file or directory
drv_pgsql.c:104: error: expected specifier-qualifier-list before ‘Oid’
编译时指定CFLAGS
CFLAGS="-L/usr/local/postgresql/9.3.4/lib -I/usr/local/postgresql/9.3.4/include -lpq" ./configure --prefix=/usr/local/sysbench/sysbench --with-gnu-ld --with-mysql --with-pgsql --enable-dependency-tracking --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib --with-pgsql-includes=/usr/local/postgresql/9.3.4/include --with-pgsql-libs=/usr/local/postgresql/9.3.4/lib
make时报错:
/usr/bin/ld: warning: libssl.so.1.0.0, needed by /usr/local/postgresql/9.3.4/lib/libpq.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libcrypto.so.1.0.0, needed by /usr/local/postgresql/9.3.4/lib/libpq.so, not found (try using -rpath or -rpath-link)
env LDFLAGS=-R/usr/local/postgresql/9.3.4/lib ./configure --prefix=/usr/local/sysbench/sysbench --with-gnu-ld --with-pgsql --enable-dependency-tracking --with-pgsql-includes=/usr/local/postgresql/9.3.4/include --with-pgsql-libs=/usr/local/postgresql/9.3.4/lib
cp /usr/local/sysbencd_0.5/bin/sysbench /usr/local/bin/
cp -a /usr/local/sysbench/sysbench/tests /usr/local/sysbencd_0.5/
[root@mars sysbencd_0.5]# sysbench
sysbench: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
--sysbench无法找到mysql的库文件,这很可能是环境变量LD_LIBRARY_PATH没有设置,设置后即可解决该问题:
[root@mars sysbencd_0.5]# export LD_LIBRARY_PATH=/usr/local/mysql/lib
export LD_LIBRARY_PATH=/usr/local/mysql/lib
./sysbench --test=oltp --oltp-table-size=1000 --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password=123456 --mysql-db=test --db-driver=mysql prepare
sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='123456' --oltp-table-size=1000 --num-threads=8 --oltp-read-only=off run >> /tmp/sysbench_oltp.log
Mysql数据库测试
create database sbtest;
sysbench --mysql-host=127.0.0.1 --mysql-port=3306 --mysql-user=root --mysql-password='laba!123' --test=/usr/local/sysbencd_0.5/tests/db/oltp.lua --oltp_tables_count=10 --oltp-table-size=1000 --rand-init=on prepare
# --test=tests/db/oltp.lua 表示调用 tests/db/oltp.lua 脚本进行 oltp 模式测试
# --oltp_tables_count=10 表示会生成 10 个测试表
# --oltp-table-size=100000 表示每个测试表数据行数
# --rand
sysbench测试mysql与postgresql
最新推荐文章于 2024-08-18 22:31:29 发布
本文详细介绍了如何使用sysbench工具在MySQL和PostgreSQL上进行性能测试,包括安装步骤、配置参数、解决编译问题及测试过程。通过对测试结果的解读,比较了两种数据库的性能差异,发现PostgreSQL的TPS(每秒事务处理量)略高于MySQL。
摘要由CSDN通过智能技术生成