使用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在执行的时候会抛错,但这不是大问题,简单处理就是手动删除下测试表~

--各位周末愉快

使用sysbench测试mysql及postgresql(完整版)的更多相关文章

  1. CentOS 6.5以上版本安装mysql 5.7 完整版教程(修订版)

    转载自:https://codeday.me/collect/20170524/21861.html 1: 检测系统是否自带安装mysql # yum list installed | grep my ...

  2. MySql数据库导出完整版(导出数据库,导出表,导出数据库结构)

    MySql数据库导出完整版(导出数据库,导出表,导出数据库结构) 用MySqlCE导出数据库脚本时,如数据库中包含中文内容,则导出异常. 现在可以通过mysqldump.exe直接导出数据库脚本步骤如 ...

  3. sysbench 测试mysql性能

    ===== #1sysbench --test=oltp --oltp-table-size=10000 --mysql-db=test --mysql-user=root --mysql-passw ...

  4. ubuntu 18.04使用sysbench测试MySQL性能

    首先下载安装sysbench: sudo apt-get install sysbench -y 查看一下sysbench版本是多少: zifeiy@zifeiy-S1-Series:~$ sysbe ...

  5. MySQL 锁(完整版)

    目录 锁总览 锁的作用 加锁流程 锁对数据库的影响 锁等待 死锁 锁类型 锁范围 锁方式 全局锁 全局读锁 全局QC锁 QC锁存在的问题: 备份锁 backup lock MDL锁 MDL锁类型 MD ...

  6. centos 安装postgresql 完整版

    按步骤 执行命令即可: yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-c ...

  7. centos6 yum安装mysql 5.6 (完整版)

    使用源代码编译安装mysql还是比较麻烦,一般来说设备安装时请网络同事临时开通linux上网,通过yum网络实现快速安装,或配置yum仓库进行内网统一安装. 通过网络快速安装过程如下 一.检查系统是否 ...

  8. sysbench 测试MYSQL

    http://imysql.cn/tag/%E5%8E%8B%E6%B5%8B http://imysql.cn/node/312 https://www.percona.com/blog/2013/ ...

  9. sysbench测试MySQL筛选tps

    log=$1tps_array=`awk -F '[,:]' '{print $4}' ${log}`zero=0 for tps in ${tps_array}do tps=`echo ${tps} ...

随机推荐

  1. ASCII Art

    ASCII Art https://npms.io/search?q=ASCII art ASCII Art Text to ASCII Art Generator (TAAG) http://pat ...

  2. calendar time shaper

    calendar time shaper const dateObj = { "id": 191837, "productId": 13602, "a ...

  3. Nodejs file path to url path

    import * as path from 'path'; import * as url from 'url'; const savePath = path.join('public', 'imag ...

  4. 14_MySQL条件查询

    本节所涉及的sql语句: -- 去除结果集中的重复记录 SELECT job FROM t_emp; SELECT DISTINCT job FROM t_emp; SELECT DISTINCT j ...

  5. Promise和async await详解

    本文转载自Promise和async await详解 Promise 状态 pending: 初始状态, 非 fulfilled 或 rejected. fulfilled: 成功的操作. rejec ...

  6. Redis与Spring Data Redis

    1.Redis概述 1.1介绍 官网:https://redis.io/ Redis是一个开源的使用ANSIC语言编写.支持网络.可基于内存 亦可持久化的日志型.Key-Value型的高性能数据库. ...

  7. vue-axios插件、django-cors插件、及vue如何使用第三方前端样式库:element/jQuery/bootstrap

    目录 一.vue的ajax插件:axios 1.安装axios 2.axios参数 二.CORS跨域问题(同源策略) 1.Django解决CORS跨域问题方法 三.前端请求携带参数及Django后台如 ...

  8. 【随便写写】印象笔记,WordPress,CSDN 等 写博客的不同

    之前有的文章,写在了印象笔记里面,有的文章,写在了自己的WordPress博客里面,但是,感觉还是需要在主流平台分享一下文章的.就再次写写文章吧.(PS:公众号最重要的不是写作,而是排版) 说说几个这 ...

  9. 5G时代,为什么NoSQL和SQL存在短板?

    01 介绍 当今的通信服务提供商(CSP)需要能够在处理海量复杂的数据的同时,不会下降或者减慢网路响应速度和可靠性.5G时代,设备和用户数量呈指数级增长,这对业务支持服务(BSS)提出了新需求,也成为 ...

  10. CentOS7安装 xmlsec1 编译并运行官方示例

    1. 自动安装下列软件和依赖(默认已安装libxml2和libxslt) yum install xmlsec1-openssl xmlsec1-openssl-devel 2. 查看官网 www.a ...