[size=small]RMAN学习-tina
rman的功能非常强大,下面我们来一步步的学习
首先想到的是备份
一、rman备份数据库和各类文件
1)备份数据文件:
RMAN> backup datafile '/u01/oradata/tinadb/ts_tina01.dbf'; --直接指定具体文件名
或者使用file_id
RMAN> backup datafile 5;
RMAN> backup as copy datafile 5 format '/orabak/df_%d%U'; --备份类型为镜像备份
RMAN> backup datafile 4,5,6 format '/orabak/df_%d_%U'; --备份类型为备份集
RMAN> list backup of datafile 5; --查看某个数据文件的备份片
必须是在开启归档模式的情况下,否则会报错:ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
2)备份控制文件:
RMAN> backup current controlfile;
或者
RMAN> sql "alter database backup controlfile to '/tmp/tinadb.control'";
RMAN> list backup of controlfile; --查看控制文件的备份片
RMAN> configure controlfile autobackup on; --开启控制文件的自动备份
RMAN> configure controlfile autobackup on; --关闭
当 autobackup 被置为on时,RMAN 做任何备份操作,都会自动对控制文件做备份
3)备份参数文件:
RMAN> backup spfile;
RMAN> backup spfile format '/orabak/sp_%d%U'; ---都是可以指定format的,当然也可以不要。
RMAN> list backup of spfile; --查看参数文件的备份片
4)备份表空间:
RMAN> backup tablespace users,ts_tina format '/orabak/tb_%d_%U';
临时表空间不需要备份。
5)备份数据库:
RMAN> backup database; ---直接备份全库
RMAN> backup database format '/orabak/whole_%d_%U'; ---指定备份的格式
RMAN> backup database include current controlfile; --连同控制文件一起全库备份
RMAN> backup database plus archivelog; --连同归档日志一起全库备份
RMAN> backup as compressed backupset database format '/orabak/whole_%d_%U'; --备份全库并压缩备份集
RMAN> run {
backup database
format '/orabak/full_%d_%T_%s'
plus archivelog
format '/orabak/arch_%d_%T_%s'
delete all input; }
增量备份level0 level1 level2
backup incremental level 0 database;
backup incremental level 1 database; --差异增量
backup incremental level 1 cumulative database; --累计增量
假设:
每半年做一个数据库的全备份
每一个月做一次零级备份
每个星期做一次一级备份 (备份的就是上次0/1级备份到当前所有的改变)0-1-1-1 这每个之间的改变
每天做一次一级累计备份 (备份的就是上次0级备份到当前所有的改变) 0----当前所有的改变,不管中间有没有其他备份
全库备份脚本
RMAN> run{
allocate channel c1 type disk; ---开3个通道
allocate channel c2 type disk;
allocate channel c3 type disk;
#for 11g database
backup as compressed backupset database TAG ${ORACLE_SID}_bk_whole format '${BK_PATH}/db_whole_${ORACLE_SID}_%U'; --目录和sid自己指定
#primary database
#backup format '${BK_PATH}/$ORACLE_SID.control_%t_%p_%s' current controlfile for standby;
#standby database or single instance
backup format '${BK_PATH}/$ORACLE_SID.control_%t_%p_%s' current controlfile;
release channel c1;
release channel c2;
release channel c3;
}
零级备份脚本
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
#for 11g database
backup as compressed backupset INCREMENTAL LEVEL=0 TAG ${ORACLE_SID}_bk_level_0 format '${BK_PATH}/db_0_${ORACLE_SID}_%U' database;
backup current controlfile format='${ORACLE_SID}_ctl_file_%t_%p_%s';
sql 'alter system archive log current';
#备份归档可选,可以单独定期备份
backup filesperset 3 format '/u01/oradata/backup/arch%u_%s_%p' archivelog all delete input;
release channel c1;
release channel c2;
release channel c3;
}
一级差异备份
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup as compressed backupset INCREMENTAL LEVEL=1 format '${BK_PATH}/db_1_${ORACLE_SID}_%U' database;
backup current controlfile format='${ORACLE_SID}_ctl_file_%t_%p_%s';
release channel c1;
release channel c2;
release channel c3;
}
一级累计备份
backup as compressed backupset INCREMENTAL LEVEL=1 format '${BK_PATH}/db_1_${ORACLE_SID}_%U' cumulative database;
备份脚本实例 ---可添加cron定期执行备份
#!/bin/bash
export ORACLE_HOME=/u01/oracle
export ORACLE_SID=tinadb
export BK_PATH=/orabak/${ORACLE_SID}
mkdir -p $BK_PATH
date > $BK_PATH/backup_${ORACLE_SID}.log
$ORACLE_HOME/bin/rman target / log $BK_PATH/backup_${ORACLE_SID}.log append <<EOF
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup as compressed backupset database format '${BK_PATH}/db_0_${ORACLE_SID}_%U';
backup format '${BK_PATH}/$ORACLE_SID.control' current controlfile;
sql 'alter system archive log current';
backup filesperset 8 archivelog all delete input format '/orabak/arch%u_%s_%p' ;
release channel c1;
release channel c2;
}
EOF
date >>$BK_PATH/backup_${ORACLE_SID}.log
$ORACLE_HOME/bin/sqlplus / as sysdba <<EOF
create pfile='$BK_PATH/${ORACLE_SID}_pfile' from spfile;
EOF
cp $ORACLE_HOME/dbs/orapw$ORACLE_SID $BK_PATH
cp $ORACLE_HOME/network/admin/*.ora $BK_PATH
5)备份归档日志:
RMAN> backup archivelog all delete input; --加上delete input 就是删除所有已经备份过的归档日志
RMAN> backup archivelog all delete input format '/orabak/arch_%T_%s_%U';
RMAN> backup archivelog sequence between 50 and 120 thread 1 delete input;
RMAN> backup archivelog from time "sysdate-15" until time "sysdate-7";
二、backup常用命令
1.设置备份标记
backup database tag='full_bak1';
注:每个标记必须唯一,相同的标记可以用于多个备份只还原最新的备份。
2.设置备份集大小(一次备份的所有结果为一个备份集,要注意备份集大小)
backup database maxsetsize=100m tag='datafile1';
注:maxsetsize限定备份集的大小。所以必须大于数据库总数据文件的大小,否则会报错。
RMAN-06183: datafile or datafile copy larger than MAXSETSIZE: file# 1 /data/oradata/system01.dbf
3.设置备份片大小(磁带或文件系统限制)
run {
allocate channel c1 type disk maxpicecsize 100m format '/data/backup/full_0_%U_%T';
backup database tag='full_0';
release channel c1;
}
可以在allocate子句中设定每个备份片的大小,以达到磁带或系统限制。
也可以在configure中设置备份片大小。
configure channel device type disk maxpiecesize 100 m;
configure channel device type disk clear;
4.备份集的保存策略
backup database keep forever; --永久保留备份文件
backup database keep until time='sysdate+30'; --保存备份30天
5.重写configure exclude命令
backup database noexclude keep forever tag='test backup';
6.检查数据库错误
backup validate database;
使用RMAN来扫描数据库的物理/逻辑错误,并不执行实际备份。
7.跳过脱机,不可存取或只读文件
backup database skip readonly;
backup database skip offline;
backup database skip inaccessible;
backup database skip readonly skip offline skip inaccessible;
8.强制备份
backup database force;
9.基于上次备份时间备份数据文件
1>只备份添加的新数据文件
backup database not backed up;
2>备份"在限定时间周期内"没有被备份的数据文件
backup database not backed up since time='sysdate-2';
10.备份操作期间检查逻辑错误
backup check logical database;
backup validate check logical database;
11.生成备份副本
backup database copies=2;
三、rman查看备份
1) List 当前RMAN所备份的数据库:
1.1. list backup summary; --概述可用的备份
list incarnation; --汇总查询
--如果备份文件多的话多用这两个list命令可以对备份文件有个总体了解。
B 表示backup
A 表示Archivelog、 F 表示full backup、 0,1,2 表示incremental level备份
A 表示可用AVALIABLE、 X 表示EXPIRED
1.2.list backup by file;--按照文件类型分别列出
分别为:数据文件列表、归档日志列表、控制文件列表、SPFILE列表
1.3.list backup;
这个命令列出已有备份集的详细信息。
1.4.list expired backup;
列出过期的备份文件
1.5.list copy;
列出copy文件
list copy of database;
list copy of controlfile;
list copy of tablespace users;
list copy of datafile n,n,n;
list copy of archivelog all;
list copy of archivelog from scn 10000;
list copy of archivelog until sequence 12;
2)List 相关文件的信息
list backup of {archivelog, controlfile, database, datafile, spfile, tablespace};
list backup of database; --full,incremental,tablespace,datafile
2.5归档日志:
list backup of archivelog {all, from, high, like, logseq, low, scn, sequence, time, until};
list backup of archivelog all;
list backup of archivelog until time 'sysdate-1';
list backup of archivelog from sequence 10;
list backup of archivelog until sequence 10;
list backup of archivelog from scn 10000;
list backup of archivelog until scn 200000;
list archivelog from scn 1000;
list archivelog until scn 2000;
list archivelog from sequence 10;
list archivelog until sequence 12;
四、rman配置策略
4.1 显示当前的配置信息
4.1.1 RMAN> show all;
RMAN 配置参数为:
RMAN configuration parameters for database with db_unique_name TINADB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/oracle/dbs/snapcf_tinadb.f'; # default
4.1.2 查询RMAN设置中非默认值:
SQL> select name,value from v$rman_configuration;
NAME VALUE
-------------- -----------------
CONTROLFILE AUTOBACKUP ON
4.2. 常用的configure选项
4.2.1 保存策略
configure retention policy to recovery window of 7 days;
configure retention policy to redundancy 5;
configure retention policy clear;
configure retention policy to none;
第一种recover window是保持所有足够的备份,可以将数据库系统恢复到最近七天内的任意时刻。
任何超过最近七天的数据库备份将被标记为obsolete。
第二种redundancy 是为了保持可以恢复的最新的5份数据库备份,任何超过最新5份的备份都将被标记为redundancy。它的默认值是1份。
第三四:NONE 可以把使备份保持策略失效,Clear 将恢复默认的保持策略
一般最安全的方法是采用第二种保持策略。
4.2.2 备份优化
configure backup optimization on;
configure backup optimization off;
configure backup optimization clear;
默认值为关闭,如果打开,rman将对备份的数据文件及归档等文件进行一种优化的算法。
4.2.3 默认设备
configure default device type to disk;
configure default device type to stb;
configure default device type clear;
是指定所有I/O操作的设备类型是硬盘或者磁带,默认值是硬盘.
4.3.4 控制文件
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/orabak/conf_%F';
configure controlfile autobackup clear;
configrue controlfile autobackup format for device type disk clear;
configrue snapshot controlfile name to '/orabak/scontrofile.snp';
configrue snapshot controlfile name clear;
--是配置控制文件的快照文件的存放路径和文件名,这个快照文件是在备份期间产生的,用于控制文件的读一致性。
强制数据库在备份文件或者执行改变数据库结构的命令之后将控制文件自动备份
4.3.5 并行数(通道数)
configure device type disk|stb parallelism 2;
configure device type disk|stb clear; --用于清除上面的信道配置
configure device type disk parallelism 1 backup type to copy; --将backup type设置为copy之后,则缺省的备份为镜像副本
configure channel device type disk format 'e/:rmanback_%U';
configure channel device type disk maxpiecesize 100m
configure channel device type disk rate 1200K
configure channel 1 device type disk format 'e/:rmanback_%U';
configure channel 2 device type disk format 'e/:rmanback_%U';
configure channel 1 device type disk maxpiecesize 100m
配置数据库设备类型的并行度。
4.3.6 生成备份副本
configure datafile backup copies for device type disk|stb to 3;
configure archivelog backup copies for device type disk|stb to 3;
--是设置数据库的归档日志的存放设备类型
configure datafile|archivelog backup copies for device type disk|stb clear
backup device type disk database format '/disk1/backup/%U', '/disk2/backup/%U', '/disk3/backup/%U';
是配置数据库的每次备份的copy数量,oracle的每一次备份都可以有多份完全相同的拷贝。
4.3.7 排除选项 exclude
configure exclude for tablespace 'users';
configrue exclude clear;
此命令用于将指定的表空间不备份到备份集中,此命令对只读表空间是非常有用的。
4.3.8 备份集大小 maxsetsize
configure maxsetsize to 1G|1000M|1000000K|unlimited;
configure maxsetsize clear;
4.3.9 归档删除
10g新增,两个值
applied on standby:设置该值,当通过附加的delete input字句删除standby数据仍需要的日志时,会提示rman-08137错误,
但用户仍可以手动通过delete archivelog删除.
none:设置该值,则不启用归档文件的删除策略,默认就是none.
rman>configure archivelog deletion policy to applied on standby;
rman>configure archivelog deletion policy to none;
[/size]
rman的功能非常强大,下面我们来一步步的学习
首先想到的是备份
一、rman备份数据库和各类文件
1)备份数据文件:
RMAN> backup datafile '/u01/oradata/tinadb/ts_tina01.dbf'; --直接指定具体文件名
或者使用file_id
RMAN> backup datafile 5;
RMAN> backup as copy datafile 5 format '/orabak/df_%d%U'; --备份类型为镜像备份
RMAN> backup datafile 4,5,6 format '/orabak/df_%d_%U'; --备份类型为备份集
RMAN> list backup of datafile 5; --查看某个数据文件的备份片
必须是在开启归档模式的情况下,否则会报错:ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
2)备份控制文件:
RMAN> backup current controlfile;
或者
RMAN> sql "alter database backup controlfile to '/tmp/tinadb.control'";
RMAN> list backup of controlfile; --查看控制文件的备份片
RMAN> configure controlfile autobackup on; --开启控制文件的自动备份
RMAN> configure controlfile autobackup on; --关闭
当 autobackup 被置为on时,RMAN 做任何备份操作,都会自动对控制文件做备份
3)备份参数文件:
RMAN> backup spfile;
RMAN> backup spfile format '/orabak/sp_%d%U'; ---都是可以指定format的,当然也可以不要。
RMAN> list backup of spfile; --查看参数文件的备份片
4)备份表空间:
RMAN> backup tablespace users,ts_tina format '/orabak/tb_%d_%U';
临时表空间不需要备份。
5)备份数据库:
RMAN> backup database; ---直接备份全库
RMAN> backup database format '/orabak/whole_%d_%U'; ---指定备份的格式
RMAN> backup database include current controlfile; --连同控制文件一起全库备份
RMAN> backup database plus archivelog; --连同归档日志一起全库备份
RMAN> backup as compressed backupset database format '/orabak/whole_%d_%U'; --备份全库并压缩备份集
RMAN> run {
backup database
format '/orabak/full_%d_%T_%s'
plus archivelog
format '/orabak/arch_%d_%T_%s'
delete all input; }
增量备份level0 level1 level2
backup incremental level 0 database;
backup incremental level 1 database; --差异增量
backup incremental level 1 cumulative database; --累计增量
假设:
每半年做一个数据库的全备份
每一个月做一次零级备份
每个星期做一次一级备份 (备份的就是上次0/1级备份到当前所有的改变)0-1-1-1 这每个之间的改变
每天做一次一级累计备份 (备份的就是上次0级备份到当前所有的改变) 0----当前所有的改变,不管中间有没有其他备份
全库备份脚本
RMAN> run{
allocate channel c1 type disk; ---开3个通道
allocate channel c2 type disk;
allocate channel c3 type disk;
#for 11g database
backup as compressed backupset database TAG ${ORACLE_SID}_bk_whole format '${BK_PATH}/db_whole_${ORACLE_SID}_%U'; --目录和sid自己指定
#primary database
#backup format '${BK_PATH}/$ORACLE_SID.control_%t_%p_%s' current controlfile for standby;
#standby database or single instance
backup format '${BK_PATH}/$ORACLE_SID.control_%t_%p_%s' current controlfile;
release channel c1;
release channel c2;
release channel c3;
}
零级备份脚本
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
#for 11g database
backup as compressed backupset INCREMENTAL LEVEL=0 TAG ${ORACLE_SID}_bk_level_0 format '${BK_PATH}/db_0_${ORACLE_SID}_%U' database;
backup current controlfile format='${ORACLE_SID}_ctl_file_%t_%p_%s';
sql 'alter system archive log current';
#备份归档可选,可以单独定期备份
backup filesperset 3 format '/u01/oradata/backup/arch%u_%s_%p' archivelog all delete input;
release channel c1;
release channel c2;
release channel c3;
}
一级差异备份
RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
backup as compressed backupset INCREMENTAL LEVEL=1 format '${BK_PATH}/db_1_${ORACLE_SID}_%U' database;
backup current controlfile format='${ORACLE_SID}_ctl_file_%t_%p_%s';
release channel c1;
release channel c2;
release channel c3;
}
一级累计备份
backup as compressed backupset INCREMENTAL LEVEL=1 format '${BK_PATH}/db_1_${ORACLE_SID}_%U' cumulative database;
备份脚本实例 ---可添加cron定期执行备份
#!/bin/bash
export ORACLE_HOME=/u01/oracle
export ORACLE_SID=tinadb
export BK_PATH=/orabak/${ORACLE_SID}
mkdir -p $BK_PATH
date > $BK_PATH/backup_${ORACLE_SID}.log
$ORACLE_HOME/bin/rman target / log $BK_PATH/backup_${ORACLE_SID}.log append <<EOF
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup as compressed backupset database format '${BK_PATH}/db_0_${ORACLE_SID}_%U';
backup format '${BK_PATH}/$ORACLE_SID.control' current controlfile;
sql 'alter system archive log current';
backup filesperset 8 archivelog all delete input format '/orabak/arch%u_%s_%p' ;
release channel c1;
release channel c2;
}
EOF
date >>$BK_PATH/backup_${ORACLE_SID}.log
$ORACLE_HOME/bin/sqlplus / as sysdba <<EOF
create pfile='$BK_PATH/${ORACLE_SID}_pfile' from spfile;
EOF
cp $ORACLE_HOME/dbs/orapw$ORACLE_SID $BK_PATH
cp $ORACLE_HOME/network/admin/*.ora $BK_PATH
5)备份归档日志:
RMAN> backup archivelog all delete input; --加上delete input 就是删除所有已经备份过的归档日志
RMAN> backup archivelog all delete input format '/orabak/arch_%T_%s_%U';
RMAN> backup archivelog sequence between 50 and 120 thread 1 delete input;
RMAN> backup archivelog from time "sysdate-15" until time "sysdate-7";
二、backup常用命令
1.设置备份标记
backup database tag='full_bak1';
注:每个标记必须唯一,相同的标记可以用于多个备份只还原最新的备份。
2.设置备份集大小(一次备份的所有结果为一个备份集,要注意备份集大小)
backup database maxsetsize=100m tag='datafile1';
注:maxsetsize限定备份集的大小。所以必须大于数据库总数据文件的大小,否则会报错。
RMAN-06183: datafile or datafile copy larger than MAXSETSIZE: file# 1 /data/oradata/system01.dbf
3.设置备份片大小(磁带或文件系统限制)
run {
allocate channel c1 type disk maxpicecsize 100m format '/data/backup/full_0_%U_%T';
backup database tag='full_0';
release channel c1;
}
可以在allocate子句中设定每个备份片的大小,以达到磁带或系统限制。
也可以在configure中设置备份片大小。
configure channel device type disk maxpiecesize 100 m;
configure channel device type disk clear;
4.备份集的保存策略
backup database keep forever; --永久保留备份文件
backup database keep until time='sysdate+30'; --保存备份30天
5.重写configure exclude命令
backup database noexclude keep forever tag='test backup';
6.检查数据库错误
backup validate database;
使用RMAN来扫描数据库的物理/逻辑错误,并不执行实际备份。
7.跳过脱机,不可存取或只读文件
backup database skip readonly;
backup database skip offline;
backup database skip inaccessible;
backup database skip readonly skip offline skip inaccessible;
8.强制备份
backup database force;
9.基于上次备份时间备份数据文件
1>只备份添加的新数据文件
backup database not backed up;
2>备份"在限定时间周期内"没有被备份的数据文件
backup database not backed up since time='sysdate-2';
10.备份操作期间检查逻辑错误
backup check logical database;
backup validate check logical database;
11.生成备份副本
backup database copies=2;
三、rman查看备份
1) List 当前RMAN所备份的数据库:
1.1. list backup summary; --概述可用的备份
list incarnation; --汇总查询
--如果备份文件多的话多用这两个list命令可以对备份文件有个总体了解。
B 表示backup
A 表示Archivelog、 F 表示full backup、 0,1,2 表示incremental level备份
A 表示可用AVALIABLE、 X 表示EXPIRED
1.2.list backup by file;--按照文件类型分别列出
分别为:数据文件列表、归档日志列表、控制文件列表、SPFILE列表
1.3.list backup;
这个命令列出已有备份集的详细信息。
1.4.list expired backup;
列出过期的备份文件
1.5.list copy;
列出copy文件
list copy of database;
list copy of controlfile;
list copy of tablespace users;
list copy of datafile n,n,n;
list copy of archivelog all;
list copy of archivelog from scn 10000;
list copy of archivelog until sequence 12;
2)List 相关文件的信息
list backup of {archivelog, controlfile, database, datafile, spfile, tablespace};
list backup of database; --full,incremental,tablespace,datafile
2.5归档日志:
list backup of archivelog {all, from, high, like, logseq, low, scn, sequence, time, until};
list backup of archivelog all;
list backup of archivelog until time 'sysdate-1';
list backup of archivelog from sequence 10;
list backup of archivelog until sequence 10;
list backup of archivelog from scn 10000;
list backup of archivelog until scn 200000;
list archivelog from scn 1000;
list archivelog until scn 2000;
list archivelog from sequence 10;
list archivelog until sequence 12;
四、rman配置策略
4.1 显示当前的配置信息
4.1.1 RMAN> show all;
RMAN 配置参数为:
RMAN configuration parameters for database with db_unique_name TINADB are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/oracle/dbs/snapcf_tinadb.f'; # default
4.1.2 查询RMAN设置中非默认值:
SQL> select name,value from v$rman_configuration;
NAME VALUE
-------------- -----------------
CONTROLFILE AUTOBACKUP ON
4.2. 常用的configure选项
4.2.1 保存策略
configure retention policy to recovery window of 7 days;
configure retention policy to redundancy 5;
configure retention policy clear;
configure retention policy to none;
第一种recover window是保持所有足够的备份,可以将数据库系统恢复到最近七天内的任意时刻。
任何超过最近七天的数据库备份将被标记为obsolete。
第二种redundancy 是为了保持可以恢复的最新的5份数据库备份,任何超过最新5份的备份都将被标记为redundancy。它的默认值是1份。
第三四:NONE 可以把使备份保持策略失效,Clear 将恢复默认的保持策略
一般最安全的方法是采用第二种保持策略。
4.2.2 备份优化
configure backup optimization on;
configure backup optimization off;
configure backup optimization clear;
默认值为关闭,如果打开,rman将对备份的数据文件及归档等文件进行一种优化的算法。
4.2.3 默认设备
configure default device type to disk;
configure default device type to stb;
configure default device type clear;
是指定所有I/O操作的设备类型是硬盘或者磁带,默认值是硬盘.
4.3.4 控制文件
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/orabak/conf_%F';
configure controlfile autobackup clear;
configrue controlfile autobackup format for device type disk clear;
configrue snapshot controlfile name to '/orabak/scontrofile.snp';
configrue snapshot controlfile name clear;
--是配置控制文件的快照文件的存放路径和文件名,这个快照文件是在备份期间产生的,用于控制文件的读一致性。
强制数据库在备份文件或者执行改变数据库结构的命令之后将控制文件自动备份
4.3.5 并行数(通道数)
configure device type disk|stb parallelism 2;
configure device type disk|stb clear; --用于清除上面的信道配置
configure device type disk parallelism 1 backup type to copy; --将backup type设置为copy之后,则缺省的备份为镜像副本
configure channel device type disk format 'e/:rmanback_%U';
configure channel device type disk maxpiecesize 100m
configure channel device type disk rate 1200K
configure channel 1 device type disk format 'e/:rmanback_%U';
configure channel 2 device type disk format 'e/:rmanback_%U';
configure channel 1 device type disk maxpiecesize 100m
配置数据库设备类型的并行度。
4.3.6 生成备份副本
configure datafile backup copies for device type disk|stb to 3;
configure archivelog backup copies for device type disk|stb to 3;
--是设置数据库的归档日志的存放设备类型
configure datafile|archivelog backup copies for device type disk|stb clear
backup device type disk database format '/disk1/backup/%U', '/disk2/backup/%U', '/disk3/backup/%U';
是配置数据库的每次备份的copy数量,oracle的每一次备份都可以有多份完全相同的拷贝。
4.3.7 排除选项 exclude
configure exclude for tablespace 'users';
configrue exclude clear;
此命令用于将指定的表空间不备份到备份集中,此命令对只读表空间是非常有用的。
4.3.8 备份集大小 maxsetsize
configure maxsetsize to 1G|1000M|1000000K|unlimited;
configure maxsetsize clear;
4.3.9 归档删除
10g新增,两个值
applied on standby:设置该值,当通过附加的delete input字句删除standby数据仍需要的日志时,会提示rman-08137错误,
但用户仍可以手动通过delete archivelog删除.
none:设置该值,则不启用归档文件的删除策略,默认就是none.
rman>configure archivelog deletion policy to applied on standby;
rman>configure archivelog deletion policy to none;
[/size]