Oracle深度学习笔记RMAN备份常用命令

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

31.Oracle深度学习笔记——RMAN备份常用命令
连接到目标数据库
(不使用恢复目录数据库)
$rman target / nocatalog
显示rman配置
RMAN> show all;
报告目标数据库的物理结构
REPORT
RMAN> report schema;
报告陈旧备份
RMAN> report obsolete;
报告不可恢复的数据文件
RMAN> report unrecoverable;
RMAN> report need backup;
RMAN> report need backup days=1;
RMAN> report need backup incremental=3;
说明:需要多少个增量备份文件才能恢复的数据文件。

RMAN> report need backup redundancy=2;
说明:报告冗余文件小于2次的数据文件
RMAN> report need backup recovery window of 2 days;
报告出恢复需要2天的归档日志的数据文件。

备份脚本
run{
allocate channel c1 type disk format '/home/oracle/rmanbk/%d_%I_%s_%p_%T.bkp'; allocate channel c2 type disk format '/home/oracle/rmanbk/%d_%I_%s_%p_%T.bkp'; backup
(datafile 5 channel c1)
(datafile 6 channel c2);
release channel c1;
release channel c2;
}
列出备份信息
RMAN> list backup;
RMAN> list backup of database;
RMAN> list backup of tablespace table_name;
RMAN> list backup of controlfile;
RMAN> list backup of spfile;
RMAN> list backupset id;
列出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;
校验备份
RMAN> crosscheck backup;
RMAN> crosscheck backup of database;
RMAN> crosscheck backup of tablespace system;
RMAN> crosscheck backup of controlfile;
RMAN> crosscheck backup of spfile;
RMAN> crosscheck backup of archivelog all;
校验没有备份过的归档日志
RMAN>crosscheck archivelog all;
RMAN>delete noprompt expired archivelog all;
delete命令
删除相关的备份集或镜像副本的物理文件,同时将删除标记DELETE更新到控制文件,如果使用恢复目录,则是清除恢复目录内的备份集。

RMAN> delete archivelog all;
RMAN> delete backupset;
RMAN> delete backupset n;
RMAN> delete obsolete ;
RMAN> delete obsolete redundancy 2;
RMAN> delete noprompt copy;
RMAN> delete noprompt backupset tag TAG20101016T143521;
RMAN> delete obsolete recovery window of 7 days;
RMAN> delete expired backupset;
RMAN> delete expired copy;
RMAN> delete expired archivelog all;
RMAN> delete archivelog until time 'sysdate-5';
RMAN> delete force archivelog until time 'sysdate -1';
RMAN> delete noprompt force archivelog until time 'sysdate -2';
RMAN> delete expired archivelog all;
RMAN> delete obsolete; -- 删除陈旧备份
RMAN> delete noprompt obsolete;
RMAN> delete expired backup;
--删除所有expired的备份(包括归档日志、控制文件、备份聚)
RMAN> delete expired ;
RMAN> delete backupset id;
RMAN> delete backup; -- 删除所有备份
改变备份集的状态
RMAN> change backupset id unavailable;
改为长期备份
RMAN> change backupset id keep forever logs;
RMAN> change backupset id keep until time 'sysdate+30' logs;
RMAN> change backupset id nokeep;
基于时间:
RMAN>configure retention policy to recovery window of 30 days;
基于冗余数量:
CONFIGURE RETENTION POLICY TO REDUNDANCY n ;
取消备份保留策略:
CONFIGURE RETENTION POLICY TO NONE;
设置归档日志存放在其它位置
set archivelog destination to 'e:\temp';
常用的configure选项
保存策略(retention policy)
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 将恢复默认的保持策略一般最安全的方法是采用第二种保持策略。

备份优化backup optimization
configure backup optimization on;
configure backup optimization off;
configure backup optimization clear;
默认值为关闭,如果打开,rman将对备份的数据文件及归档等文件进行一种优化的算法。

默认设备default device type
configure default device type to disk;
configure default device type to stb;
configure default device type clear;
是指定所有I/O操作的设备类型是硬盘或者磁带,默认值是硬盘
磁带的设置是CONFIGURE DEFAULT DEVICE TYPE TO SBT;
控制文件controlfile
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/cfs01/backup/conf/conf_%F'; configure controlfile autobackup clear;
configrue controlfile autobackup format for device type disk clear;
configrue snapshot controlfile name to '/cfs01/backup/snapcf/scontrofile.snp';
--是配置控制文件的快照文件的存放路径和文件名,这个快照文件是在备份期间产生的,用于控制文件的读一致性。

configrue snapshot controlfile name clear;
强制数据库在备份文件或者执行改变数据库结构的命令之后将控制文件自动备份,默认值为关闭。

这样可以避免控制文件和catalog丢失后,控制文件仍然可以恢复。

并行数(通道数) device type disk|stb pallelism n;
configure device type disk|stb parallelism 2;
configure device type disk|stb clear; --用于清除上面的信道配置
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
配置数据库设备类型的并行度。

生成备份副本datafile|archivelog backup copies
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的每一次备份都可以有多份完全相同的拷贝。

排除选项exclude
configure exclude for tablespace 'users';
configrue exclude clear;
此命令用于将指定的表空间不备份到备份集中,此命令对只读表空间是非常有用的。

备份集大小maxsetsize
configure maxsetsize to 1G|1000M|1000000K|unlimited;
configure maxsetsize clear;
其它选项auxiliary
CONFIGURE AUXNAME FOR DATAFILE 1 TO '/oracle/auxfiles/aux_1.f';
CONFIGURE AUXNAME FOR DATAFILE 2 TO '/oracle/auxfiles/aux_2.f';
CONFIGURE AUXNAME FOR DATAFILE 3 TO '/oracle/auxfiles/aux_3.f';
CONFIGURE AUXNAME FOR DATAFILE 4 TO '/oracle/auxfiles/aux_4.f';
CONFIGURE AUXNAME FOR DATAFILE 1 CLEAR;
CONFIGURE AUXNAME FOR DATAFILE 2 CLEAR;
CONFIGURE AUXNAME FOR DATAFILE 3 CLEAR;
CONFIGURE AUXNAME FOR DATAFILE 4 CLEAR;
change
改变备份集状态
可用CHANGE BACKUPSET .. UNAVAILABLE/AVAILABLE 来改变一个备份集的状态。

RMAN>CHANGE BACKUPSET 22 UNAVAILABLE
改变映像副本状态
数据文件:CHANGE DATAFILECOPY .. AVAILABLE/UNAVAILABLE
控制文件:CHANGE CONTROLFILECOPY .. AVAILABLE/UNAVAILABLE
归档日志:CHANGE ARCHIVELOG .. AVAILABLE/UNAVAILABLE
例如:
RMAN>CHANGE DATAFILECOPY 'D:\BACKUP\DEMO_37.BAK' UNAVAILABLE;
建立长期备份
长期备份是指被长期保留的备份文件,使用长期备份的目的是为了可以将数据库恢复到过去的特定时间点。

当社顶了长期备份之后,RMAN会从设备冗余策略中
免除该备份文件,也就是说,长期备份文件不会被标记为陈旧备份。

命令:CHANGE .. KEEP/NOKEEP
(1)使备份集156永久保留
RMAN>CHANGE BACKUPSET 156 KEEP FOREVER LOGS;
(2)使备份集198保留60天
RMAN>CHANGE BACKUPSET 198 KEEP UNTIL TIME 'SYSDATE+60' LOGS;
(3)免除备份集156的保留期限
RMAN>CHANGE BACKUPSET 156 NOKEEP。

相关文档
最新文档