恢復之RAC資料庫RECOVER

yangtingkun發表於2008-09-18

模擬RAC環境崩潰,在新的伺服器上恢復RAC資料庫的過程。

這一篇描述資料庫的RECOVER過程。

恢復之RAC資料庫RESTOREhttp://yangtingkun.itpub.net/post/468/470912

 

 

下面可以進行恢復,不過在恢復之前首先需要修改日誌檔案檔案的位置,將原始的裸裝置的位置修改為ASM磁碟組中的位置。

由於資料庫還沒有開啟,因此無法在rman中直接呼叫SQL對日誌檔案進行修改操作,如果直接修改會報錯如下:

RMAN> sql "alter database rename file '/dev/vx/rdsk/datavg/rac11g_redo1_1_1_1g' to '+DATA/RAC11G/rac11g_redo1_1_1_1g'";

sql statement: alter database rename file '/dev/vx/rdsk/datavg/rac11g_redo1_1_1_1g' to '+DATA/RAC11G/rac11g_redo1_1_1_1g'
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 09/05/2008 15:50:15
RMAN-10015: error compiling PL/SQL program

下面還是先借助SQLPLUS來修改LOGFILE的位置:

RMAN> host;

$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Sep 5 15:53:29 2008

Copyright (c) 1982, 2007, Oracle.  All rights reserved.


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

SQL> alter database rename file '/dev/vx/rdsk/datavg/rac11g_redo1_1_1_1g' to '+DATA/RAC11G/rac11g_redo1_1_1_1g';

Database altered.

SQL> alter database rename file '/dev/vx/rdsk/datavg/rac11g_redo1_2_1_1g' to '+DATA/RAC11G/rac11g_redo1_2_1_1g';

Database altered.

SQL> alter database rename file '/dev/vx/rdsk/datavg/rac11g_redo2_2_2_1g' to '+DATA/RAC11G/rac11g_redo2_2_2_1g';

Database altered.

SQL> alter database rename file '/dev/vx/rdsk/datavg/rac11g_redo2_2_1_1g' to '+DATA/RAC11G/rac11g_redo2_2_1_1g';

Database altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
$ exit
host command complete

RMAN>

下面可以開始恢復過程了:

RMAN> recover database;

Starting recover at 05-SEP-08
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 528 is already on disk as file +DATA/rac11g/rac11g_redo1_2_1_1g
archived log for thread 1 with sequence 529 is already on disk as file +DATA/rac11g/rac11g_redo1_1_1_1g
archived log for thread 2 with sequence 193 is already on disk as file +DATA/rac11g/rac11g_redo2_2_1_1g
archived log for thread 2 with sequence 194 is already on disk as file +DATA/rac11g/rac11g_redo2_2_2_1g
archived log file name=+DATA/rac11g/rac11g_redo1_2_1_1g thread=1 sequence=528
archived log file name=+DATA/rac11g/rac11g_redo2_2_1_1g thread=2 sequence=193
archived log file name=+DATA/rac11g/rac11g_redo1_1_1_1g thread=1 sequence=529
archived log file name=+DATA/rac11g/rac11g_redo2_2_2_1g thread=2 sequence=194
Finished recover at 05-SEP-08

恢復完成後,嘗試開啟資料庫:

RMAN> alter database open resetlogs;

database opened

下面可以退出RMANsqlplus來管理資料庫,首先是透過本地的PFILE建立一個ASM上面儲存的共享SPFILE

RMAN> exit


Recovery Manager complete.
bash-3.00$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.1.0.6.0 - Production on Fri Sep 5 16:10:05 2008

Copyright (c) 1982, 2007, Oracle.  All rights reserved.


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

SQL> create spfile='+DATA/RAC11G/spfilerac11g.ora' from pfile='/export/home/oracle/initrac11g1.ora';

File created.

從兩個節點分別編輯一個初始化檔案,指向ASM中的SPFILE

vi /data/oracle/product/11.1/database/dbs/initrac11g2.ora
"/data/oracle/product/11.1/database/dbs/initrac11g2.ora" [New file]
spfile=+DATA/RAC11G/spfilerac11g.ora

下面登陸資料庫,嘗試啟動例項2

$ env|grep ORACLE_SID
ORACLE_SID=rac11g2
$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.1.0.6.0 - Production on 星期五 9 5 16:12:39 2008

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

已連線到空閒例程。

SQL> startup
ORACLE
例程已經啟動。

Total System Global Area 1.7108E+10 bytes
Fixed Size                  2101632 bytes
Variable Size            3612855936 bytes
Database Buffers         1.3489E+10 bytes
Redo Buffers                4431872 bytes
資料庫裝載完畢。
資料庫已經開啟。

最後重新設定TEMP表空間:

SQL> alter database rename file '/dev/vx/rdsk/datavg/rac11g_temp_1_4g' to '+DATA/RAC11G/rac11g_temp_1_4g';

Database altered.

SQL> alter database tempfile '+DATA/RAC11G/rac11g_temp_1_4g' drop;

Database altered.

SQL> alter tablespace temp add tempfile '+DATA/RAC11G/rac11g_temp_1_4g' size 4096m;

Tablespace altered.

進行一些檢查,檢查資料庫是否可以正常訪問。

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
rac11g1

SQL> SELECT INSTANCE_NAME FROM GV$INSTANCE;

INSTANCE_NAME
----------------
rac11g1
rac11g2

在另一個節點進行檢查:

SQL> SELECT INSTANCE_NAME FROM V$INSTANCE;

INSTANCE_NAME
----------------
rac11g2

SQL> SELECT INSTANCE_NAME FROM GV$INSTANCE;

INSTANCE_NAME
----------------
rac11g2
rac11g1

最後檢查資料檔案和日誌檔案:

SQL> SELECT FILE_NAME FROM DBA_DATA_FILES;

FILE_NAME
-----------------------------------------------------------------------------------
+DATA/rac11g/rac11g_system_1_1g
+DATA/rac11g/rac11g_sysaux_1_1g
+DATA/rac11g/rac11g_undotbs1_1_4g
+DATA/rac11g/rac11g_undotbs2_1_4g
+DATA/rac11g/rac11g_users_1_4g
+DATA/rac11g/rac11g_ndmain_1_32g
+DATA/rac11g/rac11g_ndmain_2_32g
+DATA/rac11g/rac11g_ndmain_3_32g
+DATA/rac11g/rac11g_ndmain_4_32g
+DATA/rac11g/rac11g_ndmain_5_32g
+DATA/rac11g/rac11g_ndmain_6_32g
+DATA/rac11g/rac11g_undotbs1_2_32g
+DATA/rac11g/rac11g_undotbs2_2_32g
+DATA/rac11g/rac11g_perfstat_1_8g

已選擇14行。

SQL> SELECT FILE_NAME FROM DBA_TEMP_FILES;

FILE_NAME
---------------------------------------------------------------------------------------
+DATA/rac11g/rac11g_temp_1_4g

SQL> SELECT MEMBER FROM V$LOGFILE;

MEMBER
--------------------------------------------------------------------------------------
+DATA/rac11g/rac11g_redo1_1_1_1g
+DATA/rac11g/rac11g_redo1_2_1_1g
+DATA/rac11g/rac11g_redo2_2_1_1g
+DATA/rac11g/rac11g_redo2_2_2_1g

至此RAC資料庫成功進行了恢復。

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4227/viewspace-450255/,如需轉載,請註明出處,否則將追究法律責任。

相關文章