暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

SysBench简单安装测试

原创 小草 2024-04-17
221

一、安装

[root@observer3-2 ~]# yum install make automake autoconf libtool gcc mariadb-devel mariadb -y

本次环境已经安装jdk1.8

[root@observer3-2 ~]# yum install java-1.8.0-openjdk.x86_64 -y

[admin@observer3-2 app]$ wget https://github.com/akopytov/sysbench/archive/refs/tags/1.0.20.zip

[admin@observer3-2 app]$ unzip 1.0.20.zip

[admin@observer3-2 app]$ cd sysbench-1.0.20/

[admin@observer3-2 sysbench-1.0.20]$ ./autogen.sh

[admin@observer3-2 sysbench-1.0.20]$ ./configure --prefix=/usr/sysbench/ --with-mysql-includes=/usr/include/mysql/ --with-mysql-libs=/usr/lib64/mysql/ --with-mysql

[admin@observer3-2 sysbench-1.0.20]$ make

[root@observer3-2 sysbench-1.0.20]# make install

[root@observer3-2 sysbench-1.0.20]# cp -r /usr/sysbench/share/sysbench/* /usr/sysbench/bin/

[admin@observer3-2 sysbench-1.0.20]$ ./src/sysbench --help

参数说明:

参数名

说明

--prefix

指定 Sysbench 的安装目录。

--with-mysql-includes

指定 mysql 的 includes 目录。

--with-mysql-libs

指定 mysql 的 lib 目录。

--with-mysql

Sysbench 默认支持 MySQL

二、手动进行Sysbench测试

2.1 环境调优

observer调优

ALTER system SET enable_sql_audit=false;

ALTER system SET enable_perf_event=false;

ALTER system SET syslog_level='PERF';

alter system set enable_record_trace_log=false;

2.2 操作步骤

1.运行以下命令,初始化数据库

/usr/sysbench/bin/sysbench oltp_read_write.lua --mysql-host=192.168.220.117 --mysql-port=2881 --mysql-db=test --mysql-user=root@obcp_t1 --mysql-password=LIUjie\!\@34 --table_size=1000000 --tables=30 --threads=150 --report-interval=10 --rand-type=uniform --time=60 cleanup

2.运行以下命令,新建表

/usr/sysbench/bin/sysbench oltp_read_write.lua --mysql-host=192.168.220.117 --mysql-port=2881 --mysql-db=test --mysql-user=root@obcp_t1 --mysql-password=LIUjie\!\@34 --table_size=1000000 --tables=30 --threads=150 --report-interval=10 --rand-type=uniform --time=60 prepare

3.运行以下命令,执行测试

/usr/sysbench/bin/sysbench oltp_read_write.lua --mysql-host=192.168.220.117 --mysql-port=2881 --mysql-db=test --mysql-user=root@obcp_t1 --mysql-password=LIUjie\!\@34 --table_size=100000 --tables=30 --threads=150 --report-interval=10 --time=60 --rand-type=uniform --db-ps-mode=disable run

[admin@ocp3 lua]$ /usr/sysbench/bin/sysbench oltp_read_write.lua --mysql-host=192.168.220.117 --mysql-port=2881 --mysql-db=test --mysql-user=root@obcp_t1 --mysql-password=LIUjie\!\@34 --table_size=100000 --tables=30 --threads=150 --report-interval=10 --time=60 --rand-type=uniform --db-ps-mode=disable run

sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:

Number of threads: 150

Report intermediate results every 10 second(s)

Initializing random number generator from current time

Initializing worker threads...

Threads started!

[ 10s ] thds: 150 tps: 0.39 qps: 280.90 (r/w/o: 206.98/58.55/15.38) lat (ms,95%): 10158.80 err/s: 0.00 reconn/s: 0.00

[ 20s ] thds: 150 tps: 29.80 qps: 530.70 (r/w/o: 405.30/65.71/59.69) lat (ms,95%): 10722.67 err/s: 0.00 reconn/s: 0.00

[ 30s ] thds: 150 tps: 30.01 qps: 598.26 (r/w/o: 418.38/119.75/60.13) lat (ms,95%): 5709.50 err/s: 0.00 reconn/s: 0.00

[ 40s ] thds: 150 tps: 30.09 qps: 584.77 (r/w/o: 402.91/121.77/60.09) lat (ms,95%): 5124.81 err/s: 0.00 reconn/s: 0.00

[ 50s ] thds: 150 tps: 29.73 qps: 565.24 (r/w/o: 390.46/115.22/59.56) lat (ms,95%): 6594.16 err/s: 0.00 reconn/s: 0.00

[ 60s ] thds: 150 tps: 30.48 qps: 648.62 (r/w/o: 458.04/129.62/60.95) lat (ms,95%): 5312.73 err/s: 0.00 reconn/s: 0.00

SQL statistics:

queries performed:

read: 23156

write: 6616

other: 3308

total: 33080

transactions: 1654 (26.71 per sec.)

queries: 33080 (534.13 per sec.)

ignored errors: 0 (0.00 per sec.)

reconnects: 0 (0.00 per sec.)

General statistics:

total time: 61.9296s

total number of events: 1654

Latency (ms):

min: 1808.67

avg: 5541.98

max: 10974.40

95th percentile: 10343.39

sum: 9166431.27

Threads fairness:

events (avg/stddev): 11.0267/0.16

execution time (avg/stddev): 61.1095/0.34

参数配置

参数名

说明

--mysql-host

运行 OceanBase 数据库机器的 IP。如果有 ODP 建议使用 ODP 的 IP。

--mysql-port

端口号。

--mysql-db

待连接的数据库。

--mysql-user

用户名。

--mysql-password

密码。

--table_size

每张表初始化的数据数量。

--tables

初始化表的数量。

--threads

启动的线程数量。

--time

运行时间。设置为

0

时表示不限制时间。

--report-interval

运行期间日志,单位为秒。

--events

最大请求数量,定义数量后可以不需要 --time 选项。

--rand-type

访问数据时使用的随机生成函数。取值可以为

special

uniform

gaussian

pareto

。 默认值为

special

, 早期值为

uniform

--skip_trx=on

在只读测试中打开或关闭事务。默认打开。

--percentile=N

打印百分位 rt,默认值为

95

oltp_write_only

在 Sysbench 的 lua 目录下,自带有针对不同场景的测试用例,比如 insert 和 point_select 等。

三、报错

报错1

image.png

解决:

[admin@ocp3 sysbench-1.0.20]$ cd src

[admin@ocp3 src]$ ls

CMakeLists.txt Makefile sb_ck_pr.h sb_histogram.h sb_lua.c sb_rand.c sb_timer.c sb_win.c tests

db_driver.c Makefile.am sb_counter.c sb_histogram.o sb_lua.h sb_rand.h sb_timer.h sb_win.h xoroshiro128plus.h

db_driver.h Makefile.in sb_counter.h sb_list.h sb_lua.o sb_rand.o sb_timer.o sysbench

db_driver.o sb_barrier.c sb_counter.o sb_logger.c sb_options.c sb_thread.c sb_util.c sysbench.c

drivers sb_barrier.h sb_global.h sb_logger.h sb_options.h sb_thread.h sb_util.h sysbench.h

lua sb_barrier.o sb_histogram.c sb_logger.o sb_options.o sb_thread.o sb_util.o sysbench.o

[admin@ocp3 src]$ cd lua/

[admin@ocp3 lua]$ ls

bulk_insert.lua Makefile.am oltp_delete.lua oltp_read_only.lua oltp_update_non_index.lua select_random_ranges.lua

internal Makefile.in oltp_insert.lua oltp_read_write.lua oltp_write_only.lua

Makefile oltp_common.lua oltp_point_select.lua oltp_update_index.lua select_random_points.lua

[admin@ocp3 lua]$ ./oltp_read_write.lua

sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

FATAL: ./oltp_common.lua:28: Command is required. Supported commands: prepare, prewarm, run, cleanup, help

报错2

image.png

解决

obclient [(none)]> show variables like '%timeout%';

+---------------------+------------------+

| Variable_name | Value |

+---------------------+------------------+

| connect_timeout | 10 |

| interactive_timeout | 28800 |

| lock_wait_timeout | 31536000 |

| net_read_timeout | 30 |

| net_write_timeout | 60 |

| ob_pl_block_timeout | 3216672000000000 |

| ob_query_timeout | 10000000 |

| ob_trx_idle_timeout | 120000000 |

| ob_trx_lock_timeout | -1 |

| ob_trx_timeout | 100000000 |

| wait_timeout | 28800 |

+---------------------+------------------+

11 rows in set (0.019 sec)

obclient [(none)]> set global ob_query_timeout=10000000000000;

Query OK, 0 rows affected (0.322 sec)

obclient [(none)]> set global ob_trx_idle_timeout=20000000000;

Query OK, 0 rows affected (0.055 sec)

obclient [(none)]> set global ob_trx_timeout=18000000000;

Query OK, 0 rows affected (0.108 sec)

解决之后,删除重建

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论