RMAN Channels
rman通道可以手动分配和自动,在10G以前,RUN里的脚本需要手动分配通道
如果脚本里没有allocate 命令,那么服务器就会自动分配通道。。根据RMAN的配置,
如果要查看RMAN配置,可以执行SHOW ALL命令
RMAN> show all;
使用目标数据库控制文件替代恢复目录
db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON; 启动RMAN备份 优化
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default 定义默认设备为磁盘
CONFIGURE CONTROLFILE AUTOBACKUP ON;启动控制文件自动备份
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘%F’;定义控制文件备份格式
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM 1;定义BACKUP的并行度
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default定义备份数据文件设备类型为DISK
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default定义归档日志设备类型为DISK
CONFIGURE MAXSETSIZE TO UNLIMITED; # default备份文件大小不限制
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128′; # default
CONFIGURE COMPRESSION ALGORITHM ‘BZIP2′; # default默认压缩类型BZIP2
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘F:\APP\BOSON.SUN\PRODUCT\11.1.0\DB_1\DATABASE\SNCFORCL.ORA’;
一、分配通道:
CONFIGUREDEVICE TYPEDISK|SBTPARALLELISM NCONFIGUREDEFAULTDEVICETYPE DISK|SBTCONFIGURECHANNEL
二、定义通道的并行度
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
三、定义通道缺省的设备类型:
CONFIGURE DEFAULT DEVICE TYPE TO DISK|sbt;
四、自动分配通道的一般配置:
CONFIGURE CHANNEL DEVICE TYPE sbt PARMS='ENV=(NSR_SERVER=bksvr1)';
CONFIGURE CHANNEL DEVICE TYPE DISK RATE 5M(定义磁盘速度) FORMAT="?/oradata/%U";备份格式
五、自动分配通道的一些特殊设置:
CONFIGURE DEVICE TYPE DISK PARALLELISM 3;
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE = 2M;其他通道最大备份片为2M
CONFIGURE CHANNEL 3 DEVICE TYPE DISK MAXPIECESIZE = 900K; 如果分配通道3,则最大备份片为900K
六、清除通道设置
CONFIGURE DEVICE TYPE DISK CLEAR; # returns DISK to default PARALLELISM 1
# and backup type to BACKUPSET
CONFIGURE DEFAULT DEVICE TYPE CLEAR; # returns to default device type of DISK
CONFIGURE CHANNEL DEVICE TYPE sbt CLEAR; # removes all options for sbt channel
CONFIGURE CHANNEL 3 DEVICE TYPE DISK CLEAR; # removes configurations for 3rd ch.
七、分配的并行度和硬件匹配:
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
ALLOCATE CHANNEL c2 DEVICE TYPE sbt;
ALLOCATE CHANNEL c3 DEVICE TYPE sbt;
BACKUP DATAFILE 5;
BACKUP DATAFILE 6;
BACKUP DATAFILE 7;
}
这个脚本其实只是使用了通道C1,
RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt; ALLOCATE CHANNEL c2 DEVICE TYPE sbt; ALLOCATE CHANNEL c3 DEVICE TYPE sbt; BACKUP DATAFILE 5,6,7; }
这个才会同时启用三个通道备份
When all three datafiles are backed up in one command, RMAN recognizes the opportunity for parallelism and can use multiple channels to do the I/O in parallel. When three separate commands are used, RMAN can only perform the backups one at a time, regardless of available channels and I/O devices.
八、手动或自动分配通道一些控制选项:
- Control the operating system resources RMAN uses when performing RMAN operations
- Affect the degree of parallelism for a backup or restore command
- Set limits on I/O bandwidth consumption in kilobytes, megabytes, or gigabytes (
ALLOCATECHANNEL...RATE,CONFIGURECHANNEL...RATE)控制备份磁盘速率 - Set limits on the size of backup pieces (the
MAXPIECESIZEparameter specified on theCONFIGURECHANNELandALLOCATECHANNELcommands)控制备份片的大小 - Set limits on the size of backup sets (the
MAXSETSIZEparameter specified on theBACKUPandCONFIGUREcommands)控制备份集大小 - Send vendor-specific commands to the media manager (
SEND) - Specify vendor-specific parameters for the media manager (
ALLOCATECHANNEL...PARMS,CONFIGURECHANNEL...PARMS) - Specify which instance performs the operation (
ALLOCATECHANNEL...CONNECT,CONFIGURECHANNEL...CONNECT)
九、映像的复制
如果是使用RMAN的映像拷贝,那么如果遇到使用RESTORE恢复文件,并且磁盘上有一份可用的映像拷贝时,可以不必把映像拷贝到源位置,可以使用命令alter database rename datafile 和switch命令,切换到映像的位置上
如果是用户的映像拷贝,那么在拷贝后需要使用CHANGE UNCATALOG
十、分配不同的通道给不同数据文件:
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS=”ENV=(BACKUP_SERVER=tape_server1)”;
ALLOCATE CHANNEL c2 DEVICE TYPE sbt PARMS=”ENV=(BACKUP_SERVER=tape_server2)”;
ALLOCATE CHANNEL c3 DEVICE TYPE sbt PARMS=”ENV=(BACKUP_SERVER=tape_server3)”;
BACKUP
(DATAFILE 1,2,3
CHANNEL c1)
(DATAFILECOPY ‘/tmp/system01.dbf’, ‘/tmp/tools01.dbf’
CHANNEL c2)
(ARCHIVELOG FROM SEQUENCE 100 UNTIL SEQUENCE 102 THREAD 1
CHANNEL c3);
}
shi
十一:多备份集的设置
BACKUP DEVICE TYPE DISK AS BACKUPSET DATABASE PLUS ARCHIVELOG;
BACKUP DEVICE TYPE sbt BACKUPSET ALL; # copies backup sets on disk to tape
BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;
BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE ‘SYSDATE-7′ DELETE INPUT;
This command backs up backup sets that were created more than a week ago from disk to tape, and then deletes them from disk. Note that DELETE INPUT here is equivalent to DELETE ALL INPUT;RMAN deletes all existing copies of the backup set. If you duplexed a backup to four locations, then RMAN deletes all four copies of the pieces in the backup set.
十二、Backups of Image Copies映像的备份
BACKUPAS COPYCOPYOFDATABASEBACKUP AS BACKUPSETCOPYOFTABLESPACEtablespace_nameBACKUP AS BACKUPSETCOPYOFDATAFILEdatafile
十三、RMAN Backup Options: Naming, Sizing, and Speed
名字:
BACKUP TABLESPACE users FORMAT = ‘/tmp/users_%u%p%c’; 想启动自己的备份名用FORMAT指定
映像备份的名字一般是FORMAT或者DB_FILE_NAME_CONVERT
复制的:
Type of File Meaning of %U
Datafile data-D-%d_id-%I_TS-%N_FNO-%f_%u
Archived log arch-D_%d-id-%I_S-%e_T-%h_A-%a_%u
Control file cf-D_%d-id-%I_%u
Using DB_FILE_NAME_CONVERT With BACKUP AS COPY
BACKUP AS COPY TABLESPACE users DB_FILE_NAME_CONVERT=('/maindisk/oradata/users','/backups/users_ts');
还可以使用TAG做备注:
# Back up as image copies the datafiles of tablespaces users and tools # all copies get the TAG 'users_tools' BACKUP AS COPY TAG users_tools TABLESPACE users, tools;
# Create new copies of all image copies of the database that have the tag # 'full_cold_copy', and give the new copies the tag 'new_full_cold_copy' BACKUP AS COPY COPY OF DATABASE FROM TAG=full_cold_copy TAG=new_full_cold_copy;
备份片的大小:
For example, if datafile 1 is 6GB, you can still restrict the backup piece size for disk backups to 2 GB by configuring an automatic disk channel, and then run a backup as follows:
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE = 2G; BACKUP AS BACKUPSET DATAFILE 1;
IO带宽:
CONFIGURE DEVICE TYPE sbt PARALLELISM 2; CONFIGURE DEFAULT DEVICE TYPE TO sbt; CONFIGURE CHANNEL DEVICE TYPE sbt RATE 1M;
十四、备份策略
CONFIGURERETENTIONPOLICYTO REDUNDANCY 1; # default
obsolete 过期 report obsolete delete obsolete
crosscheck
expired 不可用 report expired delete expired
To configure a retention policy based on a recovery window, use the following command:
CONFIGURERETENTIONPOLICYTORECOVERYWINDOW
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;保留距离当前时间7天的备份
To configure a retention policy based on redundancy, use the following command:
CONFIGURERETENTIONPOLICYTOREDUNDANCY
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
You can also disable the retention policy completely, meaning that RMAN does not consider any backup to be obsolete. To do so, use the following command:
CONFIGURE RETENTION POLICY TO NONE;
CHANGE... KEEP and CHANGE... NOKEEP 是否保留过期的备份
# Creates a backup and exempts it from retention policy until last day of 2007 BACKUP DATABASE KEEP UNTIL TIME "TO_DATE('31-DEC-2007' 'dd-mon-yyyy')" NOLOGS; # Specifies that backupset 2 is no longer exempt from the retention policy CHANGE BACKUPSET 2 NOKEEP; # Creates a backup that is indefinitely exempt from the retention policy BACKUP TABLESPACE users KEEP FOREVER NOLOGS;
