oracle capability i/o(压力測试数据库serveri/o性能)

时间:2024-12-11 12:02:56

今天是2014-04-21,今天简单仅仅说明一下怎么影响重做数据的一个因素,那就是i/o吞吐量,oracle的介质恢复依赖于i/o,假设i/o存在瓶颈,那么势必会影响备库的介质恢复。

那么i/o stack包括hbas,存储相关的交换机、存储物理磁盘。那么oracle建议在应用程序部署的时候。建议去验证i/o避免存在问题。可是之前有一个非常刺手的问题,那就是怎样去验证i/o側吞吐量,换句话说怎么去验证i/o吞吐量更符合真实的生产环境。

In Oracle Database 11g, the Real Application Testing feature (Capture/Replay) was introduced to inject real (captured) workload into the system. However, another new 11g feature is available to help assess the I/O capability of the database's storage system,
and gauge maximum IOPS and Mbytes/s.

capability i/o feature 是根据一个数据库内部的函数(dbms_resource_manager.calibrateio()),该函数是oracle database内部集成的,更能满足測试i/o问题,且在最后将输出相关报告信息。

那么运行这个包须要注意什么呢?

1、权限,必须具有sysdba运行该过程的权限。另外须要打开timed_statistics。

2、确定异步i/o在数据库的全部数据文件和暂时文件都已经得到应用启动,我们能够通过v$datafile 和v$iostat_file视图关联进行、确认。

eg:

col name format a50

select name,asynch_io from v$datafile f,v$iostat_file i

where f.file#=i.file_no

and (filetype_name='Data File' or filetype_name='Temp File');

假设异步i/o没有启动,设置disk_asynch_io=true启动该功能,但默认是开启的。假设在linux中最大slots使用完成。那么将自己主动关闭噶 功能,这也就是为什么尽管设置了disk_asynch_io=true了却依旧没有达到效果。最大的slots能够查看/proc/sys/fs/aio-max-nr  当前使用的能够查看/proc/sys/fs/aio-nr去分别确认。

3、确保server仅仅有须要測试的数据库开启,避免 其它应用软件的影响。

4、对于RAC,须要确保全部的实例都开启,由于 将会对全部节点做全面的校对。运行该过程仅仅需在一个实例就可以。

5、确保仅仅有一个用户运行一个校对i/o的操作。

能够通过v$io_calibration_status查看当前鉴定状态。

另外查看资料了解到有这么几个过程:

The calibration will run in different phases. In the first phase, small block random I/O

workload is performed on each node and then concurrently on all nodes. The second

phase will generate large block sequential I/O on each node. Note, that the Calibrate

I/O is expecting that a datafile is spread across all disks specified in NUM_DISKS

variable. Furthermore, offline files are not considered for file I/O.

一旦运行完成,其结果将存在于dba_rsrc_io_calibrate表中。

好了。

了解到这些,以下開始去实验操作。让实践得真知。

语法例如以下:

SET SERVEROUTPUT ON

DECLARE

  lat  INTEGER;

  iops INTEGER;

  mbps INTEGER;

BEGIN

-- DBMS_RESOURCE_MANAGER.CALIBRATE_IO (<DISKS>, <MAX_LATENCY>, iops, mbps, lat);

   DBMS_RESOURCE_MANAGER.CALIBRATE_IO (2, 10, iops, mbps, lat);

 

  DBMS_OUTPUT.PUT_LINE ('max_iops = ' || iops);

  DBMS_OUTPUT.PUT_LINE ('latency  = ' || lat);

  DBMS_OUTPUT.PUT_LINE ('max_mbps = ' || mbps);

end;

/

參数介绍例如以下:

Parameter Description

num_physical_disks

 Approximate number of physical disks in the database storage(物理磁盘个数 input)

 

max_latency

 Maximum tolerable latency in milliseconds for database-block-sized IO requests(最大可用容忍延迟的毫秒数 input)

 

max_iops

 Maximum number of I/O requests per second that can be sustained. The I/O requests are randomly-distributed, database-block-sized reads.(持续中每秒请求最大i/o的数量 output)

 

max_mbps

 Maximum throughput of I/O that can be sustained, expressed in megabytes per second. The I/O requests are randomly-distributed, 1 megabyte reads.(持续中最大的吞吐量M为单位)

 

actual_latency

 Average latency of database-block-sized I/O requests at max_iops rate, expressed in milliseconds(平均延迟)

环境为oracle linux 6.4 +database 11.2.0.4(RAC 2节点 )+asm 11.2.0.4

对了。另外假设数据库使用的是asm,那么假设验证的死数据文件须要使用datadg中的全部物理磁盘,而不是fra中的物理磁盘。

尽管我使用存储化的lun进行的映射。可是

num_physical_disks必须是真实物理磁盘个数,由于是測试是一个磁盘。那么这个參数为1。

1、验证是否启动async i/o

[oracle@rac-one ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Apr 21 22:35:23 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options SQL> show parameter disk_asynch_io(查看数据库是否启用了异步i/o) NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
disk_asynch_io boolean TRUE
SQL> !
[oracle@rac-one ~]$ more /proc/sys/fs/aio-max-nr (系统slots最大数量)
1048576
[oracle@rac-one ~]$ more /proc/sys/fs/aio-nr (当前使用的slots)
23680
[oracle@rac-one ~]$ exit
exit SQL> col name for a50
SQL> set linesize 200
SQL> select name,asynch_io from v$datafile f,v$iostat_file i where f.file#=i.file_no and (filetype_name='Data File' or filetype_name='Temp File'); -------------(查看启用了async的文件信息) NAME ASYNCH_IO
-------------------------------------------------- ---------
+DATADG/rac/datafile/system.262.839537769 ASYNC_ON
+DATADG/rac/datafile/system.262.839537769 ASYNC_ON
+DATADG/rac/datafile/sysaux.263.839537911 ASYNC_ON
+DATADG/rac/datafile/undotbs1.264.839538031 ASYNC_ON
+DATADG/rac/datafile/undotbs2.266.839538155 ASYNC_ON
+DATADG/rac/datafile/users.267.839538199 ASYNC_ON 6 rows selected. SQL>
開始验证i/o: SQL> set serveroutput on
SQL> declare
2 lat integer;
3 iops integer;
4 mbps integer;
5 begin
6 --dbms_resource_manager.calibrate_io(<num_disks>,<max_latency>,iops,mbps,lat);
7 dbms_resource_manager.calibrate_io(1,10,iops,mbps,lat);
8 dbms_output.put_line('max_iops=' || iops);
9 dbms_output.put_line('latency=' || lat);
10 dbms_output.put_line('max_mbps=' || mbps);
11 end;
12 / 查看状态信息: SQL> select * from v$io_calibration_status; STATUS CALIBRATION_TIME
------------- ---------------------------------------------------------------------------
IN PROGRESS SQL> select file_no,small_read_megabytes,small_read_reqs,large_read_megabytes,large_read_reqs from v$iostat_file; FILE_NO SMALL_READ_MEGABYTES SMALL_READ_REQS LARGE_READ_MEGABYTES LARGE_READ_REQS
---------- -------------------- --------------- -------------------- ---------------
0 0 24 0 0
0 107 6819 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 40 4808 884 901 FILE_NO SMALL_READ_MEGABYTES SMALL_READ_REQS LARGE_READ_MEGABYTES LARGE_READ_REQS
---------- -------------------- --------------- -------------------- ---------------
1 0 4 0 0
2 28 2515 777 779
3 5 577 351 351
4 3 404 264 264

可知正在进行測试中:

运行结束将输出结果例如以下:

SQL> declare
2 lat integer;
3 iops integer;
4 mbps integer;
5 begin
6 --dbms_resource_manager.calibrate_io(<num_disks>,<max_latency>,iops,mbps,lat);
7 dbms_resource_manager.calibrate_io(1,10,iops,mbps,lat);
8 dbms_output.put_line('max_iops=' || iops);
9 dbms_output.put_line('latency=' || lat);
10 dbms_output.put_line('max_mbps=' || mbps);
11 end;
12 /
max_iops=45
latency=42
max_mbps=12 PL/SQL procedure successfully completed. SQL>

能够知道这两个节点请求小块读为45。最大吞吐量为12M/s。虚拟机就是卡的掉渣。