ITPub博客

首页 > 数据库 > Oracle > RAC备份恢复系列之三 RAC的恢复,恢复整个数据库

RAC备份恢复系列之三 RAC的恢复,恢复整个数据库

原创 Oracle 作者:西门吹牛 时间:2011-02-14 15:50:21 0 删除 编辑

第一部分,环境描述
(也可以参考前面的部分)
linux:
[oracle@node1 ~]$ uname -a
Linux node1 2.6.18-92.el5xen #1 SMP Tue Apr 29 13:45:57 EDT 2008 i686 i686 i386 GNU/Linux

Oracle:
SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL>

采用的是虚拟机模拟的RAC环境
安装了ASM

node1节点的归档日志的设置
归档日志的设置
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +RAC_DISK/demo/arch1
Oldest online log sequence 42
Next log sequence to archive 44
Current log sequence 44
SQL>

归档日志的设置
SQL> show parameter arch

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
archive_lag_target integer 0
log_archive_config string
log_archive_dest string
log_archive_dest_1 string LOCATION=+RAC_DISK/demo/arch1
log_archive_dest_10 string
log_archive_dest_2 string
log_archive_dest_3 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string enable
log_archive_dest_state_10 string enable
log_archive_dest_state_2 string enable
log_archive_dest_state_3 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.arc
log_archive_local_first boolean TRUE
log_archive_max_processes integer 2
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
log_archive_trace integer 0
remote_archive_enable string true
standby_archive_dest string ?/dbs/arch
SQL>


node2节点的归档日志的设置
归档日志的设置

SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +RAC_DISK/demo/arch2
Oldest online log sequence 17
Next log sequence to archive 19
Current log sequence 19
SQL>

SQL> show parameter arch

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
archive_lag_target integer 0
log_archive_config string
log_archive_dest string
log_archive_dest_1 string LOCATION=+RAC_DISK/demo/arch2
log_archive_dest_10 string
log_archive_dest_2 string
log_archive_dest_3 string
log_archive_dest_4 string
log_archive_dest_5 string
log_archive_dest_6 string
log_archive_dest_7 string

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_8 string
log_archive_dest_9 string
log_archive_dest_state_1 string enable
log_archive_dest_state_10 string enable
log_archive_dest_state_2 string enable
log_archive_dest_state_3 string enable
log_archive_dest_state_4 string enable
log_archive_dest_state_5 string enable
log_archive_dest_state_6 string enable
log_archive_dest_state_7 string enable
log_archive_dest_state_8 string enable

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_state_9 string enable
log_archive_duplex_dest string
log_archive_format string %t_%s_%r.arc
log_archive_local_first boolean TRUE
log_archive_max_processes integer 2
log_archive_min_succeed_dest integer 1
log_archive_start boolean FALSE
log_archive_trace integer 0
remote_archive_enable string true
standby_archive_dest string ?/dbs/arch
SQL>


RAC备份注意事项
第一,备份的时候连接到某个实例,而不是连接整个集群
第二,备份归档日志的时候,必须保证在备份实例上面能够访问所有实例的归档日志,否则会报错


备份步骤
登录到node1节点

rman target / nocatalog

run {
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
backup
tag mjs_racdb_full
format '/opt/ora10g/rman/racdb%t_s%s_p%p'
database include current controlfile ;
sql 'alter system archive log current';
backup archivelog all delete input
format '/opt/ora10g/rman/racdb_archlog_%d.%s';
release channel t1;
release channel t2;
release channel t3;
allocate channel node1 type disk format '/opt/ora10g/rman/racdb_control_%d_%s_%p_%c';
Backup current controlfile;
release channel node1;
}


========================================================
数据库全备份已经完成,参见上面是第22小结的部分,下面是本次试验

本次试验目的是把数据库的控制文件,数据文件,联机日志文件全部删除,最后利用备份进行不完全恢复。

步骤一:全备份

过程如下

allocated channel: t1
channel t1: sid=127 instance=RACDB1 devtype=DISK

allocated channel: t2
channel t2: sid=126 instance=RACDB1 devtype=DISK

allocated channel: t3
channel t3: sid=136 instance=RACDB1 devtype=DISK

Starting backup at 14-FEB-11
channel t1: starting full datafile backupset
channel t1: specifying datafile(s) in backupset
input datafile fno=00001 name=+RAC_DISK/racdb/datafile/system.259.733960845
input datafile fno=00004 name=+RAC_DISK/racdb/datafile/undotbs2.263.733960921
channel t1: starting piece 1 at 14-FEB-11
channel t2: starting full datafile backupset
channel t2: specifying datafile(s) in backupset
input datafile fno=00003 name=+RAC_DISK/racdb/datafile/sysaux.261.733960895
input datafile fno=00006 name=+RAC_DISK/racdb/datafile/test_d.271.734574993
input datafile fno=00005 name=+RAC_DISK/racdb/datafile/users.264.733960933
input datafile fno=00010 name=+RAC_DISK/racdb/datafile/recover_test.290.742887039
channel t2: starting piece 1 at 14-FEB-11
channel t3: starting full datafile backupset
channel t3: specifying datafile(s) in backupset
input datafile fno=00002 name=+RAC_DISK/racdb/datafile/undotbs1.260.733960879
input datafile fno=00007 name=+RAC_NEWDISK/racdb/datafile/test_e.256.736131295
input datafile fno=00008 name=+RAC_NEWDISK/racdb/datafile/test_e.257.736131637
input datafile fno=00009 name=+RAC_DISK/racdb/datafile/recover_test.293.742885323
channel t3: starting piece 1 at 14-FEB-11
channel t1: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb743106839_s29_p1 tag=MJS_RACDB_FULL comment=NONE
channel t1: backup set complete, elapsed time: 00:02:04
channel t1: starting full datafile backupset
channel t1: specifying datafile(s) in backupset
including current control file in backupset
channel t1: starting piece 1 at 14-FEB-11
channel t2: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb743106840_s30_p1 tag=MJS_RACDB_FULL comment=NONE
channel t2: backup set complete, elapsed time: 00:02:09
channel t2: starting full datafile backupset
channel t2: specifying datafile(s) in backupset
channel t3: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb743106841_s31_p1 tag=MJS_RACDB_FULL comment=NONE
channel t3: backup set complete, elapsed time: 00:02:11
channel t1: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb743106966_s32_p1 tag=MJS_RACDB_FULL comment=NONE
channel t1: backup set complete, elapsed time: 00:00:06
including current SPFILE in backupset
channel t2: starting piece 1 at 14-FEB-11
channel t2: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb743106972_s33_p1 tag=MJS_RACDB_FULL comment=NONE
channel t2: backup set complete, elapsed time: 00:00:01
Finished backup at 14-FEB-11

sql statement: alter system archive log current

Starting backup at 14-FEB-11
current log archived
channel t1: starting archive log backupset
channel t1: specifying archive log(s) in backup set
input archive log thread=1 sequence=46 recid=45 stamp=743106982
channel t1: starting piece 1 at 14-FEB-11
channel t2: starting archive log backupset
channel t2: specifying archive log(s) in backup set
input archive log thread=1 sequence=47 recid=47 stamp=743106985
input archive log thread=2 sequence=21 recid=44 stamp=743100283
channel t2: starting piece 1 at 14-FEB-11
channel t3: starting archive log backupset
channel t3: specifying archive log(s) in backup set
input archive log thread=2 sequence=22 recid=46 stamp=743106905
input archive log thread=2 sequence=23 recid=48 stamp=743106909
channel t3: starting piece 1 at 14-FEB-11
channel t1: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb_archlog_RACDB.34 tag=TAG20110214T183631 comment=NONE
channel t1: backup set complete, elapsed time: 00:00:02
channel t1: deleting archive log(s)
archive log filename=+RAC_DISK/demo/arch1/1_46_733960822.arc recid=45 stamp=743106982
channel t2: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb_archlog_RACDB.35 tag=TAG20110214T183631 comment=NONE
channel t2: backup set complete, elapsed time: 00:00:02
channel t2: deleting archive log(s)
archive log filename=+RAC_DISK/demo/arch1/1_47_733960822.arc recid=47 stamp=743106985
archive log filename=+RAC_DISK/demo/arch2/2_21_733960822.arc recid=44 stamp=743100283
channel t3: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb_archlog_RACDB.36 tag=TAG20110214T183631 comment=NONE
channel t3: backup set complete, elapsed time: 00:00:03
channel t3: deleting archive log(s)
archive log filename=+RAC_DISK/demo/arch2/2_22_733960822.arc recid=46 stamp=743106905
archive log filename=+RAC_DISK/demo/arch2/2_23_733960822.arc recid=48 stamp=743106909
Finished backup at 14-FEB-11

released channel: t1

released channel: t2

released channel: t3

allocated channel: node1
channel node1: sid=127 instance=RACDB1 devtype=DISK

Starting backup at 14-FEB-11
channel node1: starting full datafile backupset
channel node1: specifying datafile(s) in backupset
including current control file in backupset
channel node1: starting piece 1 at 14-FEB-11
channel node1: finished piece 1 at 14-FEB-11
piece handle=/opt/ora10g/rman/racdb_control_RACDB_37_1_1 tag=TAG20110214T183639 comment=NONE
channel node1: backup set complete, elapsed time: 00:00:04
Finished backup at 14-FEB-11

released channel: node1

RMAN> exit


步骤二:产生模拟数据
conn test2/test2

SQL> select table_name from user_tables;

TABLE_NAME
------------------------------
TBL_TEST
TBL_T2

SQL> select count(*) from tbl_test;

COUNT(*)
----------
38198

SQL> delete from tbl_test where rownum < 100;

99 rows deleted.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> delete from tbl_test where rownum < 100;

99 rows deleted.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> delete from tbl_test where rownum < 100;

99 rows deleted.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> select count(*) from tbl_test;

COUNT(*)
----------
37901


步骤二:查看需要删除并恢复的文件位置

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+RAC_DISK/racdb/datafile/system.259.733960845
+RAC_DISK/racdb/datafile/undotbs1.260.733960879
+RAC_DISK/racdb/datafile/sysaux.261.733960895
+RAC_DISK/racdb/datafile/undotbs2.263.733960921
+RAC_DISK/racdb/datafile/users.264.733960933
+RAC_DISK/racdb/datafile/test_d.271.734574993
+RAC_NEWDISK/racdb/datafile/test_e.256.736131295
+RAC_NEWDISK/racdb/datafile/test_e.257.736131637
+RAC_DISK/racdb/datafile/recover_test.293.742885323
+RAC_DISK/racdb/datafile/recover_test.290.742887039

10 rows selected.

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+RAC_DISK/racdb/controlfile/current.256.733960831

SQL>
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+RAC_DISK/racdb/onlinelog/group_1.257.733960837
+RAC_DISK/racdb/onlinelog/group_2.258.733960839
+RAC_DISK/racdb/onlinelog/group_3.265.733963563
+RAC_DISK/racdb/onlinelog/group_4.266.733963567
+RAC_DISK/racdb/onlinelog/group_5.272.734633861
+RAC_DISK/racdb/onlinelog/group_6.273.734633913

6 rows selected.

SQL>

步骤三,关闭数据库,删除数据文件,模拟灾难场景
关闭两个实例,两个节点都
shutdown abort

在节点2上面
[oracle@node2 ~]$ export ORACLE_SID=+ASM2
[oracle@node2 ~]$ asmcmd -p
ASMCMD [+] > ls
RAC_DISK/
RAC_NEWDISK/
ASMCMD [+] > cd RAC_DISK
ASMCMD [+RAC_DISK] > ls
RACDB/
demo/
ASMCMD [+RAC_DISK] > cd racdb
ASMCMD [+RAC_DISK/racdb] > ls
ARCHIVELOG/
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileRACDB.ora
ASMCMD [+RAC_DISK/racdb] > cd datafile
ASMCMD [+RAC_DISK/racdb/datafile] > ls
RECOVER_TEST.290.742887039
RECOVER_TEST.293.742885323
SYSAUX.261.733960895
SYSTEM.259.733960845
TEST_D.271.734574993
UNDOTBS1.260.733960879
UNDOTBS2.263.733960921
USERS.264.733960933
ASMCMD [+RAC_DISK/racdb/datafile] > rm *
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD [+RAC_DISK/racdb/datafile] > ls
asmcmd: entry 'datafile' does not exist in directory '+RAC_DISK/racdb/'
ASMCMD [+RAC_DISK/racdb/datafile] > cd ..
asmcmd: entry 'datafile' does not exist in directory '+RAC_DISK/racdb/'
ASMCMD [+RAC_DISK/racdb/datafile] > cd +RAC_DISK/racdb/
ASMCMD [+RAC_DISK/racdb] > ls
ARCHIVELOG/
CONTROLFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileRACDB.ora
ASMCMD [+RAC_DISK/racdb] > cd +RAC_NEWDISK/racdb/datafile/
ASMCMD [+RAC_NEWDISK/racdb/datafile] > ls
TEST_E.256.736131295
TEST_E.257.736131637
ASMCMD [+RAC_NEWDISK/racdb/datafile] > rm *
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD [+RAC_NEWDISK/racdb/datafile] > cd +RAC_DISK/racdb/controlfile/
ASMCMD [+RAC_DISK/racdb/controlfile] > ls
Current.256.733960831
ASMCMD [+RAC_DISK/racdb/controlfile] > rm *
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD [+RAC_DISK/racdb/controlfile] > cd +RAC_DISK/racdb/onlinelog/
ASMCMD [+RAC_DISK/racdb/onlinelog] > ls
group_1.257.733960837
group_2.258.733960839
group_3.265.733963563
group_4.266.733963567
group_5.272.734633861
group_6.273.734633913
ASMCMD [+RAC_DISK/racdb/onlinelog] > rm *
You may delete multiple files and/or directories.
Are you sure? (y/n) y
ASMCMD [+RAC_DISK/racdb/onlinelog] > exit

步骤四:恢复数据库
1)先恢复控制文件
先登录到node1,因为备份在node1做的,恢复也在node1进行


SQL> startup nomount
ORACLE instance started.

Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 117442804 bytes
Database Buffers 46137344 bytes
Redo Buffers 2973696 bytes
SQL>

2)用RMAN从备份恢复控制文件
在节点1进行
RMAN> restore controlfile;

Starting restore at 14-FEB-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 instance=RACDB1 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/14/2011 18:57:43
RMAN-06563: control file or SPFILE must be restored using FROM AUTOBACKUP

RMAN> list backup of controlfile;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 02/14/2011 18:57:56
ORA-01507: database not mounted

RMAN>

原来数据库启动不起来,没法list backup 查看,也对,因为没有用catalog备份,所以备份信息保存在控制文件中
目前控制文件被删除,当然查不到备份的信息了
所以只能从前面的备份日志中查看备份的控制文件存放地址了


RMAN> restore controlfile from '/opt/ora10g/rman/racdb_control_RACDB_37_1_1';

Starting restore at 14-FEB-11
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:12
output filename=+RAC_DISK/racdb/controlfile/current.273.743108307
Finished restore at 14-FEB-11

RMAN>

3)挂载数据库
RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN>

4)恢复数据文件
RMAN> restore database;

Starting restore at 14-FEB-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=146 instance=RACDB1 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to +RAC_DISK/racdb/datafile/undotbs1.260.733960879
restoring datafile 00007 to +RAC_NEWDISK/racdb/datafile/test_e.256.736131295
restoring datafile 00008 to +RAC_NEWDISK/racdb/datafile/test_e.257.736131637
restoring datafile 00009 to +RAC_DISK/racdb/datafile/recover_test.293.742885323
channel ORA_DISK_1: reading from backup piece /opt/ora10g/rman/racdb743106841_s31_p1
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/ora10g/rman/racdb743106841_s31_p1 tag=MJS_RACDB_FULL
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +RAC_DISK/racdb/datafile/system.259.733960845
restoring datafile 00004 to +RAC_DISK/racdb/datafile/undotbs2.263.733960921
channel ORA_DISK_1: reading from backup piece /opt/ora10g/rman/racdb743106839_s29_p1
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/ora10g/rman/racdb743106839_s29_p1 tag=MJS_RACDB_FULL
channel ORA_DISK_1: restore complete, elapsed time: 00:00:56
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to +RAC_DISK/racdb/datafile/sysaux.261.733960895
restoring datafile 00005 to +RAC_DISK/racdb/datafile/users.264.733960933
restoring datafile 00006 to +RAC_DISK/racdb/datafile/test_d.271.734574993
restoring datafile 00010 to +RAC_DISK/racdb/datafile/recover_test.290.742887039
channel ORA_DISK_1: reading from backup piece /opt/ora10g/rman/racdb743106840_s30_p1
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/ora10g/rman/racdb743106840_s30_p1 tag=MJS_RACDB_FULL
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 14-FEB-11

RMAN>

这里暂停一下,回忆看看我们第23小结的实验,asm不允许两个数据文件同名,所以回复过来的数据文件是以前的文件吗
restore 恢复的数据文件和以前是一样的吗?

查看ASM中的文件名
[oracle@node1 ~]$ export ORACLE_SID=+ASM1
[oracle@node1 ~]$ asmcmd -p
ASMCMD [+] > cd +RAC_DISK/racdb/datafile/
ASMCMD [+RAC_DISK/racdb/datafile] > ls
RECOVER_TEST.258.743108403
RECOVER_TEST.264.743108495
SYSAUX.290.743108487
SYSTEM.257.743108431
TEST_D.293.743108491
TEST_E.265.743108401
TEST_E.266.743108399
UNDOTBS1.272.743108397
UNDOTBS2.256.743108435
USERS.271.743108493
ASMCMD [+RAC_DISK/racdb/datafile] >

可见 restore的时候,ASM还是自动修改了数据文件名称
那么我们需要更改控制文件中的数据文件名称吗


SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+RAC_DISK/racdb/datafile/system.257.743108431
+RAC_DISK/racdb/datafile/undotbs1.272.743108397
+RAC_DISK/racdb/datafile/sysaux.290.743108487
+RAC_DISK/racdb/datafile/undotbs2.256.743108435
+RAC_DISK/racdb/datafile/users.271.743108493
+RAC_DISK/racdb/datafile/test_d.293.743108491
+RAC_DISK/racdb/datafile/test_e.266.743108399
+RAC_DISK/racdb/datafile/test_e.265.743108401
+RAC_DISK/racdb/datafile/recover_test.258.743108403
+RAC_DISK/racdb/datafile/recover_test.264.743108495

10 rows selected.

SQL>

发现现在控制文件中的数据文件名称和实际ASM中的文件名对应上了,
所以我们不必再进行修改工作了,restore的时候自动修改控制文件了

5)确定恢复终点
SQL> select name from v$archived_log;

NAME
--------------------------------------------------------------------------------


28 rows selected.

SQL>
但是实际上是空的,因为我备份完归档日志后,用了 delete input语句,把备份后的归档日志删除了。

6)查看磁盘上面的归档日志
[oracle@node1 ~]$ export ORACLE_SID=+ASM1
[oracle@node1 ~]$ asmcmd -p
ASMCMD [+] > cd +RAC_DISK/demo/arch1
ASMCMD [+RAC_DISK/demo/arch1] > ls
1_48_733960822.arc
1_49_733960822.arc
1_50_733960822.arc
ASMCMD [+RAC_DISK/demo/arch1] > cd ..
ASMCMD [+RAC_DISK/demo] > ls
arch1/
arch2/
ASMCMD [+RAC_DISK/demo] > cd arch2
ASMCMD [+RAC_DISK/demo/arch2] > ls
2_24_733960822.arc
ASMCMD [+RAC_DISK/demo/arch2] > exit
[oracle@node1 ~]$

也就是说,现在磁盘上面的归档日志是在全备份之后产生的。

也就是说,这几个归档日志没有记录在控制文件中,

下面我们把这几个文件记录到控制文件中

7)把这几个文件记录到控制文件中

rman target /

catalog archivelog '+RAC_DISK/demo/arch1/1_48_733960822.arc';

catalog archivelog '+RAC_DISK/demo/arch1/1_49_733960822.arc';

catalog archivelog '+RAC_DISK/demo/arch1/1_50_733960822.arc';

catalog archivelog '+RAC_DISK/demo/arch2/2_24_733960822.arc';

现在再查询


SQL> select name from v$archived_log;


NAME
--------------------------------------------------------------------------------


+RAC_DISK/demo/arch1/1_48_733960822.arc
+RAC_DISK/demo/arch1/1_49_733960822.arc
+RAC_DISK/demo/arch1/1_50_733960822.arc
+RAC_DISK/demo/arch2/2_24_733960822.arc

28 rows selected.

SQL>

发现这几个新的归档日志已经被新的控制文件识别。


8) 执行不完全恢复
过程如下
RMAN> recover database using backup controlfile until cancel;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "using": expecting one of: "archivelog, auxiliary, allow, check, delete, from, high, noredo, noparallel, parallel, ;, skip, tablespace, test, until, undo"
RMAN-01007: at line 2 column 18 file: standard input

干脆直接恢复
RMAN> recover database;

Starting recover at 14-FEB-11
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 48 is already on disk as file +RAC_DISK/demo/arch1/1_48_733960822.arc
archive log thread 1 sequence 49 is already on disk as file +RAC_DISK/demo/arch1/1_49_733960822.arc
archive log thread 1 sequence 50 is already on disk as file +RAC_DISK/demo/arch1/1_50_733960822.arc
archive log thread 2 sequence 24 is already on disk as file +RAC_DISK/demo/arch2/2_24_733960822.arc
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=46
channel ORA_DISK_1: reading from backup piece /opt/ora10g/rman/racdb_archlog_RACDB.34
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/ora10g/rman/racdb_archlog_RACDB.34 tag=TAG20110214T183631
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
archive log filename=+RAC_DISK/demo/arch1/1_46_733960822.arc thread=1 sequence=46
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=47
channel ORA_DISK_1: reading from backup piece /opt/ora10g/rman/racdb_archlog_RACDB.35
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/ora10g/rman/racdb_archlog_RACDB.35 tag=TAG20110214T183631
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=22
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=23
channel ORA_DISK_1: reading from backup piece /opt/ora10g/rman/racdb_archlog_RACDB.36
channel ORA_DISK_1: restored backup piece 1
piece handle=/opt/ora10g/rman/racdb_archlog_RACDB.36 tag=TAG20110214T183631
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
archive log filename=+RAC_DISK/demo/arch1/2_22_733960822.arc thread=2 sequence=22
archive log filename=+RAC_DISK/demo/arch1/1_47_733960822.arc thread=1 sequence=47
archive log filename=+RAC_DISK/demo/arch1/2_23_733960822.arc thread=2 sequence=23
archive log filename=+RAC_DISK/demo/arch1/1_48_733960822.arc thread=1 sequence=48
archive log filename=+RAC_DISK/demo/arch2/2_24_733960822.arc thread=2 sequence=24
archive log filename=+RAC_DISK/demo/arch1/1_49_733960822.arc thread=1 sequence=49
archive log filename=+RAC_DISK/demo/arch1/1_50_733960822.arc thread=1 sequence=50
unable to find archive log
archive log thread=1 sequence=51
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/14/2011 21:04:31
RMAN-06054: media recovery requesting unknown log: thread 1 seq 51 lowscn 1090223

RMAN>

从最后的提示可以看出,需要找到seq=51的归档日志,可是这样的日志还没有产生,所以实际上归档日志已经应用成功了。
下面我们 reset logs方式打开数据库

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

RMAN>

现在节点1上面的实例启动了,但是节点2的实例没有启动
SQL> startup
ORACLE instance started.

Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 117442804 bytes
Database Buffers 46137344 bytes
Redo Buffers 2973696 bytes
ORA-00205: error in identifying control file, check alert log for more info


SQL>

估计错误的原因,因为控制文件是从备份恢复到ASM的,所以文件名和当初的控制文件名称不一致。

在节点1,参数文件自动修改了,但是在节点2,修改不了

下面我换了另外一种方法,还是启动不了数据库

[oracle@node2 ~]$ srvctl start database -d RACDB2
PRKR-1001 : cluster database RACDB2 does not exist
PRKO-2005 : Application error: Failure in getting Cluster Database Configuration for: RACDB2
[oracle@node2 ~]$ echo $ORACLE_SID
RACDB2
[oracle@node2 ~]$ exit
logout

[root@node2 ~]# srvctl start database -d RACDB2
PRKR-1001 : cluster database RACDB2 does not exist
PRKO-2005 : Application error: Failure in getting Cluster Database Configuration for: RACDB2
[root@node2 ~]#

检查警告日志文件,发现果然如我猜测一样

ORA-00202: control file: '+RAC_DISK/racdb/controlfile/current.256.733960831'
ORA-17503: ksfdopn:2 Failed to open file +RAC_DISK/racdb/controlfile/current.256.733960831
ORA-15012: ASM file '+RAC_DISK/racdb/controlfile/current.256.733960831' does not exist

在启动的节点1的数据库上查询

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+RAC_DISK/racdb/controlfile/current.273.743108307

SQL>

因为SPFILE是无法直接修改,所以在本地建立一个PFILE,修改后,通过PFILE启动
再生成ASM格式的SPFILE;

startup nomount

SQL> show parameter spfile

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /opt/ora10g/product/10.2.0/db_1/dbs/spfileRACDB2.ora
SQL>


create pfile='/opt/ora10g/product/10.2.0/db_1/dbs/pfileRACDB2.ora.new' from spfile;

编辑 /opt/ora10g/product/10.2.0/db_1/dbs/pfileRACDB2.ora.new 文件
把里面控制文件名称修改为恢复后的 +RAC_DISK/racdb/controlfile/current.273.743108307

shutdown immediate

startup pfile='/opt/ora10g/product/10.2.0/db_1/dbs/pfileRACDB2.ora.new'

create spfile from pfile='/opt/ora10g/product/10.2.0/db_1/dbs/pfileRACDB2.ora.new';

shutdown immediate

startup


9)检查
[oracle@node2 dbs]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....B1.inst application ONLINE ONLINE node1
ora....B2.inst application ONLINE ONLINE node2
ora.RACDB.db application ONLINE ONLINE node1
ora....SM1.asm application ONLINE ONLINE node1
ora....E1.lsnr application ONLINE ONLINE node1
ora.node1.gsd application ONLINE ONLINE node1
ora.node1.ons application ONLINE ONLINE node1
ora.node1.vip application ONLINE ONLINE node1
ora....SM2.asm application ONLINE ONLINE node2
ora....E2.lsnr application ONLINE ONLINE node2
ora.node2.gsd application ONLINE ONLINE node2
ora.node2.ons application ONLINE ONLINE node2
ora.node2.vip application ONLINE ONLINE node2
[oracle@node2 dbs]$

SQL> conn test2/test2
Connected.
SQL> select count(*) from tbl_test;

COUNT(*)
----------
37901

SQL>

发现没有丢失数据,数据已经提交了。

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10771/viewspace-1045971/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-06-13

  • 博文量
    18
  • 访问量
    122931