RAC 简单归档设置下备份恢复理解
RAC 简单归档设置下备份恢复理解
理解最简单的备份方法,理解rman是如何备份与恢复的。集群环境下对归档日志的备份注意事项:
必须保证备份实例上能够访问所有实例的归档日志,否则会报错,除非为各个实例分配通道。
集群环境下恢复注意事项:
进行restore时,为每个实例配置通道,以正确的转储。
进行recover时,当前操作实例必须能够访问所有的归档日志文件,否则可能恢复失败。
以上注意事项在任何归档日志设置情况下成立,只是有些情况下Oracle为我们做了,或通过asm,或通过nfs,或其它方式。
以下以 最简单的归档日志设置 为例进行测试,
alter system set log_archive_dest_1='LOCATION=/oracle/rac1_arch' scope=spfile sid='RACDB1';
alter system set log_archive_dest_1='LOCATION=/oracle/rac2_arch' scope=spfile sid='RACDB2';
备份过程:
[plain]- RACDB1@rac1 /home/oracle$ rman target /
- Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 23:52:28 2012
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- connected to target database: RACDB (DBID=769091368)
- RMAN> backup archivelog all tag='arc_bak' format='/oracle/backup/arch_%U_%T';
- Starting backup at 11-JAN-12
- current log archived
- using target database control file instead of recovery catalog
- allocated channel: ORA_DISK_1
- channel ORA_DISK_1: sid=152 instance=RACDB1 devtype=DISK
- RMAN-00571: ===========================================================
- RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
- RMAN-00571: ===========================================================
- RMAN-03002: failure of backup command at 01/11/2012 23:52:54
- RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
- ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf
- ORA-27037: unable to obtain file status
- Linux Error: 2: No such file or directory
- Additional information: 3
- RMAN> quit
- Recovery Manager complete.
- ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf
找不到2_11_771474603.dbf 这个归档日志文件,因为在本地/oracle/rac2_arch/目录没有这个文件。这个文件在节点二的本地/oracle/rac2_arch/目录下,看下面: [plain]
- RACDB1@rac1 /home/oracle$ ll /oracle/rac2_arch/
- total 0
- RACDB1@rac1 /home/oracle$ ssh rac2
- Last login: Wed Jan 11 23:50:52 2012 from rac1
- RACDB2@rac2 /home/oracle$ ll /oracle/rac1_arch/
- total 0
- RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/
- total 132
- -rw-rw---- 1 oracle oinstall 95744 Jan 11 23:51 2_11_771474603.dbf --就是无法找到这个日志文件
- -rw-rw---- 1 oracle oinstall 32768 Jan 11 23:52 2_12_771474603.dbf
- RACDB1@rac1 /home/oracle$ rman target /
- Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jan 12 00:31:16 2012
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- connected to target database: RACDB (DBID=769091368)
- RMAN> run
- 2> {
- 3> allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
- allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
- 5> backup archivelog all tag='arc_bak' ;
- 6> release channel c1;
- 7> release channel c2;
- 8> }
- using target database control file instead of recovery catalog
- allocated channel: c1
- channel c1: sid=131 instance=RACDB1 devtype=DISK
- allocated channel: c2
- channel c2: sid=147 instance=RACDB2 devtype=DISK
- Starting backup at 12-JAN-12
- current log archived
- ......
- ......
- piece handle=/oracle/backup/arch_08n0hm06_1_1_20120112 tag=ARC_BAK comment=NONE
- channel c2: backup set complete, elapsed time: 00:00:03
- Finished backup at 12-JAN-12
- released channel: c1
- released channel: c2
- RMAN> quit
- Recovery Manager complete.
- --查看两个节点的备份结果
- RACDB1@rac1 /home/oracle$ ll /oracle/backup/
- total 159996
- -rw-r----- 1 oracle oinstall 123994112 Jan 12 00:31 arch_05n0hlvp_1_1_20120112
- -rw-r----- 1 oracle oinstall 39667712 Jan 12 00:32 arch_07n0hm05_1_1_20120112
- RACDB1@rac1 /home/oracle$ su rac2
- su: user rac2 does not exist
- RACDB1@rac1 /home/oracle$ ssh rac2
- Last login: Thu Jan 12 00:27:36 2012 from rac1
- RACDB2@rac2 /home/oracle$ ll /oracle/backup/
- total 73252
- -rw-r----- 1 oracle oinstall 73526784 Jan 12 00:32 arch_06n0hlvp_1_1_20120112
- -rw-r----- 1 oracle oinstall 1399296 Jan 12 00:32 arch_08n0hm06_1_1_20120112
恢复过程:
--全备数据库
--分别在两个节点构造数据后,备份所有归档日志
--关闭数据库后,在asmcmd下删除一数据文件
--使用归档日志实施数据文件的恢复.(备份中没有对此数据文件的备份)
归档日志设置:
alter system set log_archive_dest_1='LOCATION=/oracle/rac1_arch' scope=spfile sid='RACDB1';
alter system set log_archive_dest_1='LOCATION=/oracle/rac2_arch' scope=spfile sid='RACDB2';
- BACKUP FORMAT '/oracle/backup/racdb_%U_%T' DATABASE TAG racdb_hot_db_bk;
- --两个节点构造数据
- RACDB1@rac1 /home/oracle$ sqlplus lau/lau@racdb1
- SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 22:54:44 2012
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- Connected to:
- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, Real Application Clusters, OLAP and Data Mining options
- SQL> select name from v$datafile;
- NAME
- --------------------------------------------------------------------------------
- +DATA/racdb/datafile/system.256.771474531
- +DATA/racdb/datafile/undotbs1.258.771474533
- +DATA/racdb/datafile/sysaux.257.771474533
- +DATA/racdb/datafile/users.259.771474535
- +DATA/racdb/datafile/example.264.771474649
- +DATA/racdb/datafile/undotbs2.265.771474825
- 6 rows selected.
- SQL> create tablespace test;
- Tablespace created.
- SQL> select name from v$datafile;
- NAME
- --------------------------------------------------------------------------------
- +DATA/racdb/datafile/system.256.771474531
- +DATA/racdb/datafile/undotbs1.258.771474533
- +DATA/racdb/datafile/sysaux.257.771474533
- +DATA/racdb/datafile/users.259.771474535
- +DATA/racdb/datafile/example.264.771474649
- +DATA/racdb/datafile/undotbs2.265.771474825
- +DATA/racdb/datafile/test.283.772321119
- 7 rows selected.
- SQL> create table t(id int,text varchar2(10)) tablespace test;
- Table created.
- SQL> insert into t values(1,'hello');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter system switch logfile;
- System altered.
- SQL> quit
- Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, Real Application Clusters, OLAP and Data Mining options
- RACDB1@rac1 /home/oracle$ ssh rac2
- Last login: Wed Jan 11 21:29:25 2012 from rac1
- RACDB2@rac2 /home/oracle$ sqlplus lau/lau@racdb2
- SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 21:41:51 2012
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- Connected to:
- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, Real Application Clusters, OLAP and Data Mining options
- SQL> insert into t values(2,'world');
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> alter system switch logfile;
- System altered.
- SQL> quit
- Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, Real Application Clusters, OLAP and Data Mining options
- --查看两个节点的归档日志
- RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/
- total 1052
- -rw-r----- 1 oracle oinstall 1070592 Jan 11 21:42 2_8_771474603.dbf
- RACDB2@rac2 /home/oracle$ ssh rac1
- Last login: Wed Jan 11 21:29:21 2012 from 192.168.246.1
- RACDB1@rac1 /home/oracle$ ll /oracle/rac1_arch/
- total 26876
- -rw-r----- 1 oracle oinstall 27486720 Jan 11 21:41 1_9_771474603.dbf
- RACDB1@rac1 /home/oracle$ ssh rac2
- Last login: Wed Jan 11 21:41:31 2012 from rac1
- RACDB2@rac2 /home/oracle$ ll /oracle/backup/
- total 0
- --全备归档日志
- RACDB2@rac2 /home/oracle$ ssh rac1
- Last login: Wed Jan 11 21:42:49 2012 from rac2
- RACDB1@rac1 /home/oracle$ rman target /
- Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 21:43:47 2012
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- connected to target database: RACDB (DBID=769091368)
- run
- {
- allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
- allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
- backup archivelog all delete all input;
- release channel c1;
- release channel c2;
- 8> }
- using target database control file instead of recovery catalog
- allocated channel: c1
- channel c1: sid=141 instance=RACDB1 devtype=DISK
- allocated channel: c2
- channel c2: sid=124 instance=RACDB2 devtype=DISK
- Starting backup at 11-JAN-12
- current log archived
- ......
- ......
- channel c1: deleting archive log(s)
- archive log filename=/oracle/rac1_arch/1_9_771474603.dbf recid=15 stamp=772321287
- archive log filename=/oracle/rac1_arch/1_10_771474603.dbf recid=17 stamp=772321478
- Finished backup at 11-JAN-12
- released channel: c1
- released channel: c2
- RMAN> quit
- Recovery Manager complete.
|
评论暂时关闭