[Oracle] 最简单的RMAN配置、备份及恢复(1) - 设置RMAN及备份

博客首页 » Oracle 最简单的RMAN配置、备份及恢复(1) - 设置RMAN及备份

发布于 08 Jun 2014 03:37
标签 blog
Oracle无疑是一个复杂的软件,不过它的基本使用远没有这么复杂。其中RMAN是Oracle的备份软件。其实配置好以后,最简单的备份只需要两句话。

下面就介绍这套配置和备份使用方法。

虽然Oracle的备份选项很多,不过这个备份设置是经过多年生产环境检验的。并且与其他的设定独立性、兼容性都很好。

设置RMAN及备份

准备工作,建备份目录。
#设定ORACLE_SID
#Linux/Unix/Mac下
export ORACLE_SID=test02
#Windows下
set ORACLE_SID=test02
 
mkdir -p /u04/oradata/test02t/rman

启动rman

#启动rman,其中 target是连接的数据库USER和PASSWORD,nocatalog是无rman catalog
rman target / nocatalog
 
#也可省略为 rman target /
输入rman命令设置
#检查默认配置
show all;
 
#只用更改三个配置
 
#指定control file自动备份的目录和命名规则
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u04/oradata/test02t/rman/ctl_%F.bak';
 
#把control file自动备份打开
CONFIGURE CONTROLFILE AUTOBACKUP ON;
 
#指定backup的目录和命名规则
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u04/oradata/test02t/rman/bk_%d_%U_%T.bkp';
备份数据库
#可以开始备份了
backup as compressed backupset database plus archivelog delete input;
 
#删除多余的备份
delete noprompt obsolete;
完整地执行log如下
[scripts oracle@test03] export ORACLE_SID=test02t
[scripts oracle@test03] mkdir -p /u04/oradata/test02t/rman/current
[scripts oracle@test03] mkdir -p /u04/oradata/test02t/rman/current
[scripts oracle@test03] rman target /
 
Recovery Manager: Release 10.2.0.4.0 - Production on Wed Sep 4 16:26:27 2013
 
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
 
connected to target database: test02t (DBID=2513594778)
 
RMAN> show all;
 
using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
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 ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/oracle/app/oracle/product/10.2.0/db_1/dbs/snapcf_test02t.f'; # default
 
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u04/oradata/test02t/rman/bk_%d_%U_%T.bkp';
 
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u04/oradata/test02t/rman/bk_%d_%U_%T.bkp';
new RMAN configuration parameters are successfully stored
 
RMAN>
user interrupt received
 
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u04/oradata/test02t/rman/bk_%d_%U_%T.bkp';
 
old RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u04/oradata/test02t/rman/bk_%d_%U_%T.bkp';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u04/oradata/test02t/rman/bk_%d_%U_%T.bkp';
new RMAN configuration parameters are successfully stored
 
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
 
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
 
RMAN> show all;
 
using target database control file instead of recovery catalog
RMAN configuration parameters 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 '/u04/oradata/test02t/rman/ctl_%F.bak';
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 CHANNEL DEVICE TYPE DISK FORMAT   '/u04/oradata/test02t/rman/bk_%d_%U_%T.bkp';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/oracle/app/oracle/product/10.2.0/db_1/dbs/snapcf_test02t.f'; # default
 
RMAN> backup as compressed backupset database plus archivelog delete input;
 
Starting backup at 04-SEP-13
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=115 devtype=DISK
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=11 recid=1 stamp=825194389
input archive log thread=1 sequence=12 recid=2 stamp=825194398
input archive log thread=1 sequence=13 recid=3 stamp=825194410
input archive log thread=1 sequence=14 recid=4 stamp=825194423
input archive log thread=1 sequence=15 recid=5 stamp=825194435
input archive log thread=1 sequence=16 recid=6 stamp=825194462
input archive log thread=1 sequence=17 recid=7 stamp=825194480
input archive log thread=1 sequence=18 recid=8 stamp=825194498
input archive log thread=1 sequence=19 recid=9 stamp=825194591
input archive log thread=1 sequence=20 recid=10 stamp=825195129
input archive log thread=1 sequence=21 recid=11 stamp=825195141
input archive log thread=1 sequence=22 recid=12 stamp=825195163
input archive log thread=1 sequence=23 recid=13 stamp=825195190
input archive log thread=1 sequence=24 recid=14 stamp=825195206
input archive log thread=1 sequence=25 recid=15 stamp=825195283
input archive log thread=1 sequence=26 recid=16 stamp=825195358
input archive log thread=1 sequence=27 recid=17 stamp=825195373
input archive log thread=1 sequence=28 recid=18 stamp=825195457
input archive log thread=1 sequence=29 recid=19 stamp=825195476
input archive log thread=1 sequence=30 recid=20 stamp=825199207
input archive log thread=1 sequence=31 recid=21 stamp=825265912
input archive log thread=1 sequence=32 recid=22 stamp=825266177
channel ORA_DISK_1: starting piece 1 at 04-SEP-13
channel ORA_DISK_1: finished piece 1 at 04-SEP-13
piece handle=/u04/oradata/test02t/rman/bk_test02t_02oj1402_1_1_20130904.bkp tag=TAG20130904T163618 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u04/oradata/ipadlbst/arch/1_11_825193754.dbf recid=1 stamp=825194389
archive log filename=/u04/oradata/ipadlbst/arch/1_12_825193754.dbf recid=2 stamp=825194398
archive log filename=/u04/oradata/ipadlbst/arch/1_13_825193754.dbf recid=3 stamp=825194410
archive log filename=/u04/oradata/ipadlbst/arch/1_14_825193754.dbf recid=4 stamp=825194423
archive log filename=/u04/oradata/ipadlbst/arch/1_15_825193754.dbf recid=5 stamp=825194435
archive log filename=/u04/oradata/ipadlbst/arch/1_16_825193754.dbf recid=6 stamp=825194462
archive log filename=/u04/oradata/ipadlbst/arch/1_17_825193754.dbf recid=7 stamp=825194480
archive log filename=/u04/oradata/ipadlbst/arch/1_18_825193754.dbf recid=8 stamp=825194498
archive log filename=/u04/oradata/ipadlbst/arch/1_19_825193754.dbf recid=9 stamp=825194591
archive log filename=/u04/oradata/ipadlbst/arch/1_20_825193754.dbf recid=10 stamp=825195129
archive log filename=/u04/oradata/ipadlbst/arch/1_21_825193754.dbf recid=11 stamp=825195141
archive log filename=/u04/oradata/ipadlbst/arch/1_22_825193754.dbf recid=12 stamp=825195163
archive log filename=/u04/oradata/ipadlbst/arch/1_23_825193754.dbf recid=13 stamp=825195190
archive log filename=/u04/oradata/ipadlbst/arch/1_24_825193754.dbf recid=14 stamp=825195206
archive log filename=/u04/oradata/ipadlbst/arch/1_25_825193754.dbf recid=15 stamp=825195283
archive log filename=/u04/oradata/ipadlbst/arch/1_26_825193754.dbf recid=16 stamp=825195358
archive log filename=/u04/oradata/ipadlbst/arch/1_27_825193754.dbf recid=17 stamp=825195373
archive log filename=/u04/oradata/ipadlbst/arch/1_28_825193754.dbf recid=18 stamp=825195457
archive log filename=/u04/oradata/ipadlbst/arch/1_29_825193754.dbf recid=19 stamp=825195476
archive log filename=/u04/oradata/ipadlbst/arch/1_30_825193754.dbf recid=20 stamp=825199207
archive log filename=/u04/oradata/ipadlbst/arch/1_31_825193754.dbf recid=21 stamp=825265912
archive log filename=/u04/oradata/ipadlbst/arch/1_32_825193754.dbf recid=22 stamp=825266177
Finished backup at 04-SEP-13
 
Starting backup at 04-SEP-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u02/oradata/test02t/system01.dbf
input datafile fno=00002 name=/u02/oradata/test02t/undotbs01.dbf
input datafile fno=00003 name=/u02/oradata/test02t/sysaux01.dbf
input datafile fno=00004 name=/u02/oradata/test02t/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-SEP-13
channel ORA_DISK_1: finished piece 1 at 04-SEP-13
piece handle=/u04/oradata/test02t/rman/bk_test02t_03oj141h_1_1_20130904.bkp tag=TAG20130904T163705 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 04-SEP-13
 
Starting backup at 04-SEP-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=33 recid=23 stamp=825266240
channel ORA_DISK_1: starting piece 1 at 04-SEP-13
channel ORA_DISK_1: finished piece 1 at 04-SEP-13
piece handle=/u04/oradata/test02t/rman/bk_test02t_04oj1420_1_1_20130904.bkp tag=TAG20130904T163720 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/u04/oradata/ipadlbst/arch/1_33_825193754.dbf recid=23 stamp=825266240
Finished backup at 04-SEP-13
 
Starting Control File and SPFILE Autobackup at 04-SEP-13
piece handle=/u04/oradata/test02t/rman/ctl_c-2513594778-20130904-00.bak comment=NONE
Finished Control File and SPFILE Autobackup at 04-SEP-13
 
RMAN> delete noprompt obsolete;
 
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           1      04-SEP-13
  Backup Piece       1      04-SEP-13          /u04/oradata/test02t/rman/bk_test02t_02oj1402_1_1_20130904.bkp
deleted backup piece
backup piece handle=/u04/oradata/test02t/rman/bk_test02t_02oj1402_1_1_20130904.bkp recid=1 stamp=825266179
Deleted 1 objects
 
RMAN> quit;

请注意,如果delete obsolete时不加noprompt,会产生是否删除的提示。

RMAN> delete obsolete;
 
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           1      04-SEP-13
  Backup Piece       1      04-SEP-13          /u04/oradata/test02t/rman/bk_test02t_02oj1402_1_1_20130904.bkp
 
Do you really want to delete the above objects (enter YES or NO)? n

本页面的文字允许在知识共享 署名-相同方式共享 3.0协议和GNU自由文档许可证下修改和再使用,仅有一个特殊要求,请用链接方式注明文章引用出处及作者。请协助维护作者合法权益。


系列文章

文章列表

  • Oracle 最简单的RMAN配置、备份及恢复(1) - 设置RMAN及备份

这篇文章对你有帮助吗,投个票吧?

rating: 0+x

留下你的评论

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License