RAC环境下的备份与恢复(四)

简介:

 上一讲介绍了rac环境下,当归档日志存储在本地文件系统时的备份与恢复操作,比较麻烦的是需要同步rac各个节点的归档日志,这无疑给备份和恢复操作增加了难度和需要的时间,因而本节中介绍使用多路归档的方式来尽量避免这个问题!

一:配置多路归档

[oracle@rac1 ~]$ sqlplus sys/123456@racdb as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Thu Dec 22 19:08:45 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/rac2_archivelog
Oldest online log sequence     62
Next log sequence to archive   63
Current log sequence           63

SQL> conn sys/123456@racdb2 as sysdba
Connected.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/rac2_archivelog
Oldest online log sequence     62
Next log sequence to archive   63
Current log sequence           63

[oracle@rac2 ~]$ mkdir /u01/app/oracle/rac1_archivelog/
[oracle@rac2 ~]$ ssh rac1 mkdir /u01/app/oracle/rac2_archivelog/

SQL> alter system set log_archive_dest_2='SERVICE=racdb2' sid='racdb1';
System altered.

SQL> alter system set log_archive_dest_2='SERVICE=racdb1' sid='racdb2';
System altered.

SQL> alter system set standby_archive_dest='/u01/app/oracle/rac2_archivelog' sid='racdb1';
System altered.

SQL> alter system set standby_archive_dest='/u01/app/oracle/rac1_archivelog' sid='racdb2';
System altered.

SQL> alter system set log_archive_local_first=false;
System altered.

SQL> alter system set  log_archive_max_processes=3;
System altered.

SQL> alter system archive log current;
System altered.

[root@rac1 ~]#  ls /u01/app/oracle/rac1_archivelog/
1_94_769205632.dbf
[root@rac1 ~]#  ls /u01/app/oracle/rac2_archivelog/
2_63_769205632.dbf

[root@rac2 ~]# ls /u01/app/oracle/rac1_archivelog/
1_94_769205632.dbf
[root@rac2 ~]# ls /u01/app/oracle/rac2_archivelog/
2_63_769205632.dbf

二:备份数据库和归档日志,需要分配通道,否则会失败

[oracle@rac1 ~]$ rman target sys/123456@racdb
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Dec 22 19:15:16 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: RACDB (DBID=766822397)

RMAN> backup archivelog all;

Starting backup at 2011-12-22 19:15:22
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=124 instance=racdb1 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 12/22/2011 19:15:33
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /u01/app/oracle/rac2_archivelog/2_66_769205632.dbf
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

RMAN> run {
2> allocate channel c1 device type disk connect 
sys/123456@racdb1;
3> allocate channel c2 device type disk connect 
sys/123456@racdb2
;
4> backup incremental level 0
5> tag 'inr0_fullbak_20111222'
6> database plus archivelog delete all input;
7> release channel c1;
8> release channel c2;
9> }

RMAN> list backup of database summary;

List of Backups
===============
Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag
------- -- -- - ----------- ------------------- ------- ------- ---------- ---
50      B  0  A DISK        2011-12-22 19:19:39 1       1       NO         INR0_FULLBAK_20111222
51      B  0  A DISK        2011-12-22 19:19:56 1       1       NO         INR0_FULLBAK_20111222

三:创建测试数据

[oracle@rac1 ~]$ sqlplus sys/123456@racdb as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Thu Dec 22 20:14:45 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> create tablespace local_arch_test datafile size 10M;
Tablespace created.

SQL> create table test.t5  tablespace local_arch_test as select * from hr.employees;
Table created.

SQL> select count(*) from test.t5;

  COUNT(*)
----------
       107

SQL> select file_name from dba_data_files where tablespace_name in ('SYSTEM','LOCAL_ARCH_TEST');

FILE_NAME
------------------------------------------------------------------
+DATA/racdb/datafile/system.256.770422987
+DATA/racdb/datafile/local_arch_test.312.770588167

SQL> alter system archive log current;
System altered.

SQL> /
System altered.

四:模拟数据文件损坏

[oracle@rac1 ~]$ srvctl stop database -d racdb -o immediate
[oracle@rac1 ~]$ export ORACLE_SID=+ASM1
[oracle@rac1 ~]$ asmcmd rm -rf +DATA/racdb/datafile/system.256.770422987
[oracle@rac1 ~]$ asmcmd rm -rf +DATA/racdb/datafile/local_arch_test.312.770588167

[oracle@rac1 ~]$ source .bash_profile 
[oracle@rac1 ~]$ srvctl start database -d racdb 
PRKP-1001 : Error starting instance racdb1 on node rac1
CRS-0215: Could not start resource 'ora.racdb.racdb1.inst'.
PRKP-1001 : Error starting instance racdb2 on node rac2
CRS-0215: Could not start resource 'ora.racdb.racdb2.inst'.

五:执行恢复

[oracle@rac2 ~]$ srvctl start database -d racdb -o mount
[oracle@rac2 ~]$ rman target 
sys/123456@racdb
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Dec 22 20:26:06 2011
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database: RACDB (DBID=766822397, not open)

RMAN> run {
2> allocate channel c1 device type disk connect 
sys/123456@racdb1;
3> allocate channel c2 device type disk connect 
sys/123456@racdb2
;
4> restore database;
5> recover database;
6> release channel c1;
7> release channel c2;
8> }

allocated channel: c1
channel c1: sid=146 instance=racdb1 devtype=DISK

allocated channel: c2
channel c2: sid=146 instance=racdb2 devtype=DISK

Starting restore at 2011-12-22 20:42:10

creating datafile fno=7 name=+DATA/racdb/datafile/local_arch_test.312.770588847
skipping datafile 2; already restored to file +DATA/racdb/datafile/undotbs1.258.769205541
skipping datafile 3; already restored to file +DATA/racdb/datafile/sysaux.257.770222575
skipping datafile 6; already restored to file +DATA/racdb/datafile/undotbs2.265.769205765
skipping datafile 1; already restored to file +DATA/racdb/datafile/system.256.770588849
skipping datafile 4; already restored to file +DATA/racdb/datafile/users.259.769960507
skipping datafile 5; already restored to file +DATA/racdb/datafile/example.264.769205649
Finished restore at 2011-12-22 20:42:11

Starting recover at 2011-12-22 20:42:11

starting media recovery

archive log thread 1 sequence 100 is already on disk as file /u01/app/oracle/rac1_archivelog/1_100_769205632.dbf
archive log thread 1 sequence 101 is already on disk as file /u01/app/oracle/rac1_archivelog/1_101_769205632.dbf
archive log thread 2 sequence 69 is already on disk as file /u01/app/oracle/rac2_archivelog/2_69_769205632.dbf
archive log thread 2 sequence 70 is already on disk as file /u01/app/oracle/rac2_archivelog/2_70_769205632.dbf
channel c2: starting archive log restore to default destination
channel c2: restoring archive log
archive log thread=2 sequence=68
channel c2: reading from backup piece +FRA/racdb/backupset/2011_12_22/annnf0_inr0_fullbak_20111222_0.270.770584805
channel c1: starting archive log restore to default destination
channel c1: restoring archive log
archive log thread=1 sequence=99
channel c1: reading from backup piece +FRA/racdb/backupset/2011_12_22/annnf0_inr0_fullbak_20111222_0.261.770584805
channel c1: restored backup piece 1
piece handle=+FRA/racdb/backupset/2011_12_22/annnf0_inr0_fullbak_20111222_0.261.770584805 tag=INR0_FULLBAK_20111222
channel c1: restore complete, elapsed time: 00:00:07
archive log filename=/u01/app/oracle/rac1_archivelog/1_99_769205632.dbf thread=1 sequence=99
channel c2: restored backup piece 1
piece handle=+FRA/racdb/backupset/2011_12_22/annnf0_inr0_fullbak_20111222_0.270.770584805 tag=INR0_FULLBAK_20111222
channel c2: restore complete, elapsed time: 00:00:07
archive log filename=/u01/app/oracle/rac2_archivelog/2_68_769205632.dbf thread=2 sequence=68
archive log filename=/u01/app/oracle/rac2_archivelog/2_69_769205632.dbf thread=2 sequence=69
archive log filename=/u01/app/oracle/rac1_archivelog/1_100_769205632.dbf thread=1 sequence=100
media recovery complete, elapsed time: 00:00:04
Finished recover at 2011-12-22 20:42:27

released channel: c1

released channel: c2

六:验证

[oracle@rac2 ~]$ srvctl  stop database -d racdb -o abort
[oracle@rac2 ~]$ srvctl  start database -d racdb

[oracle@rac2 ~]$ sqlplus sys/123456@racdb as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Thu Dec 22 20:44:55 2011
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select count(*) from test.t5;

  COUNT(*)
----------
       107

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


ylw6006

相关文章
|
8月前
|
Oracle Java 关系型数据库
RAC 环境中 gc block lost 和私网通信性能问题的诊断
对于每个节点,以及集群汇总统计信息中的global cache数据块丢失的统计信息("gc cr block lost" 和/或 "gc current block lost") 代表了私网通信的包处理效率低或者包的处理存在异常。
199 0
|
11月前
|
数据库 数据安全/隐私保护
使用rman把单机的备份集恢复到RAC的方法
环境准备 在ASM磁盘组里面创建相应的目录
160 0
|
11月前
|
存储 Oracle 关系型数据库