第五章RMAN环境配置
1. 配置Flash
Recovery Area(快速恢复区)
Flash
Recovery Area(快速恢复区):主要存放
Online redo log(文件夹:onlinelog)
控制文件
归档日志文件(文件夹:archivelog)
RMAN文件(文件夹:backupset)
A.
以下命令都会在Flash Recovery Area产生Online
redo log:
l CREATE DATABASE
l ALTER DATABASE ADD LOGFILE
l ALTER DATABASE ADD STANDBY LOGFILE
l ALTER DATABASE OPEN RESETLOGS
初始化参数决定的位置:
l DB_CREATE_ONLINE_LOG_DEST_n #online redo log 位置
l DB_RECOVERY_FILE_DEST
#快速恢复区文件位置
l DB_CREATE_FILE_DEST
# OMF文件位置
B.
控制文件
初始化参数决定的位置:
l CONTROL_FILES
l DB_CREATE_ONLINE_LOG_DEST_n
l DB_RECOVERY_FILE_DEST
l DB_CREATE_FILE_DEST
C.
归档日志
如果希望使用Flash
Recovery Area,则不能使用初始化参数(LOG_ARCHIVE_DUPLEX_DEST,LOG_ARCHIVE_DEST)
D. REDO LOG文件的位置规则
l 如果设置了LOG_ARCHIVE_DEST(或LOG_ARCHIVE_DUPLEX_DEST),则保存归档日志到指定位置;
l 如果DB_RECOVERY_FILE_DEST被指定,而LOG_ARCHIVE_DEST_n没有指定,LOG_ARCHIVE_DEST_10是默认的快速恢复区位置
l 如果设置参数LOG_ARCHIVE_DEST_n,则会归档到该指定位置,而不会归档到闪回区的默认位置;当然,你也可以将闪回区指定为该参数的归档位置LOCATION = USE_DB_RECOVERY_FILE_ DEST
l 如果LOG_ARCHIVE_DEST,
LOG_ARCHIVE_DEST_n, or DB_RECOVERY_FILE_DEST都没有指定,则有OS系统默认位置(各系统不同),如,?/dbs,?/dbs/arch
E.
归档日志文件名格式:LOG_ARCHIVE_FORMAT
2. 配置media 管理器备份
media 管理器是第三方软件,通常用于管理磁带等备份设备;
A. RMAN使用media管理器的先决条件:支持oracle RMAN并能与其通信
B. 定位media管理器libray:SBT_LIBRARY参数
SBT_LIBRARY提供媒体管理器软件的库位置:
unix:$ORACLE_HOME/lib/libobk.so
windows:%ORACLE_HOME%\bin\orasbt.dll
如果不能定位,则会报错ORA-27211
Whenever channel allocation fails, the database writes a trace
file to the USER_DUMP_DEST directory. The following shows sample output:
SKGFQ
OSD: Error in function sbtinit on line 2278
SKGFQ
OSD: Look for SBT Trace messages in file /oracle/rdbms/log/sbtio.log
SBT Initialize failed for /oracle/lib/libobk.so
C. 测试媒体管理器library整合正确
l 为RMAN备份配置媒体管理软件
BACKUP命令中分配channel的FORMAT
ALLOCATE CHANNEL、CONFIGURE CHANNEL
环境变量:PARMS='ENV=(NSR_DATA_VOLUME_POOL=oracle_tapes)'
备份片名称:由format指定,默认为%U
%U:是%u_%p_%c的简写形式,利用它可以为每一个备份片段(即磁盘文件)生成一个唯一名称,这是最常用的命名方式;
备份片大小:MAXPIECESIZE
l 测试allocate
channel
例如:
RUN
{ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS='SBT_LIBRARY=/mediavendor/lib/libobk.so
ENV=(NSR_SERVER=tape_srv,NSR_GROUP=oracle_tapes)';
}
如果不成功,则报错ORA-27211,例如:
RMAN-00571:
===========================================================
RMAN-00569:
=============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571:
===========================================================
RMAN-03009:
failure of allocate command on c1 channel at 11/30/2001 13:57:18
ORA-19554:
error allocating device, device type: SBT_TAPE, device name:
ORA-27211:
Failed to load Media Management Library
Additional
information: 25
或者:
RMAN>
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='SBT_LIBRARY=/mediavendor/lib/libobk.so
ENV=(NSR_SERVER=tape_svr,NSR_CLIENT=oracleclnt,NSR_GROUP=ora_tapes)' FORMAT "BACKUP_%U";
RMAN>
BACKUP DEVICE TYPE sbt CURRENT CONTROLFILE;
l 测试备份到媒体管理器
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS='SBT_LIBRARY=/mediavendor/lib/libobk.so
ENV=(NSR_SERVER=tape_srv,NSR_GROUP=oracle_tapes)';
BACKUP CURRENT CONTROLFILE;
}
D. 配置SBT通道
c
3. 配置通道
默认情况下,RMAN会自动配置磁盘通道用于备份与恢复;你也可以手动配置通道来提升性能;
l 配置channel并行
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3;
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt; # default backup
device is tape
RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 2; # configure two
tape channels
RMAN> BACKUP DATABASE; # backup goes to two tapes, in two
parallel streams
l 配置channel设备类型
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT = '?/bkup_%U';
RMAN> CONFIGURE CHANNEL DEVICE TYPE sbt
PARMS='SBT_LIBRARY=/mediavendor/lib/libobk.so
ENV=(NSR_SERVER=tape_svr,NSR_CLIENT=oracleclnt,NSR_GROUP=ora_tapes)';
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2G;
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT = /tmp/%U;
l show
RMAN> SHOW CHANNEL;
SHOW DEFAULT DEVICE TYPE; # shows the CONFIGURE DEFAULT DEVICE TYPE
setting
SHOW DEVICE TYPE; # shows the CONFIGURE DEVICE TYPE ...
PARALLELISM settings
l 手动配置channel
RMAN> RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
BACKUP TABLESPACE users;
}
l 为设备配置特定channel
CONFIGURE DEFAULT DEVICE TYPE TO sbt; # backup goes to sbt
CONFIGURE DEVICE TYPE sbt PARALLELISM 2; # two sbt channels will
be allocated by default
# Assume media manager takes NSR_DATA_VOLUME_POOL to
# specify a pool
# Configure channel 1 to pool named first_pool
CONFIGURE CHANNEL 1 DEVICE TYPE sbt
PARMS
'SBT_LIBRARY=/mediavendor/lib/libobk.so ENV=(NSR_DATA_VOLUME_POOL=first_pool)';
# configure channel 2 to pool named second_pool
CONFIGURE CHANNEL 2 DEVICE TYPE sbt
PARMS 'SBT_LIBRARY=/mediavendor/lib/libobk.so
ENV=(NSR_DATA_VOLUME_POOL=second_pool)';
BACKUP DATABASE; # first stream goes to 'first_pool' and second to
'second_pool'
l 混合channel
# disk channel configuration
CONFIGURE DEVICE TYPE DISK PARALLELISM 4;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT = '/tmp/backup_%U';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK MAXPIECESIZE = 20M;
CONFIGURE CHANNEL 4 DEVICE TYPE DISK MAXPIECESIZE = 40M;
# sbt channel configuration
CONFIGURE DEVICE TYPE sbt PARALLELISM 3;
CONFIGURE CHANNEL DEVICE TYPE sbt
PARMS='SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=?/oradata)';
CONFIGURE CHANNEL 3 DEVICE TYPE sbt
PARMS='SBT_LIBRARY=oracle.disksbt, ENV=(BACKUP_DIR=/tmp)';
l 恢复channel默认值
CONFIGURE DEVICE TYPE ... CLEAR
CONFIGURE DEFAULT DEVICE TYPE CLEAR
CONFIGURE CHANNEL DEVICE TYPE ... CLEAR
CONFIGURE CHANNEL n DEVICE TYPE ... CLEAR (where n is an integer)
4. 配置备份集和备份片的最大尺寸
CONFIGURE MAXSETSIZE TO 7500K;
BACKUP TABLESPACE tools MAXSETSIZE 5G;
5. 配置备份优化
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE BACKUP OPTIMIZATION CLEAR;
6. 配置多备份
# Makes 2 disk copies of each datafile and
control file backup set
# (autobackups excluded)
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE
TYPE DISK TO 2;
# Makes 3 copies of every archived redo log
backup to tape
CONFIGURE ARCHIVELOG BACKUP COPIES FOR
DEVICE TYPE sbt TO 3;
BACKUP DATABASE FORMAT '/tmp/%U',
'?/dbs/%U', '?/oradata/%U';
SHOW DATAFILE BACKUP COPIES; # shows CONFIGURE DATAFILE BACKUP COPIES
setting
7. 配置排除表空间的数据库备份
CONFIGURE ARCHIVELOG BACKUP COPIES FOR
DEVICE TYPE sbt TO 3;
ONFIGURE EXCLUDE
FOR TABLESPACE cwmlite;
CONFIGURE EXCLUDE FOR TABLESPACE example;
BACKUP DATABASE NOEXCLUDE;
BACKUP TABLESPACE cwmlite, example; # backs up only cwmlite and example
CONFIGURE EXCLUDE FOR TABLESPACE cwmlite
CLEAR;
CONFIGURE EXCLUDE FOR TABLESPACE example
CLEAR;
8. 配置辅助数据库的数据文件名
CONFIGURE AUXNAME FOR datafileSpec TO
'filename';
CONFIGURE AUXNAME FOR DATAFILE 2 TO
'/newdisk/datafiles/df2.df;'
CONFIGURE AUXNAME FOR DATAFILE 2 CLEAR;
RMAN> SHOW AUXNAME;
9. 设置快照控制文件位置
当RMAN需要从一个读一致版本的控制文件重新同步,才会创建控制文件快照;RMAN只有以下2种情况下才会需要控制文件快照:从恢复目录重新同步、用当前控制文件备份;
默认快照名:$ORACLE_HOME/dbs/snapcf_@.f
SHOW SNAPSHOT CONTROLFILE NAME; # shows CONFIGURE SNAPSHOT CONTROLFILE
setting
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
'/dev/vgd_1_0/rlvt5';
10. RMAN共享服务器设置
tnsname.ora:
inst1_shs =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=inst1_host)(port1521))
(CONNECT_DATA=(SERVICE_NAME=inst1)(SERVER=shared))
)
RMAN命令列表