课程目标:
- 监控RMAN Jobs
- 配置异步I/O
- 配置多路复用
- 平衡备份速度和恢复速度
- MAXPIECESIZE,FILESPERSET,MAXOPENFILES对RMAN性能的影响
- BACKUP DURATION选项
1、备份集并行度
可以在CONFIGURE命令中设置PARALLELISM选项配置并行备份,也可以手工分配多个通道进行并行备份,指定文件到特定的通道。
RMAN> RUN {
2> ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
3> ALLOCATE CHANNEL c2 DEVICE TYPE sbt;
4> ALLOCATE CHANNEL c3 DEVICE TYPE sbt;
5> BACKUP
6> INCREMENTAL LEVEL = 0
7> (DATAFILE 1,4,5 CHANNEL c1)
8> (DATAFILE 2,3,9 CHANNEL c2)
9> (DATAFILE 6,7,8 CHANNEL c3);
10> SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
11> }
当备份数据文件,可以指定数据文件名称或者数据文件编号,例如:
BACKUP DEVICE TYPE sbt DATAFILE '/home/oracle/system01.dbf';
BACKUP DEVICE TYPE sbt DATAFILE 1;
当分配多个通道创建多个备份集时,RMAN自动并行写入到备份集。
例子:并行备份,指定文件使用某个通道
RMAN> report schema;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name STONE
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 910 SYSTEM *** /u01/app/oracle/oradata/STONE/datafile/o1_mf_system_cb1769f2_.dbf
2 890 SYSAUX *** /u01/app/oracle/oradata/STONE/datafile/o1_mf_sysaux_cb1769f6_.dbf
3 115 UNDOTBS1 *** /u01/app/oracle/oradata/STONE/datafile/o1_mf_undotbs1_cb1769ff_.dbf
4 7 USERS *** /u01/app/oracle/oradata/STONE/datafile/user01.dbf
5 346 EXAMPLE *** /u01/app/oracle/oradata/STONE/datafile/o1_mf_example_cb1769f9_.dbf
6 10 TEST_INDEX *** /u01/app/oracle/oradata/STONE/datafile/o1_mf_test_ind_cb178or2_.dbf
7 15 RCAT_TS *** /u01/app/oracle/oradata/STONE/datafile/o1_mf_rcat_ts_cb178oqs_.dbf
RMAN> run{
2> allocate channel c1 device type disk;
3> allocate channel c2 device type disk;
4> allocate channel c3 device type disk;
5> backup
6> incremental level=0
7> (datafile 1 channel c1)
8> (datafile 2 channel c2)
9> (datafile 3,4,5,6,7 channel c3);
10> sql 'alter system archive log current';}
released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=19 device type=DISK
allocated channel: c2
channel c2: SID=45 device type=DISK
allocated channel: c3
channel c3: SID=51 device type=DISK
Starting backup at 21-JAN-16
channel c1: starting incremental level 0 datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/STONE/datafile/o1_mf_system_cb1769f2_.dbf
channel c1: starting piece 1 at 21-JAN-16
channel c2: starting incremental level 0 datafile backup set
channel c2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/STONE/datafile/o1_mf_sysaux_cb1769f6_.dbf
channel c2: starting piece 1 at 21-JAN-16
channel c3: starting incremental level 0 datafile backup set
channel c3: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/STONE/datafile/o1_mf_example_cb1769f9_.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/STONE/datafile/o1_mf_undotbs1_cb1769ff_.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/STONE/datafile/o1_mf_rcat_ts_cb178oqs_.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/STONE/datafile/o1_mf_test_ind_cb178or2_.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/STONE/datafile/user01.dbf
channel c3: starting piece 1 at 21-JAN-16
channel c3: finished piece 1 at 21-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_21/o1_mf_nnnd0_TAG20160121T175149_cb1bkphw_.bkp tag=TAG20160121T175149 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:35
channel c1: finished piece 1 at 21-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_21/o1_mf_nnnd0_TAG20160121T175149_cb1bkpjc_.bkp tag=TAG20160121T175149 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:55
channel c2: finished piece 1 at 21-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_21/o1_mf_nnnd0_TAG20160121T175149_cb1bkpfg_.bkp tag=TAG20160121T175149 comment=NONE
channel c2: backup set complete, elapsed time: 00:01:55
Finished backup at 21-JAN-16
Starting Control File and SPFILE Autobackup at 21-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/STONE/autobackup/2016_01_21/o1_mf_s_901734825_cb1bo9o5_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 21-JAN-16
sql statement: alter system archive log current
released channel: c1
released channel: c2
released channel: c3
实际测试表明,如果备份设备是带库,并行通道数等于带库中带机的数量会达到最佳的性能。需要注意的是,如果并行通道数多于带机数,会出现Backupset在多盘磁带混合存放的情况因而会影响到恢复的速度。
如果备份到磁盘,并行通道数等于磁盘子系统的数量时会达到最佳的性能,磁盘子系统数量指的是输出设备跨几块磁盘。例如磁盘子系统分布在3块物理硬盘上,则应分配3个通道。
2、监控RMAN会话
通过V$SESSION和V$PROCESS,可以查询RMAN通道对应的服务器会话,V$PROCESS的SPID字段显示操作系统进程或者线程ID。在UNIX平台,SPID表示进程ID,在Windows平台,SPID表示线程ID。
当只有一个RMAN会话活动时,执行下面语句查询:
SQL> COLUMN CLIENT_INFO FORMAT a30
SQL> COLUMN SID FORMAT 999
SQL> COLUMN SPID FORMAT 9999
SQL> SELECT s.sid, p.spid, s.client_info
2 FROM v$process p, v$session s
3 WHERE p.addr = s.paddr
4 AND CLIENT_INFO LIKE 'rman%';
SID SPID CLIENT_INFO
---- ------------ ------------------------------
15 2714 rman channel=ORA_SBT_TAPE_1
13 2715 rman channel=ORA_SBT_TAPE_2
当有多个RMAN会话运行时,通过使用SET COMMAND ID命令关联进程和通道,如下:
(1)在每一个会话设置COMMAND ID为不同的值,例如在会话1:
RUN
{
SET COMMAND ID TO 'sess1';
BACKUP DATABASE;
}
在会话2:
RUN
{
SET COMMAND ID TO 'sess2';
BACKUP DATABASE;
}
(2)当RMAN job执行时,在SQL*Plus会话中查询V$SESSION和V$PROCESS视图,例如:
SELECT SID, SPID, CLIENT_INFO
FROM V$PROCESS p, V$SESSION s
WHERE p.ADDR = s.PADDR
AND CLIENT_INFO LIKE '%id=sess%';
例子:监控RMAN会话
SQL> col client_info for a30
SQL> col sid for 999
SQL> col spid for 9999
SQL> select s.sid,p.spid,s.client_info
2 from v$process p,v$session s
3 where p.addr=s.paddr
4 and client_info like 'rman%';
SID SPID CLIENT_INFO
---- ------------------------ ------------------------------
39 23387 rman channel=ORA_DISK_1
RMAN> run{
2> set command id to 'sess1';
3> backup database;}
RMAN> run{
2> set command id to 'sess2';
3> backup database;}
SQL> select s.sid,p.spid,s.client_info
2 from v$process p,v$session s
3 where p.addr=s.paddr
4 and client_info like '%id=sess%';
SID SPID CLIENT_INFO
---- ------------------------ -----------------------------------
37 23459 id=sess2
53 23384 id=sess1
39 23387 id=sess1,rman channel=ORA_DISK_1
3、监控RMAN Job
通过查询视图V$SESSION_LONGOPS监控备份、拷贝以及恢复过程。opname字段带有detail关键字的行表示一个job step中处理的文件,opname字段带有aggregate关键字的行表示一个RMAN命令中所有job step处理的文件。一个job step表示创建或者还原一个备份集或者镜像拷贝。detail粒度比aggregate粒度更细。
使用V$SESSION_LONGOPS视图查看信息需要设置参数STATISTICS_LEVEL为TYPICAL或者ALL。
V$SESSION_LONGOPS常用的字段含义如下:
- OPNAME:对一行信息的描述,detail信息包括RMAN:datafile copy,RMAN:FULL DATAFILE BACKUP和RMAN:FULL DATAFILE RESTORE。
- CONTEXT:有关备份的行,值为2,其他情况(不包括proxy copy),值为1。
- SOFAR:对于镜像拷贝,表示已经读入的块数量;对于备份输入行,表示已经读入备份的块数量,对于备份输出行,表示已经写入到备份片的块数量;对于还原,表示一个job step中已经还原的块数量;对于proxy copies,表示复制的文件数量。
- TOTALWORK:对于镜像拷贝,表示文件所有块数量;对于备份输入行,表示一个job step中需要读入文件块的总量,对于备份输出行,由于不能预先知道会写入多少块到备份片,所有该值为0;对于还原,表示一个job step中所有文件块的总量;对于proxy copies,表示一个job step中复制的文件总数量。
例子:进行备份,监控运行情况
SQL> select opname,context,sofar,totalwork,
2 round(sofar/totalwork*100,2) "%_complete"
3 from v$session_longops
4 where opname like 'RMAN%'
5 and opname not like '%aggregate%'
6 and totalwork != 0
7 and sofar<>totalwork;
OPNAME CONTEXT SOFAR TOTALWORK %_complete
------------------------------ ---------- ---------- ---------- ----------
RMAN: full datafile backup 1 133050 293600 45.32
例子:进行还原,监控运行情况
SQL> select opname,context,sofar,totalwork,
2 round(sofar/totalwork*100,2) "%_complete"
3 from v$session_longops
4 where opname like 'RMAN%'
5 and opname not like '%aggregate%'
6 and totalwork != 0
7 and sofar<>totalwork;
OPNAME CONTEXT SOFAR TOTALWORK %_complete
------------------------------ ---------- ---------- ---------- ----------
RMAN: full datafile restore 1 28570 44320 64.46
4、RMAN输出的信息
RMAN输出包括job信息以及错误信息,RMAN错误信息有RMAN-nnnn前缀,既可以显示在终端,也可以通过使用LOG选项或者重定向到文件。
RMAN跟踪文件包含DEBUG输出,仅用于使用TRACE命令选项的情况。
如果RMAN没有使用恢复目录,会使用控制文件进行RMAN信息记录,故会写入到告警日志中。
当RMAN通道分配失败或者介质管理库加载失败,修改进程会产生需要的服务器跟踪文件。
sbtio.log文件包括由介质管理软件写入的特定信息,位于USER_DUMP_DEST。
5、使用DEBUG选项
在RMAN命令挂起或者出现错误的时候可以使用DEBUG选项来定位,DEBUG选项显示RMAN编译中执行的所有SQL语句和执行结果,由恢复目录PL/SQL包产生的任何信息也会被显示。可以在RMAN提示符或者RUN块中指定DEBUG选项。下面的例子中,DEBUG选项用户数据文件3的备份,但不用于数据文件4:
RMAN> run {
debug on;
allocate channel c1 type disk;
backup datafile 3;
debug off;
backup datafile 4; }
注意DUBUG会产生大量的信息,要有足够的磁盘空间来保留这些信息,一般不产生任何错误的备份操作会产生大约500K的信息。
[oracle@oracletest ~]$ rman target / debug trace sample.log
RMAN> backup database plus archivelog delete input;
RMAN> host 'ls -l sample.log';
-rw-r--r-- 1 oracle oinstall 453561 Jan 24 22:12 sample.log
RMAN-06134: host command complete
6、RMAN错误信息
快速找到RMAN错误信息中有用的信息:
- RMAN错误信息中大部分没有什么用处,需要找到最重要的一个或者两个错误。
- 检查包含“Additional information”加数字的信息,表示介质管理错误。
- 从下往上分析输出信息,最后的一两个错误信息一般最有用。
- 查看RMAN-03002或者RMAN-03009后的信息定位失败的命令。语法错误会产生RMAN-00558错误。
7、调优RMAN
RMAN备份和还原操作进行如下不同的任务:
- 读或者写输入数据
- 通过验证和从输入缓冲区到输出缓冲区复制块处理数据
这些任务中最慢的部分我们称之为瓶颈,RMAN调优包括定位瓶颈并通过使用RMAN命令,初始化参数设置或者调整物理介质来解决瓶颈。调优RMAN的关键是理解输入输出。RMAN备份和还原使用两种类型I/O缓冲:磁盘和第三方存储(通常是磁带),当执行备份,RMAN通过使用磁盘缓冲读取输入文件,通过使用磁盘缓冲或者磁带缓冲写入到输出文件。当执行还原则反过来。I/O可以同步或者异步。同步设备一次执行一个I/O任务,很容易计算出备份任务所需时间。而异步I/O一次可以执行多个任务。调优RMAN必须深入理解同步和异步I/O概念,磁盘和磁带缓冲,通道结构。
可以利用一些备份和恢复功能,平衡备份操作与恢复操作的性能。例如,如果需要缩短恢复时间,那么可以定期进行镜像拷贝。这需要更多的资源来为恢复做准备,但会减少执行恢复所需的时间。
8、RMAN多路复用
RMAN使用两种不同类型的I/O缓冲区:磁盘和磁带。RMAN多路复用决定如何分配磁盘缓冲区。RMAN多路复用是指单个通道备份时同时读取的文件数量并将其写入到同一备份片。复用的程度(Level)取决于BACKUP命令的FILESPERSET参数(默认64)以及CONFIGURE CHANNEL命令或ALLOCATE CHANNEL命令的MAXOPENFILES参数(默认8),还有通道读取的文件数。注意:RMAN复用在通道级设置。
multiplexing_level = min(MAXOPENFILES, min(FILESPERSET, files_per_channel))
例如,假设使用1个通道备份2个数据文件,设置FILESPERSET为3,MAXOPENFILES为8。在这种情况下,每个备份集的文件数为2(取FILESPERSET和每个通道读取文件数的最小值),复用水平为2(取MAXOPENFILES和每个备份集文件数的最小值)。
当RMAN从磁盘进行备份时使用上图中描述的算法为多路复用级别来分配不同数量和大小的磁盘I/O缓冲区。
对于写,每个通道分配4个大小为1MB的输出缓冲。
如果DBWR_IO_SLAVES为0,则这些缓冲区从PGA分配。
注意:为了最好的恢复性能,不要设置FILESPERSET大于8。
从实际的测试及Oracle的建议来看,多路复用设置的规则为:
如果要备份的所有磁盘或数据文件很好的做了条带(stripe),多路复用处就不大了,可以将多路复用级别设为1或者2。
如果磁盘没有做条带,多路复用应当设一个8之下的一个值。
大于8的值常用在备份有很多空块的文件或在做增量备份时。
9、分配磁盘缓冲区:示例
在上图中,1个通道备份4个数据文件。MAXOPENFILES设置为4,FILESPERSET设置为4,故多路复用水平为4。每个数据文件的缓冲区总大小为4MB。要计算在备份集中分配的缓冲区的总大小,将每个数据文件缓冲的总字节数乘以由该通道同时访问的数据文件的数目,然后将这个数字乘以通道数。
假设使用1个通道来备份4个数据文件,并使用上图中的设置。在这种情况下,如下相乘来获得分配给备份的缓冲区的总大小:
4 MB per data file ? 1 channel ? 4 data files per channel = 16 MB
设置MAXOPENFILES参数使同时读取文件的数量可以充分利用输出设备,特别是当输出设备是磁带的时候。
例子:查询每个文件被分配了多大的buffer
SQL> SELECT type, filename, buffer_size, buffer_count, open_time, close_time
2 FROM v$backup_async_io
3 ORDER by type, open_time, close_time;
TYPE FILENAME BUFFER_SIZE BUFFER_COUNT OPEN_TIME CLOSE_TIME
--------- ---------------------------------------------------------------------------------------------------------- ----------- ------------ ------------ ------------
AGGREGATE 0 0 24-JAN-16 24-JAN-16
AGGREGATE 0 0 24-JAN-16 24-JAN-16
AGGREGATE 0 0 24-JAN-16 24-JAN-16
AGGREGATE 0 0 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/fast_recovery_area/STONE/archivelog/2016_01_24/o1_mf_1_6_cb9mhjxq_.arc 1048576 16 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_test_ind_cb178or2_.dbf 524288 4 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_rcat_ts_cb178oqs_.dbf 524288 4 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_undotbs1_cb1769ff_.dbf 524288 4 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_example_cb33c57f_.dbf 524288 4 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_system_cb1769f2_.dbf 524288 4 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_sysaux_cb1769f6_.dbf 524288 4 24-JAN-16 24-JAN-16
TYPE FILENAME BUFFER_SIZE BUFFER_COUNT OPEN_TIME CLOSE_TIME
--------- ---------------------------------------------------------------------------------------------------------- ----------- ------------ ------------ ------------
INPUT /u01/app/oracle/oradata/STONE/datafile/user01.dbf 524288 4 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/fast_recovery_area/STONE/archivelog/2016_01_24/o1_mf_1_7_cb9mln86_.arc 1048576 16 24-JAN-16 24-JAN-16
INPUT /u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_stone.f 1048576 16 24-JAN-16 24-JAN-16
OUTPUT /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_24/o1_mf_annnn_TAG20160124T211321_cb9mhl4h_.bkp 1048576 4 24-JAN-16 24-JAN-16
OUTPUT /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_24/o1_mf_nnndf_TAG20160124T211323_cb9mhmmc_.bkp 1048576 4 24-JAN-16 24-JAN-16
OUTPUT /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_24/o1_mf_annnn_TAG20160124T211500_cb9mlnkc_.bkp 1048576 4 24-JAN-16 24-JAN-16
OUTPUT /u01/app/oracle/fast_recovery_area/STONE/autobackup/2016_01_24/o1_mf_s_902006101_cb9mlov7_.bkp 1048576 4 24-JAN-16 24-JAN-16
18 rows selected.
10、分配磁带缓冲区
如果备份到磁带设备,Oracle服务器为磁带写入(还原的话就是磁带读取)的每个通道分配4个缓冲区,且只有通道为System Backup to Tape(SBT)才分配这些通道。通常每个磁带缓冲区为256K。缓冲区大小乘以4再乘以通道就是备份或者还原的总缓冲区大小。
如上图所示,假设使用1个磁带通道,每个缓冲区为256K,总大小为:
256 KB per buffer ? 4 buffers per channel ? 1 channel = 1,024 KB
根据是否使用I/O slaves,RMAN从SGA或者PGA分配磁带缓冲区。如果BACKUP_TAPE_IO_SLAVES初始化参数设置为TRUE,则从共享池分配,如果设置了LARGE_POOL_SIZE,则从大池分配。如果BACKUP_TAPE_IO_SLAVES设置为FALSE,则从PGA分配。
Oracle推荐将BACKUP_TAPE_IO_SLAVES设置为TURE,以提供备份到磁带的最佳性能,前面讲的duplexed备份也是需要将该参数设置为TRUE。
11、比较同步和异步I/O
当I/O为同步时,服务器进程一次只能处理一个任务,当I/O为异步时,服务器进程可以开始一个I/O并在等待该I/O完成时执行其他任务,也可以在等待时开始多个I/O操作。
如果初始化参数BACKUP_TAPE_IO_SLAVES为TURE,则磁带I/O为异步,否则为同步。
上图显示了备份到磁带的同步I/O,步骤如下:
(1)服务器进程写块到磁带缓冲区。
(2)磁带进程写数据到磁带,当介质管理器从Oracle缓冲区拷贝数据到介质管理器内部缓冲区时服务器进程是空闲的。
(3)磁带进程告知服务器进程已完成写入。
(4)服务器可以发起一个新的任务。
12、比较同步和异步I/O
Oracle可以使用操作系统自身的异步I/O特性,如果操作系统平台支持异步I/O,Oracle推荐将BACKUP_TAPE_IO_SLAVES设置为TURE。如果操作系统平台不支持异步I/O,Oracle通过使用特殊的I/O slave进程来模拟异步I/O。通过设置DBWR_IO_SLAVES参数为非零值控制磁盘I/O slaves。如果DBWR_IO_SLAVES为任意非零值,Oracle分配4个备份磁盘I/O slaves。
上图显示了备份到磁带的异步I/O,步骤如下:
(1)服务器进程写块到磁带缓冲区。
(2)磁带进程写数据到磁带。
(3)当磁带进程在写的时候,其他空闲服务器进程写块到磁带缓冲区。
13、监控RMAN Job性能
最大备份速度受限于物理硬件,比如不可能快于磁带带宽的总和。
磁盘,磁带驱动器或者网络都有可能成为备份的瓶颈。
使用V$BACKUP_SYNC_IO和V$BACKUP_ASYNC_IO可以用于监控备份和恢复性能。这两张视图中的数据存在的周期是实例运行的过程中、当数据库被重新启动,这两张视图中的数据会被清空。
14、异步I/O瓶颈
可以使用V$BACKUP_ASYNC_IO监控异步I/O。LONG_WAITS字段表示备份或者还原进程在其I/O完成前需要等待的次数。SHORT_WAITS自动表示请求buffer不能立即获得,不过经过简短非的阻塞方式轮询可获的次数。
如果LONG_WAITS/IO_COUNT这个值比较大表明存在瓶颈。
例子:查询备份情况以及异步I/O瓶颈
SQL> SELECT device_type device,TYPE,filename,
2 to_char(open_time,'yyyymmdd hh24:mi:ss') OPEN,
3 to_char(close_time,'yyyymmdd hh24:mi:ss') CLOSE,
4 elapsed_time elapse,effective_bytes_per_second e_bytes
5 FROM v$backup_async_io
6 WHERE close_time>SYSDATE-1
7 ORDER BY close_time;
DEVICE TYPE FILENAME OPEN CLOSE ELAPSE E_BYTES
----------------- --------- ------------------------------------------------------------ ----------------- ----------------- ---------- ----------
DISK AGGREGATE 20160124 21:13:22 20160124 21:13:22 0
DISK INPUT /u01/app/oracle/fast_recovery_area/STONE/archivelog/2016_01_ 20160124 21:13:22 20160124 21:13:22 0
24/o1_mf_1_6_cb9mhjxq_.arc
DISK OUTPUT /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_2 20160124 21:13:22 20160124 21:13:22 0
4/o1_mf_annnn_TAG20160124T211321_cb9mhl4h_.bkp
DISK INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_test_ind_cb178o 20160124 21:13:23 20160124 21:13:24 100 1048576
r2_.dbf
DISK INPUT /u01/app/oracle/oradata/STONE/datafile/user01.dbf 20160124 21:13:24 20160124 21:13:25 100 7340032
DEVICE TYPE FILENAME OPEN CLOSE ELAPSE E_BYTES
----------------- --------- ------------------------------------------------------------ ----------------- ----------------- ---------- ----------
DISK INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_rcat_ts_cb178oq 20160124 21:13:23 20160124 21:13:26 300 5068117
s_.dbf
DISK INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_undotbs1_cb1769 20160124 21:13:23 20160124 21:13:28 500 7654605
ff_.dbf
DISK INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_example_cb33c57 20160124 21:13:23 20160124 21:14:11 4800 6804821
f_.dbf
DISK INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_system_cb1769f2 20160124 21:13:23 20160124 21:14:51 8800 9151209
_.dbf
DEVICE TYPE FILENAME OPEN CLOSE ELAPSE E_BYTES
----------------- --------- ------------------------------------------------------------ ----------------- ----------------- ---------- ----------
DISK OUTPUT /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_2 20160124 21:13:23 20160124 21:14:52 8900 17874668
4/o1_mf_nnndf_TAG20160124T211323_cb9mhmmc_.bkp
DISK INPUT /u01/app/oracle/oradata/STONE/datafile/o1_mf_sysaux_cb1769f6 20160124 21:13:23 20160124 21:14:52 8900 10002708
_.dbf
DISK AGGREGATE 20160124 21:13:23 20160124 21:14:52 8900 23416234
DISK AGGREGATE 20160124 21:15:00 20160124 21:15:00 0
DISK INPUT /u01/app/oracle/fast_recovery_area/STONE/archivelog/2016_01_ 20160124 21:15:00 20160124 21:15:00 0
24/o1_mf_1_7_cb9mln86_.arc
DEVICE TYPE FILENAME OPEN CLOSE ELAPSE E_BYTES
----------------- --------- ------------------------------------------------------------ ----------------- ----------------- ---------- ----------
DISK OUTPUT /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_2 20160124 21:15:00 20160124 21:15:00 0
4/o1_mf_annnn_TAG20160124T211500_cb9mlnkc_.bkp
DISK INPUT /u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_stone.f 20160124 21:15:01 20160124 21:15:01 0
DISK AGGREGATE 20160124 21:15:01 20160124 21:15:01 0
DISK OUTPUT /u01/app/oracle/fast_recovery_area/STONE/autobackup/2016_01_ 20160124 21:15:01 20160124 21:15:01 0
24/o1_mf_s_902006101_cb9mlov7_.bkp
18 rows selected.
effective_bytes_per_second这一列表示每秒中以异步方式备份、恢复数据的字节数,这个值应该接近于备份设备的读、写速率,如果这个值很小于备份设备读写速率、我们也该注意了。
SQL> select long_waits/io_count waitcountratio, filename from v$backup_async_io where long_waits/io_count>0 order by 1 desc;
WAITCOUNTRATIO FILENAME
-------------- ----------------------------------------------------------------------------------------------------------
.249670619 /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_24/o1_mf_nnndf_TAG20160124T211323_cb9mhmmc_.bkp
.24 /u01/app/oracle/fast_recovery_area/STONE/backupset/2016_01_24/o1_mf_annnn_TAG20160124T211321_cb9mhl4h_.bkp
.2 /u01/app/oracle/fast_recovery_area/STONE/autobackup/2016_01_24/o1_mf_s_902006101_cb9mlov7_.bkp
15、同步I/O瓶颈
使用V$BACKUP_SYNC_IO查看同步I/O瓶颈。discrete_bytes_per_second字段表示每秒中以同步方式备份、恢复数据的字节数,这个值应该接近于备份设备的读、写速率如果这个值远小于备份设备读写速率,则存在优化的机会。
16、通道调优
可以在CONFIGURE CHANNEL和ALLOCATE CHANNEL命令中设置通道参数。
MAXPIECESIZE参数指定了备份片的最大大小。可以通过设置此参数在备份集中创建多个备份片,每个备份片的大小都不超过MAXPIECESIZE大小。
RATE参数指定了RMAN在这个通道上每秒钟读取的字节数。可以通过设置此参数限制RMAN消耗大量的磁盘带宽导致事务处理性能下降。
MAXOPENFILES参数指定了备份或镜像拷贝时同时打开的最大文件数。默认值为8。此参数参与决定RMAN多路复用级别。
如果为SBT设备配置了多通道,可以指定数据文件到这些通道:
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
ALLOCATE CHANNEL c2 DEVICE TYPE sbt;
ALLOCATE CHANNEL c3 DEVICE TYPE sbt;
BACKUP (DATAFILE 1,2,5 CHANNEL c1)
(DATAFILE 4,6 CHANNEL c2)
(DATAFILE 3,7,8 CHANNEL c3);
BACKUP DATABASE NOT BACKED UP;
}
17、调优BACKUP命令
MAXPIECESIZE参数指定了在该通道创建的备份片的最大大小。
FILESPERSET参数指定了备份集中文件的最大数量。如果只分配了一个通道,你可以使用这个参数创建多个备份集。假如有50个数据文件和2个通道,设置FILESPERSIET=5,则创建10个备份集。
MAXOPENFILES参数设置取决于磁盘特性。如果使用ASM,则设置为1或者2。如果磁盘没有条带化,可以增大此参数以提高性能。
DURATION选项指定了备份的持续时间,可以使用MINIMIZE TIME让备份尽快完成,也可以使用MINIMIZE LOAD在整个备份时间段内进行备份以减少系统负载。
18、调优备份性能
参考如下步骤获取最佳备份性能:
(1)在配置和分配通道时移除RATE设置。RATE参数用于指定RMAN通道每秒读取的最大字节数。用于指定上限以防RMAN消耗过多磁盘带宽而影响性能。如果不是备份到磁带,建议不要在ALLOCATE CHANNEL或者CONFIGURE CHANNEL命令设置RATE参数。
(2)如果使用同步磁盘I/O,设置DBWR_IO_SLAVES参数。如果磁盘不支持异步I/O,设置DBWR_IO_SLAVES为非零值,可以使用4个磁盘I/O slaves进行备份和还原,以模拟异步I/O。如果使用了I/O slaves,从SGA中分配I/O buffers,如果配置了大池,则使用大池,否则使用共享池。注意:设置了DBWR_IO_SLAVES,则DBWn进程也会使用salves,因此可能需要增大PROCESSES参数。
(3)设置大池LARGE_POOL_SIZE。
(4)调优RMAN磁带streaming性能瓶颈。
(5)使用V$视图查询瓶颈。
19、设置LARGE_POOL_SIZE
通过如下公式计算大池LARGE_POOL_SIZE:
#_of_allocated_channels * (16 MB + (4*size_of_tape_buffer ))
对于备份到磁盘,磁带缓冲区为0,故设置LARGE_POOL_SIZE为16MB。对于磁带,使用RMAN通道参数BLKSIZE指定单个磁带缓冲区大小,默认值为256K。假如有2个磁带驱动器,磁带缓冲区大小为256K,则LARGE_POOL_SIZE为18MB,如果增大BLKSIZE为512K,则LARGE_POOL_SIZE为20M。
注意:只有当DBWR_IO_SLAVES>0(磁盘缓存)或者BACKUP_TAPE_IO_SLAVES=TURE(磁带缓存)时,才需要手动设置大池。如果使用自动内存管理,则系统根据负载自动调整大小。
20、调优磁带性能
采取以下措施定位和解决备份到磁带的性能瓶颈:
(1)使用BACKUP...VALIDATE查看在一个备份任务中磁带流或者磁盘I/O是否为瓶颈。在备份到磁带中执行该命令,则会读取磁盘而不会写入到磁带,如果所需时间远小于真实备份到磁带的时间,则写入到磁带就可能是瓶颈。
(2)使用多路复用改善磁带流避免磁盘瓶颈。当RMAN备份到磁带的时候,有可能由于发送数据块的速度不够快而不能支持磁带流。例如增量备份时,如果没有启用块改变跟踪,则RMAN需要去扫描数据文件,找到改变的块并发送到输出缓冲,如果发送到输入缓冲的速度不够快则不能保持磁盘流。可以通过增大多路复用级别提高填充磁带缓冲的速度。
(3)使用增量备份提高备份性能避免磁带瓶颈。
21、相关习题:
(1)You are tuning RMAN to optimize performance. You want tape I/O to be asynchronous when you perform tape backups. Which action should you take?
A. Set the BACKUP_TAPE_IO_SLAVES parameter to FALSE.
B. Set the BACKUP_TAPE_IO_SLAVES parameter to TRUE.
C. Use compression when performing tape backups.
D. Configure multiple SBT channels.
答案:B
(2)Using the LIST command in Recovery Manager (RMAN), which two pieces of information in the RMAN repository can be listed? (Choose two.)
A. stored scripts in the recovery catalog
B. backups that can be deleted from disk
C. backup sets and image copies are obsolete
D. backups that do not have the AVAILABLE status in the RMAN repository
答案:AD
(3)What is the impact of the results of the output of the following command?
RMAN> report unrecoverable database;
Report of files that need backup due to unrecoverable operations
File Type of Backup Required Name
4 full or incremental C:\ORACLE\ORADATA\ORCL\USERS01.DBF
A. There are no backup sets with any backups of the users01.dbf datafile.
B. The users01.dbf datafile has had unrecoverable operations occur in it.
It will need to be backed up or some data loss is possible during a recovery.
C. The users01.dbf datafile is corrupted.
D. The users01.dbf datafile backup exceeds the retention criteria.
E. The last backup of the users01.dbf datafile failed and must be rerun.
答案:B
(4)What does the output on this report indicate?
RMAN> report need backup;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
5 0 C:\ORACLE\ORADATA\ORCL\MY_DATA_01.DBF
A. The my_data_01.dbf datafile is corrupted and needs to be restored.
B. The my_data_01.dbf datafile has not yet been backed up. This report does not imply that the data in the datafile can not be recovered.
C. The my_data_01.dbf datafile has not yet been backed up. This report implies that the data in the datafile can not be recovered.
D. The my_data_01.dbf datafile no longer meets the retention criteria for backups.
E. Datafile 5 is missing.
答案:B
(5)What does the minimize load database parameter mean when backing up a database?
A. RMAN will attempt to make the backup run as fast as possible without any IO limitations.
B. RMAN will automatically restrict the number of channels in use to one.
C. RMAN will spread the backup IO over the total duration stated in the backup command.
D. RMAN will skip any datafile that currently is involved in an IO operation.
RMAN will retry backing up the datafile later and an error will be raised at the end of the backup if the datafile cannot be backed up.
E. Datafiles will be backed up; those having the lowest current number of IO operations will be backed up first.
答案:C
(6)What is the result of this command?
RMAN> Report need backup days 3;
A. Lists all datafiles created in the last three days that are not backed up.
B. Lists all datafiles not recoverable based on the current retention criteria.
C. Lists all datafiles not backed up in the last three days. The datafile is not recoverable.
D. Lists all datafiles that need to be backed up due to unrecoverable operations.
E. Lists all datafiles not backed up in the last three days. It does not imply that the datafile is not recoverable.
答案:E
(7)Why would you execute the report obsolete command?
A. To list all backups that were no longer available for restore operations
B. To list all backups that had aged beyond the RMAN retention criteria
C. To list all backup set pieces listed in control-file or recovery-catalog metadata that are not on the backup media
D. To list all datafiles that are no longer part of the database and thus do not need to be backed up
E. To list all archived redo logs that are no longer needed for any database recovery
答案:B
(8)What information does the report schema command not provide? (Choose all that apply.)
A. Size of the datafiles
B. Size of the tempfiles
C. Date of last backup for datafiles and tempfiles
D. Filenames for each datafile
E. Checkpoint SCN associated with the last RMAN backup
答案:CE
(9)If a backup is expired, which of the following is true?
A. It can never be used for a restore/recover operation.
B. Oracle will remove the backup set pieces from the flash recovery area.
C. The backup has been used at least once to restore and recover the database.
D. The backup is no longer valid because of a resetlogs operation.
E. The physical backup set pieces are missing from the media.
答案:E
(10)What command is used to reset a database to a previous incarnation?
A. reset incarnation
B. incarnation reset
C. reset database to incarnation
D. reset database incarnation
E. reset databse incarnation number
答案:C
(11)Which command do you use to generate a report of database incarnations?
A. list incarnation of database
B. report incarnation of database
C. list database incarnation
D. database incarnation list
E. report database incarnation
答案:A
(12)Which of the following is not an advantage of block media recovery (BMR)?
A. Reduced MTTR.
B. Datafiles remain offline while corrupt blocks are repaired.
C. Datafiles remain online while corrupt blocks are repaired.
D. A and C
答案:B
(13)Which of the following methods can be used to detect block corruption?
A. ANALYZE operations
B. dbv
C. SQL queries that access the potentially corrupt block
D. RMAN
E. All of the above
答案:E
(14)Which of the following are correct about block media recovery? (Choose all that apply.)
A. Physical and logical block corruption is recorded automatically in V$DATABASE_BLOCK_ CORRUPTION.
B. Logical corruptions are repairable by BMR.
C. Physical corruptions are repairable by BMR.
D. RMAN can use any backup for a BMR restore.
E. ARCHIVELOG mode is not required if you have both a full and incremental backup for restore.
答案:AC
(15)While querying the EMPLOYEES table, you receive an ORA-01578 message indicating block
corruption in File# 1201 and Block# 1968. You analyze the table and the corruption is verified.
Which RMAN command do you use to perform BMR and repair the corrupt block?(choose two)
A. RECOVER FILE=1201 BLOCK=1968;
B. RECOVER CORRUPTION LIST;
C. RECOVER DATAFILE 1201 BLOCK 1968;
D. RECOVER BLOCK CORRUPTION LIST;
E. None of the above
答案:BC
(16)You execute the following Recovery Manager (RMAN) commands in the following order:
BACKUP VALIDATE DATABAE;
RECOVER CORRUPTION LIST;
Which two tasks are performed by these commands? (Choose two.)
A. Repair the corrupted blocks. If any. In the backup created.
B. Populate V$COPY_CORRUPTION with names of files that have corrupted blocks
C. Back up the database after checking whether array of the files have corrupted blocks.
D. Discover any corrupt blocks that are viewable with the V$DATABASE_BI-OCK_CORBUPTION view.
E. Repair all corrupted blocks that have been logged in the V$DATABASE_BLOCK_ CORRUPTION
答案:DE
(17)You executed the following command in Recovery Manager (RMAN):
RMAN> REPORT NEED BACKUP days 3;
What is the output of this command?
A. a list of files that require a backup within three days
B. a list of files requiring more than 3 days of archive logs to apply
C. a list of files that RMAN recommends be backed up only once in every three days, based on low volatility
D. a list of files for which a backup has already been performed in the last three days and which is required to be backed up again based on the high number of transactions performed on them
答案:A
(18)Examine the following command used to perform incremental level 0 backup:
RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;
To enable the block change tracking, after the incremental level 0 backup you issued the following command:
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/mydir/ rman_change_track.f';
To perform incremental level 1 cumulative backup, you issued the following command:
RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
Which two statements are true in the above situation? (Choose two.)
A. The block change tracking data will be used only from the next incremental 0 backup.
B. The incremental backup will use change tracking data for accomplishing the backup.
C. The incremental backup will not use change tracking data for accomplishing the backup.
D. The block track file will scan all the blocks and create bitmap for all the blocks backed up in the level 0 backup.
答案:AC
(19)View the Exhibit and examine the output of the query in different times when the following command runs in an RMAN sessions:
RMAN> BACKUP DATABASE FILESPERSET 2;
The database has seven data files. Why is the %_COMPLETE refreshed to 13.59 in the third output after reaching 88.77?
Exhibit:
A. Because the progress is reported for each data file
B. Because the progress is reported for each backup set
C. Because other RMAN sessions have issued the same BACKUP command
D. Because new data files have been added to the database while the RMAN backup is in progress
答案:B
(20)To enable faster incremental backups, you enabled block change tracking for the database.
Which two statements are true about the block change tracking file? (Choose two.)
A. Multiple change tracking files can be created for a database.
B. The change tracking file must be created after the first level 0 backup.
C. RMAN does not support backup and recovery of the change tracking file.
D. The database clears the change tracking file and starts tracking changes again, after whole database restore and recovery operations.
答案:CD
(21)Identify the scenarios in which the RMAN CROSSCHECR command is useful. (Choose all that apply.)
A.To check that the obsolete backups are deleted from the repository records and from the disk.
B.To update the RMAN repository if you delete archived redo logs with operating system commands.
C.To update outdated information about backups that disappeared from disk or tape or became corrupted and inaccessible.
D.To synchronize the actual files on disk or in the media management catalog with the RMAN repository for which the backup was not taken using RMAN.
答案:BC

![clipboard[1] clipboard[1]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027437znRR.png)
![clipboard[2] clipboard[2]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_14630274402eIY.png)
![clipboard[3] clipboard[3]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_14630274410773.png)
![clipboard[4] clipboard[4]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027443c48g.png)
![clipboard[5] clipboard[5]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027445UD0p.png)
![clipboard[6] clipboard[6]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_14630274478T9W.png)
![clipboard[7] clipboard[7]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027448GvJ4.png)
![clipboard[8] clipboard[8]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027450MhE1.png)
![clipboard[9] clipboard[9]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027451io0F.png)
![clipboard[10] clipboard[10]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027452anDU.png)
![clipboard[11] clipboard[11]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027453bp30.png)
![clipboard[12] clipboard[12]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_146302745534q4.png)
![clipboard[13] clipboard[13]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027456RTVs.png)
![clipboard[14] clipboard[14]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027457f5F5.png)
![clipboard[15] clipboard[15]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027459U59n.png)
![clipboard[16] clipboard[16]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027460NsSG.png)
![clipboard[17] clipboard[17]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027461MFri.png)
![clipboard[18] clipboard[18]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027462q5q8.png)
![clipboard[19] clipboard[19]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_14630274633305.png)
![clipboard[20] clipboard[20]](http://img.blog.itpub.net/blog/attachment/201605/12/28536251_1463027465mauR.png)