Oracle备份恢复四(RMAN备份)-阿里云开发者社区

开发者社区> 余二五> 正文

Oracle备份恢复四(RMAN备份)

简介:
+关注继续查看

Oracle备份恢复四(RMAN备份)

    平台:Redhat linux as5,Oracle10g
    RMAN备份是指用恢复管理器备份数据文件,控制文件,归档日志和spfile的方法,前面手动备份(用户管理)的备份要借助OS命令执行备份操作,RMAN备份由目标数据库的服务器进程来完.RMAN备份中有三个新概念,备份集,备份片和映像副本,备份集是RMAN提供的一种用于存储备份信息的逻辑结构,备份片是用于存储备份集信息的二进制文件,也就是OS上的一个个文件,映像副本类似手动的备份,是单个数据文件,单个控制文件单个归档日志的完整备份文件.

完全数据库备份

1.一致性备份(冷备)完整过程
RMAN> connect target /
connected to target database: DB2 (DBID=1852673443)
RMAN> shutdown immediate;
RMAN> startup mount;
#
RMAN> backup database format='/oracle/rmanback/%d_%s.dbf';
Starting backup at 12-JUN-09
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=35 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/oracle/oracle/oradata/db2/system01.dbf
input datafile fno=00003 name=/home/oracle/oracle/oradata/db2/sysaux01.dbf
input datafile fno=00002 name=/home/oracle/oracle/oradata/db2/undotbs01.dbf
input datafile fno=00004 name=/home/oracle/oracle/oradata/db2/usertbs.dbf
channel ORA_DISK_1: starting piece 1 at 12-JUN-09
channel ORA_DISK_1: finished piece 1 at 12-JUN-09
piece handle=/oracle/rmanback/DB2_1.dbf tag=TAG20090612T071426 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 12-JUN-09
channel ORA_DISK_1: finished piece 1 at 12-JUN-09
piece handle=/oracle/rmanback/DB2_2.dbf tag=TAG20090612T071426 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 12-JUN-09
RMAN> sql 'alter database open';
RMAN> sql 'alter system archive log current';
    这样一个数据库就备份完了,通过上面的输出可以看到,把表空间,数据文件,控制文件,SPFILE都备份了,其中表空间,数据文件都备在DB2_1.dbf,控制文件和spfile保存在DB2_2.dbf,(比手动备份简单多了)
    查看备份后的文件
[oracle@oracle rmanback]$ pwd
/oracle/rmanback
[oracle@oracle rmanback]$ ls
DB2_1.dbf  DB2_2.dbf
2.非一致性备份
    因为一致性备份要中断业务,一般使用非一致性备份,但非一致性备份一定要在归档模式下.
RMAN> connect target sys/123456
RMAN> backup database format='/oracle/rmanback/%d_%s.dbf';
[oracle@oracle rmanback]$ ls
DB2_1.dbf  DB2_2.dbf  DB2_3.dbf  DB2_4.dbf

备份表空间

    下面以表空间chenxy为例
RMAN> connect target sys/123456
RMAN> backup tablespace chenxy format='/oracle/rmanback/%N_%s.dbf';
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00005 name=/home/oracle/oracle/oradata/db2/chenxy.dbf
input datafile fno=00005 name=/home/oracle/oracle/oradata/db2/chenpy.dbf
channel ORA_DISK_1: starting piece 1 at 12-JUN-09
Finished backup at 12-JUN-09
[oracle@oracle rmanback]$ ls
CHENXY_6.dbf  CHENXY_7.dbf  DB2_1.dbf  DB2_2.dbf  DB2_3.dbf  DB2_4.dbf
    可以看到备份表空间就是把表空间内的所有数据文件备份下来
备份单个数据文件
RMAN> connect target sys/123456
RMAN> backup datafile 5 format='/oracle/rmanback/%N_%f_%s.dbf';
备份控制文件和归档日志
#份控制文件
RMAN> backup current controlfile format='/oracle/rmanback/%d_%s.ctl';
#份前一天的档日志
RMAN> backup format='/oracle/rmanback/%d_%s.arc'
2> archivelog from time='sysdate-1' until time='sysdate';
#时备份数据文件和档日志
RMAN> backup format '/oracle/rmanback/%d_%s.bak' tablespace chenxy plus archivelog;

备份映像副本

1.数据文件副本
RMAN> backup as copy format='/oracle/rmanback/df_5.dbf' datafile 5;
2.控制文件副本
RMAN> copy current controlfile to '/oracle/rmanback/db2.ctl';
[oracle@oracle rmanback]$ ls
db2.ctl  df_5.dbf
3.归档日志副本
RMAN> backup as copy format='/oracle/rmanback/arc30.log' archivelog sequence 30;
RMAN> copy archivelog '/home/oracle/oracle/oradata/db2/arch/1_31_689217827.dbf'
2> to '/oracle/rmanback/arc31.log';
[oracle@oracle rmanback]$ ll
total 678288
-rw-r----- 1 oracle oinstall  23883776 Jun 12 08:16 arc30.log
-rw-r----- 1 oracle oinstall      1024 Jun 12 08:18 arc31.log
4.一次备份多个映像副本
RMAN> configure device type disk parallelism 3;
RMAN> backup as copy format='/oracle/rmanback/df_%f.dbf' datafile 2,3,4;

RMAN备份维护

1.报告目标数据库
RMAN>report schema;
RMAN>report need backup incremental 3;
RMAN>report need backup days 3 tablespace chenxy;
RMAN>report need backup redundancy 2 database;
RMAN>report obsolete redundancy 2;
RMAN>report unrecoverable;
2.详细分析RMAN资料库
RMAN>list backup of tablespace chenxy;
RMAN>list backup of controlfile;
RMAN>list backup of archivelog all;
RMAN>list backup of spfile;
RMAN>list copy of datafile 5;
RMAN>list copy of controlfile;
RMAN>list copy of archivelog;
RMAN>list incarnation of database;
3.核对磁盘和磁带上的备份文件
RMAN>crosscheck backup;
RMAN>crosscheck backup of database;
RMAN>crosscheck backup of tablespace system;
RMAN>crosscheck backup of datafile 4;
RMAN>crosscheck backup of controlfile;
RMAN>crosscheck backup of spfile;
RMAN>crosscheck backup of archivelog sequence 3;
RMAN>crosscheck backup of copy;
RMAN>crosscheck backup of database;
RMAN>crosscheck backup of tablespace users;
4.删除备份记录及相就的物理文件
RMAN>delete obsolete;
RMAN>delete noprompt expired backup;
RMAN>delete noprompt expired copy;
RMAN>delete noprompt backupset 12;
RMAN>delete noprompt backuppiece ‘/oracle/rmanback/ctl.bak’;
RMAN>delete noprompt backup;
RMAN>delete noprompt datafilecopy ‘/oracle/rmanback/*.bak’;
RMAN>delete noprompt copy;
RMAN>backup archivelog all delete input;
5.改变备份记录的状态
RMAN>change backupset 2 unavailable;
RMAN>change datafilecopy ‘/oracle/rmanback/*.bak’ unavailable;
RMAN>change backupset 10 keep forerer logs;
RMAN>change backupset 200 keep until time ‘sysdate+60’ logs;
RMAN>change backupset 20 nokeep;
6.追加备份记录到RMAN资料库
RMAN>catalog datafilecopy ‘/oracle/rmanback/chenxy01.bak’;
RMAN>catalog backuppiece ‘/oracle/rmanback/chenxy_10.dbf’;
RMAN>catalog start with ‘/oracle/rmanback’;
#
RMAN>change datafilecopy ‘/oracle/rmanback/chenxy01.bak’ uncatalog;
RMAN>change controlfilecopy ‘‘/oracle/rmanback/db2.ctl’ uncatalog;
RMAN>change backuppiece ‘/oracle/rmanback/chenxy02.bak’ uncatalog;





本文转自 vfast_chenxy 51CTO博客,原文链接:http://blog.51cto.com/chenxy/171360,如需转载请自行联系原作者

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
[20161220]rman恢复时间点的疑问.txt
[20161220]rman恢复时间点的疑问.txt --昨天在恢复时遇到缺少归档的问题,自己开始感觉奇怪,做一点分析记录. RMAN> list backupset summary ; List of Backups =============== ...
841 0
博客链接—Oracle备份与恢复
001 Oracle数据库的可恢复性设置:http://blog.itpub.net/29067253/viewspace-1986010/ 002 Oracle备份与恢复入门:http://blog.
693 0
Oracle数据库的可恢复性设置
整理自《Oracle 11g OCP/OCA 认证指南》 001     为了保证数据库的最大可恢复性,必须多路复用控制文件;必须多路复用联机重做日志;必须以归档日志模式运行数据库,并多路复用归档日志文件;最后必须作常规备份。
864 0
[20121127]rman备份数据文件大小与truncate.txt
[20121127]rman备份数据文件大小与truncate.txt记得以前看rman的书,rman仅仅备份已经格式话的块,如果这样一个表被truncate后,即使空间回收了。
836 0
Oracle实例恢复机制
整理自《OCP/OCA认证考试指南》 001      实例恢复不仅可以重新构成在崩溃时未被保存至数据文件的任何已提交事务,而且可以回滚已被写至数据文件的任何未提交事务。
795 0
Oracle备份与恢复入门
整理自《Oracle database 11g RMAN备份与恢复》001 逻辑备份与恢复     Oracle database 11g使用Oracle data pump体系结构来支持逻辑备份和恢复。
950 0
+关注
20382
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载