Oracle 基准测试 SLOB(Silly Little
OracleBenchmark)可以使用简单的数据库操作来模拟负载,然后根据分配给数据库的 SGA 大小,测试
CPU、内存(逻辑 I/O)和存储(物理 I/O)。该工具通过索引范围扫描和数据块查找来模拟整个过程。
SLOB 支持的测试类型具体如下
·支持 Oracle 逻辑读。
·支持物理随机单块读取(按数据文件顺序读取)。
·支持随机单块写入。
·支持大量 redo 日志写入。
SLOB 下载地址为 https://kevinclosson.net/slob/。进行 SLOB 测试的前提条件具体如下。
进行 SLOB 测试的前提条件具体如下
·需要创建测试表空间,用于容纳SLOB初始化创建的对象。
·运行初始化setup.sh,默认空间要求大小约为15GB。
·将system用户密码修改为manager。
1.1、下载软件
https://kevinclosson.net/slob/https://github.com/therealkevinc/SLOB_2.5.4.git

1.2、软件上传解压
MD5SUM:9105afd8de3c75c65b54141ece71203e 2021.05.12.slob_2.5.4.0.tar.gzunzip SLOB_2.5.4-main.zipcd SLOB_2.5.4-main/tar -zxvf 2021.05.12.slob_2.5.4.0.tar.gzcd SLOB/pwd/home/oracle/tmp/SLOB_2.5.4-main/SLOB

1.3、准备新建表空间 OLTP 和修改 system 用户密码
修改 system 密码为 manager,创建表空间 OLTP 大小 15GB。
然后运行初始化脚本的命令如下:
SQL> alter user system identified by manager;SQL> create tablespace OLTP datafile '+DATA' size 15G;
1.4、初始化环境
$sh setup.sh OLTP 20
OLTP 是用于压力测试而创建的表空间名字,20 表示需要创建的用户数量(默认是128)然后便会创建 20 个用户和表数据。

NOTIFY : 2022.05.25-16:55:20 : Begin SLOB 2.5.4.0 setup.NOTIFY : 2022.05.25-16:55:20 : ADMIN_CONNECT_STRING: "system/manager"NOTIFY : 2022.05.25-16:55:20 : Load parameters from slob.conf:SCALE: 80M (10240 blocks)SCAN_TABLE_SZ: 1M (128 blocks)LOAD_PARALLEL_DEGREE: 2ADMIN_SQLNET_SERVICE: ""SYSDBA_PASSWD: "manager"DBA_PRIV_USER: "system"Note: setup.sh will use the following connect strings as per slob.conf:Admin Connect String: "system/manager"Non-Admin Connect String: " "NOTIFY : 2022.05.25-16:55:20 : Testing Admin connect using "sqlplus -L system/manager"FATAL : 2022.05.25-16:55:21 : Cannot create tables in user-specified tablespace ("OLTP")FATAL : 2022.05.25-16:55:21 : See /home/oracle/tmp/SLOB_2.5.4-main/SLOB/cr_tab_and_load.outt4-rac19c-71:/home/oracle/tmp/SLOB_2.5.4-main/SLOB(jxrt4db1)$t4-rac19c-71:/home/oracle/tmp/SLOB_2.5.4-main/SLOB(jxrt4db1)$ sh setup.sh OLTP 20NOTIFY : 2022.05.25-16:59:03 : Begin SLOB 2.5.4.0 setup.NOTIFY : 2022.05.25-16:59:03 : ADMIN_CONNECT_STRING: "system/manager"NOTIFY : 2022.05.25-16:59:03 : Load parameters from slob.conf:SCALE: 80M (10240 blocks)SCAN_TABLE_SZ: 1M (128 blocks)LOAD_PARALLEL_DEGREE: 2ADMIN_SQLNET_SERVICE: ""SYSDBA_PASSWD: "manager"DBA_PRIV_USER: "system"Note: setup.sh will use the following connect strings as per slob.conf:Admin Connect String: "system/manager"Non-Admin Connect String: " "NOTIFY : 2022.05.25-16:59:03 : Testing Admin connect using "sqlplus -L system/manager"NOTIFY : 2022.05.25-16:59:04 : Dropping prior SLOB schemas. This may take a while if there is a large number of old schemas.NOTIFY : 2022.05.25-16:59:04 : Previous SLOB schemas have been removedNOTIFY : 2022.05.25-16:59:04 : Preparing to load 20 schema(s) into tablespace: OLTPNOTIFY : 2022.05.25-16:59:04 : Loading user1 schemaNOTIFY : 2022.05.25-16:59:11 : Finished loading and indexing user1 schema in 7 secondsNOTIFY : 2022.05.25-16:59:11 : Commencing multiple, concurrent schema creation and loadingNOTIFY : 2022.05.25-16:59:11 : Waiting for background batch 1. Loading up to user3NOTIFY : 2022.05.25-16:59:13 : Finished background batch 1. Loading and index creation complete : 2 secondsNOTIFY : 2022.05.25-16:59:14 : Waiting for background batch 2. Loading up to user5NOTIFY : 2022.05.25-16:59:15 : Finished background batch 2. Loading and index creation complete : 1 secondsNOTIFY : 2022.05.25-16:59:16 : Waiting for background batch 3. Loading up to user7NOTIFY : 2022.05.25-16:59:18 : Finished background batch 3. Loading and index creation complete : 2 secondsNOTIFY : 2022.05.25-16:59:18 : Waiting for background batch 4. Loading up to user9NOTIFY : 2022.05.25-16:59:20 : Finished background batch 4. Loading and index creation complete : 2 secondsNOTIFY : 2022.05.25-16:59:20 : Waiting for background batch 5. Loading up to user11NOTIFY : 2022.05.25-16:59:22 : Finished background batch 5. Loading and index creation complete : 2 secondsNOTIFY : 2022.05.25-16:59:23 : Waiting for background batch 6. Loading up to user13NOTIFY : 2022.05.25-16:59:24 : Finished background batch 6. Loading and index creation complete : 1 secondsNOTIFY : 2022.05.25-16:59:25 : Waiting for background batch 7. Loading up to user15NOTIFY : 2022.05.25-16:59:26 : Finished background batch 7. Loading and index creation complete : 1 secondsNOTIFY : 2022.05.25-16:59:27 : Waiting for background batch 8. Loading up to user17NOTIFY : 2022.05.25-16:59:29 : Finished background batch 8. Loading and index creation complete : 2 secondsNOTIFY : 2022.05.25-16:59:29 : Waiting for background batch 9. Loading up to user19NOTIFY : 2022.05.25-16:59:31 : Finished background batch 9. Loading and index creation complete : 2 secondsNOTIFY : 2022.05.25-16:59:31 : Waiting for background batch 10. Loading up to user20NOTIFY : 2022.05.25-16:59:33 : Finished background batch 10. Loading and index creation complete : 2 secondsNOTIFY : 2022.05.25-16:59:33 : Completed concurrent data loading phase: 22 secondsNOTIFY : 2022.05.25-16:59:33 : Creating SLOB UPDATE procedureNOTIFY : 2022.05.25-16:59:34 : SLOB UPDATE procedure (./misc/procedure.sql) created.NOTIFY : 2022.05.25-16:59:34 : Row and block counts for SLOB table(s) reported in ./slob_data_load_summary.txtNOTIFY : 2022.05.25-16:59:34 : Please examine ./slob_data_load_summary.txt for any possible errorsNOTIFY : 2022.05.25-16:59:34 :NOTIFY : 2022.05.25-16:59:34 : NOTE: No errors detected but if ./slob_data_load_summary.txt shows errors thenNOTIFY : 2022.05.25-16:59:34 : examine /home/oracle/tmp/SLOB_2.5.4-main/SLOB/cr_tab_and_load.outNOTIFY : 2022.05.25-16:59:34 : SLOB setup complete. Total setup time: (31 seconds)NOTIFY : 2022.05.25-16:59:34 : Please do not forget to compile the wait kit.NOTIFY : 2022.05.25-16:59:34 : Please change directories to ./wait_kit and execute make(1).NOTIFY : 2022.05.25-16:59:34 : Example:NOTIFY : 2022.05.25-16:59:34 : $ cd ./wait_kitNOTIFY : 2022.05.25-16:59:34 : $ make
根据提示编译工具包,命令如下:
cd ./wait_kitmakerm -fr *.o mywait trigger create_semcc -c -o mywait.o mywait.ccc -o mywait mywait.occ -c -o trigger.o trigger.ccc -o trigger trigger.occ -c -o create_sem.o create_sem.ccc -o create_sem create_sem.ocp mywait trigger create_sem ../rm -fr *.o
这里创建了user0-user20 共 21 个用户,每个用户下均有两张表 CF1、CF2,每张表有 10240 行,每个表有 20 列,ID 列为 NUMBER(15),其他列为 VARCHAR2(128) ,表上无任何索引。
select owner,table_name from dba_tables where owner like 'USER%' order by 1;select USERNAME,ACCOUNT_STATUS,CREATED,DEFAULT_TABLESPACE from dba_users where account_status='OPEN' and username like 'USER%' order by CREATED asc;select count(*) from user2.CF1;COUNT(*)----------10240SQL> desc user2.CF1;Name Null? Type----------------------------------------------------------------- -------- --------------------------------------------CUSTID NUMBER(15)C2 VARCHAR2(128)C3 VARCHAR2(128)C4 VARCHAR2(128)C5 VARCHAR2(128)C6 VARCHAR2(128)C7 VARCHAR2(128)C8 VARCHAR2(128)C9 VARCHAR2(128)C10 VARCHAR2(128)C11 VARCHAR2(128)C12 VARCHAR2(128)C13 VARCHAR2(128)C14 VARCHAR2(128)C15 VARCHAR2(128)C16 VARCHAR2(128)C17 VARCHAR2(128)C18 VARCHAR2(128)C19 VARCHAR2(128)C20 VARCHAR2(128)
[object Object]
默认情况下,setup.sh执行时应读取slob.conf配置文件。
1.5、修改 slob.conf 配置文件
runit.sh 脚本是性能测试驱动程序,默认情况下使用的是 slob.conf 中的参数设置,如果有需要,则可以使用命令行或直接修改 slob.conf 配置文件,重点参数列举如下。
·UPDATE_PCT=10:DML(Data ManipulationLanguage,数据操纵语言)占比,默认为10%。
·SCALE=10000:数据加载大小,默认为 10000 block。
·SCAN_TABLE_SZ=1M:单个测试表格的大小。
·LOAD_PARALLEL_DEGREE=2:数据加载并发量。
·RUN_TIME=300:测试时间,默认为 5min,超过时间会自动结束。
·DATABASE_STATISTICS_TYPE=awr :数据库统计报告,默认是 sp 报告,这里选择 awr。
可以根据不同的测试场景修改配置文件 slob.conf 的参数。
cat slob.conf | grep -v '^#'| grep -v '^$'UPDATE_PCT=10SCAN_PCT=0RUN_TIME=300WORK_LOOP=0SCALE=10000 ---新版本这里设置80M会报错,默认是 10000 blockSCAN_TABLE_SZ=1MWORK_UNIT=64REDO_STRESS=LITELOAD_PARALLEL_DEGREE=2THREADS_PER_SCHEMA=1DATABASE_STATISTICS_TYPE=awr # Permitted values: [statspack|awr]EXTERNAL_SCRIPT=""DO_HOTSPOT=FALSEHOTSPOT_MB=8HOTSPOT_OFFSET_MB=16HOTSPOT_FREQUENCY=3HOT_SCHEMA_FREQUENCY=0THINK_TM_FREQUENCY=0THINK_TM_MIN=.1THINK_TM_MAX=.5

1.6、SLOB 测试命令示例
SLOB执行测试的命令如下:
Single Option Invocation 单一选项调用
$ sh runit.sh
Multiple Option Invocation 多个选项调用
$ sh runit.sh -s-t
注意:单选项调用使用 slob.conf->THREADS_PER_SCHEMA。 如果你
在 SLOB.conf 中设置 THREADS_PER_SCHEMA,每个模式需要多个 SLOB 线程。
slob.conf->THREADS_PER_SCHEMA 的默认设置是 1。
使用多选项调用 slob.conf-> 覆盖 THREADS_PER_SCHEMA。
每个模式的 SLOB 线程数取自传递的参数与 -t 选项一起。
例子:
例1、256 个 SLOB 模式,每个模式带有 SLOB .conf->THREADS_PER_SCHEMA 编号
每个模式的 SLOB 线程数:
$ sh runit.sh 256
例2、16 个 SLOB 模式,每个模式有 32 个 SLOB 线程:
$ sh runit.sh -s 16 -t 32
注意:例 2 产生 512(16*32) 个 Oracle 数据库会话。更多详细信息请查看官方文档 ./SLOB_2.5.4-main/SLOB/doc/SLOB-2.5.0_README.pdf
1.7、模拟 512 个会话进行压测 5 分钟
$ sh runit.sh -s 16 -t 32$ sh runit.sh -s 21 -t 30
$ sh runit.sh -s 16 -t 32NOTIFY : 2022.05.25-18:31:23 : For security purposes all file and directory creation and deletionsNOTIFY : 2022.05.25-18:31:23 : performed by runit.sh are logged in: /home/oracle/tmp/SLOB_2.5.4-main/SLOB/.file_operations_audit_trail.out.NOTIFY : 2022.05.25-18:31:23 : SLOB TEMPDIR is /tmp/.SLOB.2022.05.25.183123. SLOB will delete this directory at the end of this execution.NOTIFY : 2022.05.25-18:31:23 : Sourcing in slob.confNOTIFY : 2022.05.25-18:31:23 : Performing initial slob.conf sanity check...NOTIFY : 2022.05.25-18:31:23 :NOTIFY : 2022.05.25-18:31:23 : SQLNET_SERVICE_BASE is not set. Users will connect via bequeth connections (not SQL*Net).NOTIFY : 2022.05.25-18:31:23 : Connecting to the instance to validate slob.conf->SCALE setting.UPDATE_PCT: 10SCAN_PCT: 0RUN_TIME: 300WORK_LOOP: 0SCALE: 10000 (10000 blocks)WORK_UNIT: 64REDO_STRESS: LITEHOT_SCHEMA_FREQUENCY: 0HOTSPOT_MB: 8HOTSPOT_OFFSET_MB: 16HOTSPOT_FREQUENCY: 3THINK_TM_FREQUENCY: 0THINK_TM_MIN: .1THINK_TM_MAX: .5DATABASE_STATISTICS_TYPE: awrSYSDBA_PASSWD: "manager"DBA_PRIV_USER: "system"ADMIN_SQLNET_SERVICE: ""SQLNET_SERVICE_BASE: ""SQLNET_SERVICE_MAX: ""EXTERNAL_SCRIPT: ""THREADS_PER_SCHEMA: 32 (-t option)Note: runit.sh will use the following connect strings as per slob.conf settings:Admin Connect String: "system/manager"NOTIFY : 2022.05.25-18:31:24 : Clearing temporary SLOB output files from previous SLOB testing.NOTIFY : 2022.05.25-18:31:24 : Testing admin connectivity to the instance to validate slob.conf settings.NOTIFY : 2022.05.25-18:31:24 : Testing connectivity. Command: "sqlplus -L system/manager".NOTIFY : 2022.05.25-18:31:25 : Next, testing 16 user (non-admin) connections...NOTIFY : 2022.05.25-18:31:25 : Testing connectivity. Command: "sqlplus -L user1/user1".NOTIFY : 2022.05.25-18:31:25 : Testing connectivity. Command: "sqlplus -L user16/user16".NOTIFY : 2022.05.25-18:31:25 : Performing redo log switch.NOTIFY : 2022.05.25-18:31:25 : Redo log switch complete. Setting up trigger mechanism.NOTIFY : 2022.05.25-18:31:35 : Running iostat, vmstat and mpstat on current host--in background.NOTIFY : 2022.05.25-18:31:35 : Connecting 32 (THREADS_PER_SCHEMA) session(s) to 16 schema(s) ...NOTIFY : 2022.05.25-18:31:43 : Saved pids of monitored sqlplus processes in: /tmp/.SLOB.2022.05.25.183123/sqlplus_pids.txtNOTIFY : 2022.05.25-18:31:43 : Pausing for 2 seconds before triggering the test.NOTIFY : 2022.05.25-18:31:46 : Executing awr "before snap" procedure. Command: "sqlplus -S -L system/manager".NOTIFY : 2022.05.25-18:31:54 : Before awr snap ID is 293NOTIFY : 2022.05.25-18:31:54 : Test has been triggered.NOTIFY : 2022.05.25-18:32:19 : Waiting for 290 seconds before monitoring running processes (for exit).NOTIFY : 2022.05.25-18:37:09 : Entering process monitoring loop.NOTIFY : 2022.05.25-18:37:19 : There are 509 sqlplus processes remaining.NOTIFY : 2022.05.25-18:37:29 : There are 267 sqlplus processes remaining.NOTIFY : 2022.05.25-18:37:39 : There are 135 sqlplus processes remaining.NOTIFY : 2022.05.25-18:37:46 : Run time 352 seconds.NOTIFY : 2022.05.25-18:37:47 : Executing awr "after snap" procedure. Command: "sqlplus -S -L system/manager".NOTIFY : 2022.05.25-18:37:59 : After awr snap ID is 294NOTIFY : 2022.05.25-18:37:59 : Terminating background data collectors.runit.sh: line 1548: 24519 Killed ( mpstat -P ALL 3 > mpstat.out 2>&1 )runit.sh: line 1548: 24517 Killed ( iostat -t -xm 3 > iostat.out 2>&1 )runit.sh: line 1548: 24518 Killed ( vmstat -t 3 > vmstat.out 2>&1 )NOTIFY : 2022.05.25-18:38:33 :NOTIFY : 2022.05.25-18:38:33 : SLOB test is complete.NOTIFY : 2022.05.25-18:38:33 : Cleaning up SLOB temporary directory (/tmp/.SLOB.2022.05.25.183123).
压测期间 Top 命令截图

$ sh runit.sh -s 20 -t 30 如下是使用 600 个并发会话压测 30 分钟的 top 截图。

SLOB 执行前会创建快照点,如上述代码段所示。293、294 为我本次的快照点,结束后会在当前目录下生成 I/O 的测试结果信息
awr.html.gz、awr_rac.html.gz、mpstat.out、iostat.out 和 vmstat.out。
解压 awr 报告下载到本地查看相关信息。
gunzip awr.html.gzgunzip awr.html.gz--------------------------------------------------------------------------------rw-r--r-- 1 oracle oinstall 1665720 May 25 18:46 awr.html-rw-r--r-- 1 oracle oinstall 423815 May 25 18:46 awr.txt-rw-r--r-- 1 oracle oinstall 1415483 May 25 18:46 awr_rac.html-rw-r--r-- 1 oracle oinstall 344105 May 25 18:46 awr_rac.txt-rw-r--r-- 1 oracle oinstall 204399 May 25 18:46 iostat.out-rw-r--r-- 1 oracle oinstall 123388 May 25 18:47 mpstat.out-rw-r--r-- 1 oracle oinstall 7 May 25 18:46 tm.out-rw-r--r-- 1 oracle oinstall 15239 May 25 18:47 vmstat.out-------------------------------------------------------------------------------
awr 截图



iostat 截图

vmstat 截图

mpstat 截图

1.8、脚本执行期间的错误
错误1:
FATAL : 2022.05.25-17:23:25 : The value assigned to slob.conf->SCALE (80M [5120]) is an illegal value.FATAL : 2022.05.25-17:23:25 : Illegal SCALE value. Mininum supported value is 10000 blocks.
解决办法:修改 slob.conf 配置文件中 SCALE 的值为 10000
错误2:
ERROR:ORA-00020: maximum number of processes (640) exceeded
解决办法:最大连接数默认 640,一下子就压到 640 导致超了最大连接数,修改数据库最大连接数为 2000 并重启数据库。
错误3:
FATAL : 2022.05.25-17:35:33 : f_snap_database_stats: EXEC PERFSTAT.STATSPACK.SNAP failed. Error output follows: :SNAP := STATSPACK.SNAP; *ERROR at line 2:ORA-06550: line 2, column 11:PLS-00201: identifier 'STATSPACK.SNAP' must be declaredORA-06550: line 2, column 2:PL/SQL: Statement ignored
解决办法:slob.conf 参数使用了默认生成 statspack 报告,修改 slob.conf 配置文件参数为 DATABASE_STATISTICS_TYPE=awr,让其生成 AWR 报告即可。
好了,本次就先这样吧,swingbench 等其他工具有机会在尝试吧,欢迎一起来讨论。全文完,希望可以帮到正在阅读的你,如果觉得有帮助,可以分享给你身边的朋友,同事,你关心谁就分享给谁,一起学习共同进步~~~
❤️ 欢迎关注我的公众号,来一起玩耍吧!!!
————————————————————————————
公众号:JiekeXu DBA之路
墨天轮:https://www.modb.pro/u/4347
CSDN :https://blog.csdn.net/JiekeXu
腾讯云:https://cloud.tencent.com/developer/user/5645107
————————————————————————————

Oracle 表碎片检查及整理方案
2021 年公众号历史文章合集整理
2020 年公众号历史文章合集整理
我的 2021 年终总结和 2022 展望
Oracle 19c RAC 遇到的几个问题
Oracle 查询表空间使用率超慢问题一则
国产数据库|TiDB 5.4 单机快速安装初体验
Oracle ADG 备库停启维护流程及增量恢复
Linux 环境搭建 MySQL8.0.28 主从同步环境
Oracle 19c 使用数据泵如何导入导出 PDB 用户
