ITPub博客

首页 > 数据库 > 数据库开发技术 > 国产数据库能否扛住压力—HaloDB压力测试

国产数据库能否扛住压力—HaloDB压力测试

原创 数据库开发技术 作者:sjw1933 时间:2024-07-16 07:30:00 0 删除 编辑
‍
「点击蓝字,关注我吧 」

作者:Digital Observer(施嘉伟)

Oracle ACE Pro: Database

PostgreSQL ACE Partner

11年数据库行业经验,现主要从事数据库服务工作

拥有Oracle OCM、DB2 10.1 Fundamentals、MySQL 8.0 OCP、WebLogic 12c OCA、KCP、PCTP、PCSD、OCI、PolarDB技术专家、达梦师资认证、数据安全咨询高级等认证

ITPUB认证专家、PolarDB开源社区技术顾问、HaloDB技术顾问、TiDB社区技术布道师、青学会MOP技术社区专家顾问、国内某高校企业实践指导教师‍‍‍‍‍‍‍‍‍‍‍‍‍

公众号:Digital Observer;CSDN:施嘉伟;ITPUB:sjw1933;PGFans:施嘉伟。


国产数据库如何压力测试?




众所周知国产化数据库进行压力测试的方法是通过模拟大量并发用户和操作,使用工具如JMeter或sysbench进行性能和负载测试,以评估数据库在高负荷下的稳定性和响应能力。本期我们来尝试用Sysbench压下HaloDB。


Sysbench介绍

Sysbench 是一个开源软件工具,具体来说,它是一个为 Linux 系统设计的可脚本多线程基准工具。它是一个 C 二进制文件,使用 LuaJIT 脚本来执行基准。它最常用于数据库基准测试,例如 PostgreSQL,但也可用于创建不涉及数据库服务器的一般性能测试。



01

源码安装Sysbench



安装包下载地址:https://github.com/akopytov/sysbench/tags





操作系统版本:CentOS Linux release 7.9.2009 (Core)



01
解压安装包
# tar -zxvf sysbench-1.0.20.tar.gz
02
编译安装


# cd sysbench-1.0.20/
# ./autogen.sh
# ./configure --without-mysql --with-pgsql --with-pgsql-includes=/u01/app/halo/product/dbms/14/include --with-pgsql-libs=/u01/app/halo/product/dbms/14/lib
# make
# make install

这里会碰到两个报错:

报错:

[18:19:43][root@mysql3 ~]# cd sysbench-1.0.20/

[18:19:49][root@mysql3 sysbench-1.0.20]# ./autogen.sh

[18:19:49]automake 1.10.x (aclocal) wasn't found, exiting

解决方法:

[18:25:58][root@mysql3 sysbench-1.0.20]# yum install automake

[18:26:02]Loaded plugins: fastestmirror

[18:26:02]Loading mirror speeds from cached hostfile


报错:

[root@mysql3 sysbench-1.0.20]# ./autogen.sh

libtoolize 1.4+ wasn't found, exiting

解决方法:

[root@mysql3 sysbench-1.0.20]# yum -y install libtool




03
验证是否安装成功
# su - halo
$ sysbench --version

如果遇下面报错:

sysbench: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

解决方法:

# vi .bash_profile

添加以下内容

export LD_LIBRARY_PATH=/u01/app/halo/product/dbms/14/lib

# source .bash_profile

# sysbench --version




02

sysbench压力测试


01
生成测试数据


参数填写Halodb数据库相关信息,注意threads(线程)数。测试数据生成一次即可。


[root@mysql3 ~]# sysbench /usr/local/share/sysbench/oltp_read_write.lua --auto_inc=off --pgsql-host=127.0.0.1 --pgsql-port=1921 --pgsql-db=test --table_size=500000 --tables=20 --threads=20 --time=60 --report-interval=10 --pgsql-user=halo --pgsql-password=halotest --db-driver=pgsql prepare
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Initializing worker threads...

Creating table 'sbtest7'...
Creating table 'sbtest17'...
Creating table 'sbtest13'...
Creating table 'sbtest9'...
Creating table 'sbtest4'...
Creating table 'sbtest6'...
Creating table 'sbtest19'...
Creating table 'sbtest16'...
Creating table 'sbtest20'...
Creating table 'sbtest3'...
Creating table 'sbtest12'...
Creating table 'sbtest5'...
Creating table 'sbtest14'...
Creating table 'sbtest11'...
Creating table 'sbtest18'...
Creating table 'sbtest10'...
Creating table 'sbtest8'...
Creating table 'sbtest1'...
Creating table 'sbtest15'...
Creating table 'sbtest2'...
Inserting 500000 records into 'sbtest14'
Inserting 500000 records into 'sbtest19'
Inserting 500000 records into 'sbtest12'
Inserting 500000 records into 'sbtest17'
Inserting 500000 records into 'sbtest6'
Inserting 500000 records into 'sbtest15'
Inserting 500000 records into 'sbtest7'
Inserting 500000 records into 'sbtest2'
Inserting 500000 records into 'sbtest8'
Inserting 500000 records into 'sbtest11'
Inserting 500000 records into 'sbtest3'
Inserting 500000 records into 'sbtest9'
Inserting 500000 records into 'sbtest1'
Inserting 500000 records into 'sbtest16'
Inserting 500000 records into 'sbtest5'
Inserting 500000 records into 'sbtest18'
Inserting 500000 records into 'sbtest10'
Inserting 500000 records into 'sbtest4'
Inserting 500000 records into 'sbtest13'
Inserting 500000 records into 'sbtest20'
Creating a secondary index on 'sbtest1'...
Creating a secondary index on 'sbtest20'...
Creating a secondary index on 'sbtest18'...
Creating a secondary index on 'sbtest13'...
Creating a secondary index on 'sbtest8'...
Creating a secondary index on 'sbtest19'...
Creating a secondary index on 'sbtest4'...
Creating a secondary index on 'sbtest12'...
Creating a secondary index on 'sbtest2'...
Creating a secondary index on 'sbtest3'...
Creating a secondary index on 'sbtest9'...
Creating a secondary index on 'sbtest5'...
Creating a secondary index on 'sbtest11'...
Creating a secondary index on 'sbtest7'...
Creating a secondary index on 'sbtest15'...
Creating a secondary index on 'sbtest16'...
Creating a secondary index on 'sbtest14'...
Creating a secondary index on 'sbtest10'...
Creating a secondary index on 'sbtest6'...
Creating a secondary index on 'sbtest17'...





参数名

说明

--db-driver

指定要测试的数据库类型,

--pgsql-host

数据库机器的   IP

--pgsql-port

端口号

--pgsql-user

用户名

--pgsql-password

密码

--pgsql-db

待连接的数据库

--table_size

每张表初始化的数据数量

--tables

初始化表的数量

--threads

启动的线程数量。

--time

运行时间

--report-interval

指定间隔定期报告

--auto_inc

是否启用自增主键,设为off使用随机主键

oltp_read_write

在 Sysbench目录下,自带有针对不同场景的测试用例,有oltp_read_write、oltp_read_only、oltp_write_only

02
测试读写


threads(线程)数分别设为2、4、8、16、32...... 测试到出现峰值

[root@mysql3 ~]# sysbench /usr/local/share/sysbench/oltp_read_write.lua --auto_inc=off --pgsql-host=127.0.0.1 --pgsql-port=1921 --pgsql-db=test --table_size=500000 --tables=20 --threads=2 --time=60 --report-interval=10 --pgsql-user=halo --pgsql-password=halotest --db-driver=pgsql run

记录QPS(每秒查询)和TPS(每秒事务),只读和只写都记录。








03
测试只读


hreads(线程)数分别设为2、4、8、16、32...... 测试到出现峰值


[root@mysql3 ~]# sysbench /usr/local/share/sysbench/oltp_read_only.lua --auto_inc=off --pgsql-host=127.0.0.1 --pgsql-port=1921 --pgsql-db=test --table_size=500000 --tables=20 --threads=2 --time=60 --report-interval=10 --pgsql-user=halo --pgsql-password=halotest --db-driver=pgsql run
04
测试只写


threads(线程)数分别设为2、4、8、16、32...... 测试到出现峰值



[root@mysql3 ~]# sysbench /usr/local/share/sysbench/oltp_write_only.lua --auto_inc=off --pgsql-host=127.0.0.1 --pgsql-port=1921 --pgsql-db=test --table_size=500000 --tables=20 --threads=2 --time=60 --report-interval=10 --pgsql-user=halo --pgsql-password=halotest --db-driver=pgsql run

总结

由于不同服务器、操作系统和软件版本的差异,压力测试的结果会有所不同。本次文档提供了通过 Sysbench 对数据库进行压力测试的方法,大家可以参考并测试自己的预生产数据库是否符合业务需求。

最后祝HaloDB越来越好!

END

往期推荐:






一家尊重用户的国产数据库厂商


国产数据库初体验——HaloDB安装


半年度总结:技术路上的光芒


救命!我的pg数据库被入侵了


Oracle RAC添加节点会遇到哪些问题?

在看点这里

原文作者:Digital Observer;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论
11年数据库行业经验,Oracle ACE、PG ACE、OCM、IBM Certified DBA、MySQL OCP、PolarDB技术专家、KCP、PCTP、PCSD、达梦师资认证、PolarDB开源社区技术顾问、ITPUB认证专家、某高校外聘教师

注册时间:2019-05-05

  • 博文量
    295
  • 访问量
    300730