当前位置:主页 > 查看内容

使用sysbench测试mysql及postgresql(完整版) - funnyZpC

发布时间:2021-04-30 00:00| 位朋友查看

简介:使用sysbench测试mysql及postgresql(完整版) 转载请注明出处 https://www.cnblogs.com/funnyzpc/p/14592166.html 前言 使用sysbench测试数据库十分的麻烦(主要是sysbench安装麻烦),本人需要测试mysql及postgresql,mysql可以正常编译通过,postgresql的怎么……

使用sysbench测试mysql及postgresql(完整版)

转载请注明出处https://www.cnblogs.com/funnyzpc/p/14592166.html

前言

使用sysbench测试数据库十分的麻烦(主要是sysbench安装麻烦),本人需要测试mysql及postgresql,mysql可以正常编译通过,postgresql的怎么都不行,后来群内有网友提供编译版,
发现一切都好使了??,在此感谢某网友提供的编译版sysbench

另外,如在使用过程中报各种莫名其妙的错误请使用yum或apt安装下mysql或postgresql ,后续基本都顺利~

sysbench主要参数

  • --threads=10:表示发起10个并发连接
  • --report-interval=20:表示每10秒输出一次测试进度报告
  • --oltp-tables-count=3:表示会生成3个测试表
  • --oltp-table-size=50000000:表示每个测试表填充数据量为50000000

下载执行文件

使用方式

  • mysql: ./sysbench_mysql [执行参数]
  • postgresql: ./sysbench_pg [执行参数]
  • oracle: ./sysbench_ora [执行参数]

mysql 测试

构建测试数据

./sysbench_mysql --test=./tests/include/oltp_legacy/oltp.lua \
--mysql-host=服务域名或地址 --mysql-port=服务端口 --mysql-user=数据库用户 --mysql-password=数据库密码 --mysql-db=测试DB \
--oltp-test-mode=complex --oltp-tables-count=3 --oltp-table-size=50000000 \
--threads=12 --time=120 --report-interval=20 prepare

执行测试

  • 复杂模式执行复杂查询
./sysbench_mysql --test=./tests/include/oltp_legacy/oltp.lua \
--mysql-host=服务域名或地址  --mysql-port=服务端口 --mysql-user=数据库用户 --mysql-password=数据库密码 --mysql-db=测试DB \
--oltp-test-mode=complex --oltp-read-only=on --oltp-tables-count=3 --oltp-table-size=50000000 \
--threads=12 --time=120 --report-interval=20 run >> /mnt/sysbench/mysql_bench_complex_20210400.log
  • 简单模式执行增删改查
./sysbench_mysql --test=./tests/include/oltp_legacy/oltp.lua \
--mysql-host=服务域名或地址  --mysql-port=服务端口 --mysql-user=数据库用户 --mysql-password=数据库密码 --mysql-db=测试DB \
--oltp-test-mode=simple --oltp-tables-count=3 --oltp-table-size=50000000 \
--threads=12 --time=120 --report-interval=20 run >> /mnt/sysbench/mysql_bench_simple_20210400.log

清理测试数据

./sysbench_mysql --test=./tests/include/oltp_legacy/oltp.lua \
--mysql-host=服务域名或地址  --mysql-port=服务端口 --mysql-user=数据库用户 --mysql-password=数据库密码 --mysql-db=测试DB \
--oltp-tables-count=3 cleanup

postgresql测试

构建测试数据

./sysbench_pg --test=./tests/include/oltp_legacy/oltp.lua \
--pgsql-host=服务域名或地址  --pgsql-port=服务端口 --pgsql-user=数据库用户 --pgsql-password=数据库密码  \
--pgsql-db=测试DB --oltp-tables-count=3 --oltp-table-size=50000000 \
--report-interval=20 --threads=12 \
prepare

执行测试

  • 复杂模式执行复杂查询
./sysbench_pg --test=./tests/include/oltp_legacy/oltp.lua \
--pgsql-host=服务域名或地址 --pgsql-port=服务端口 --pgsql-user=数据库用户 --pgsql-password=数据库密码  \
--pgsql-db=测试DB --oltp-tables-count=3 --oltp-table-size=50000000 \
--oltp-test-mode=complex --oltp-read-only=on --report-interval=20 --threads=12 \
run >> /mnt/sysbench/pg_bench_complex_20210400.log
  • 简单模式执行增删改查
./sysbench_pg --test=./tests/include/oltp_legacy/oltp.lua \
--pgsql-host=服务域名或地址 --pgsql-port=服务端口 --pgsql-user=数据库用户 --pgsql-password=数据库密码  \
--pgsql-db=测试DB --oltp-tables-count=3 --oltp-table-size=50000000 \
--oltp-test-mode=simple --report-interval=20 --threads=12 \
run >> /mnt/sysbench/pg_bench_simple_20210400.log

清理文件

-- [错误]
./sysbench_pg --test=./tests/include/oltp_legacy/oltp.lua \
--pgsql-host=服务域名或地址 --pgsql-port=服务端口 --pgsql-user=数据库用户 --pgsql-password=数据库密码  \
--pgsql-db=测试DB --oltp-tables-count=3 --oltp-table-size=50000000 \
cleanup

以上清理文件需要说明的是:可能由于sysbench_pg编译的版本比较低所以sysbench_pg在执行的时候会抛错,但这不是大问题,简单处理就是手动删除下测试表~

--各位周末愉快??--

-原文链接:https://www.cnblogs.com/funnyzpc/p/14592166.html
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文


随机推荐