【RAC】將單例項備份集恢復為rac資料庫

路途中的人2012發表於2016-10-24

RAC】將單例項備份集恢復為rac資料庫

一.1  BLOG文件結構圖

 

wpsE532.tmp

 

一.2  前言部分

 

一.2.1  導讀

各位技術愛好者,看完本文後,你可以掌握如下的技能,也可以學到一些其它你所不知道的知識,~O(∩_∩)O~:

單例項環境的備份集如何恢復到rac環境(重點)

rman恢復資料庫的一般步驟

rac環境的簡單操作

 

注意:本篇BLOG中程式碼部分需要特別關注的地方我都用黃色背景和紅色字型來表示,比如下邊的例子中,thread 1的最大歸檔日誌號為33thread 2的最大歸檔日誌號為43是需要特別關注的地方。

  List of Archived Logs in backup set 11

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    32      1621589    2015-05-29 11:09:52 1625242    2015-05-29 11:15:48

  1    33      1625242    2015-05-29 11:15:48 1625293    2015-05-29 11:15:58

  2    42      1613951    2015-05-29 10:41:18 1625245    2015-05-29 11:15:49

  2    43      1625245    2015-05-29 11:15:49 1625253    2015-05-29 11:15:53

 

 

 

 

本文如有錯誤或不完善的地方請大家多多指正,ITPUB留言或QQ皆可,您的批評指正是我寫作的最大動力。

 

一.2.2  實驗環境介紹

 

源庫:11.2.0.1   RHEL6.5 單例項

目標庫:11.2.0.1  RHEL6.5  rac環境

 

 

一.2.3  相關參考文章連結

 

RAC】將RAC備份集恢復為單例項資料庫  http://blog.itpub.net/26736162/viewspace-1682255/

RAC】將單例項備份集恢復為rac資料庫 http://blog.itpub.net/26736162/viewspace-1682250/ 

RACrac環境下的資料庫備份與還原 http://blog.itpub.net/26736162/viewspace-1682237/



rac安裝系列:

【推薦】 一步一步搭建11gR2 rac+dg之結尾篇(十) 

http://blog.itpub.net/26736162/viewspace-1328156/ 

【推薦】 一步一步搭建11gR2 rac+dg之DG SWITCHOVER功能(九) 

http://blog.itpub.net/26736162/viewspace-1328050/ 

一步一步搭建11gR2 rac+dg之配置單例項的DG(八) 

http://blog.itpub.net/26736162/viewspace-1298735/ 

一步一步搭建11gR2 rac+dg之DG 機器配置(七) 

http://blog.itpub.net/26736162/viewspace-1298733/ 

一步一步搭建11gR2 rac+dg之安裝rac出現問題解決(六) 

http://blog.itpub.net/26736162/viewspace-1297128/ 

一步一步搭建oracle 11gR2 rac+dg之database安裝(五) 

http://blog.itpub.net/26736162/viewspace-1297113/ 

一步一步搭建 oracle 11gR2 rac+dg之grid安裝(四) 

http://blog.itpub.net/26736162/viewspace-1297101/ 

【推薦】 一步一步搭建oracle 11gR2 rac+dg之共享磁碟設定(三) 

http://blog.itpub.net/26736162/viewspace-1291144/ 

【推薦】 一步一步搭建oracle 11gR2 rac+dg之環境準備(二) 

http://blog.itpub.net/26736162/viewspace-1290416/ 

【推薦】 一步一步搭建 oracle 11gR2 rac + dg 之前傳 (一) 

http://blog.itpub.net/26736162/viewspace-1290405/ 

 

 

一.2.4  本文簡介

 

 

本文基於如何將單例項的資料庫備份恢復到rac環境下,至於rac環境的備份集如何恢復到單例項及rac環境的備份集恢復到rac環境的實驗請參考相關文章連結部分。

 

實驗的一些資料庫環境參考如下表格:

專案

source db

target  db

db 型別

單例項

rac環境

db version

11.2.0.1

11.2.0.1

ORACLE_SID

orastrac

orastrac1 orastrac2

db_name

orastrac

orastrac

主機IP地址:

 

192.168.59.129

192.168.1.31

192.168.1.32

 

 

 

先描述下大致步驟:

? 源端建立備份集;

? 目標端安裝資料庫軟體和叢集件,並配置好共享儲存(安裝rac的時候一般已經配置好了

? 複製源端備份集到目標端;

? 目錄端任意節點執行正常恢復,恢復時注意要將 spfile,controlfile,datafile,redofile 等路徑改到共享儲存上,恢復完後這會兒仍然是個單例項資料庫;

? 修改初始化引數、增加 UNDO 表空間、增加 REDOLOG 執行緒組,重建金鑰檔案,目標端任意節點執行;

? 目標端各個節點配置監聽及網路服務名;

? 將新建的資料庫配置到 crs,目標端任意節點執行即可。

 

一.3  實驗部分

 

一.3.1  實驗目標

 

將單例項的備份整合功的恢復到rac環境下,並新增資料庫到crs環境。

一.3.2  源庫操作

 

source庫上需要做的操作主要是備份和建立測試使用者。

 

一.3.2.1  靜默建立一個單例項的測試庫

 

首先修改歸檔模式,這樣建立的資料庫預設為歸檔模式,然後我們在源庫上靜默建立一個單例項的庫,sidorastrac,為oracle single instance to rac,關於靜默安裝資料庫參考:

靜默安裝系列 

 

【推薦】 【DBCA -SILENT】靜默方式安裝11gR2 oracle資料庫軟體 

http://blog.itpub.net/26736162/viewspace-1589769/ 

【推薦】 【DBCA -SILENT】靜默安裝之rac資料庫安裝 

http://blog.itpub.net/26736162/viewspace-1586352/ 

【推薦】 【DBCA -SILENT】靜默安裝如何啟用歸檔模式 

http://blog.itpub.net/26736162/viewspace-1585925/ 

【推薦】  DBCA靜默方式建庫 

http://blog.itpub.net/26736162/viewspace-1448220/ 

 

[oracle@orcltest ~]$ echo $ORACLE_HOME

/u01/app/oracle/product/11.2.0/dbhome_1

[oracle@orcltest ~]$ sqlplus -v

 

SQL*Plus: Release 11.2.0.1.0 Production

 

[oracle@orcltest ~]$ strings $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc | grep -i arch

         <archiveLogMode>false</archiveLogMode>

[oracle@orcltest ~]$ vi $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc

<?xml version = '1.0'?>

<DatabaseTemplate name="General_Purpose" description="" version="11.1.0.0.0">

   <CommonAttributes>

      <option name="OMS" value="false"/>

      <option name="JSERVER" value="true"/>

      <option name="SPATIAL" value="true"/>

      <option name="IMEDIA" value="true"/>

      <option name="XDB_PROTOCOLS" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="ORACLE_TEXT" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="SAMPLE_SCHEMA" value="false"/>

      <option name="CWMLITE" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="EM_REPOSITORY" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="APEX" value="true"/>

      <option name="OWB" value="true"/>

      <option name="DV" value="false"/>

   </CommonAttributes>

   <Variables/>

   <CustomScripts Execute="false"/>

   <InitParamAttributes>

      <InitParams>

         <initParam name="db_name" value=""/>

         <initParam name="dispatchers" value="(PROTOCOL=TCP) (SERVICE={SID}XDB)"/>

         <initParam name="audit_file_dest" value="{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump"/>

         <initParam name="compatible" value="11.2.0.0.0"/>

         <initParam name="remote_login_passwordfile" value="EXCLUSIVE"/>

         <initParam name="processes" value="150"/>

         <initParam name="undo_tablespace" value="UNDOTBS1"/>

         <initParam name="control_files" value="("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/flash_recovery_area/{DB_UNIQUE_NAME}/control02.ctl")"/>

         <initParam name="diagnostic_dest" value="{ORACLE_BASE}"/>

         <initParam name="db_recovery_file_dest" value="{ORACLE_BASE}/flash_recovery_area"/>

         <initParam name="audit_trail" value="db"/>

         <initParam name="memory_target" value="250" unit="MB"/>

         <initParam name="db_block_size" value="8" unit="KB"/>

         <initParam name="open_cursors" value="300"/>

         <initParam name="db_recovery_file_dest_size" value="" unit="MB"/>

      </InitParams>

      <MiscParams>

         <databaseType>MULTIPURPOSE</databaseType>

         <maxUserConn>20</maxUserConn>

         <percentageMemTOSGA>40</percentageMemTOSGA>

         <customSGA>false</customSGA>

         <archiveLogMode>true</archiveLogMode>

         <initParamFileName>{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/pfile/init.ora</initParamFileName>

      </MiscParams>

      <SPfile useSPFile="true">{ORACLE_HOME}/dbs/spfile{SID}.ora</SPfile>

   </InitParamAttributes>

   <StorageAttributes>

      <DataFiles>

"/u01/app/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc" 95L, 4985C written                                                                                     

[oracle@orcltest ~]$ strings $ORACLE_HOME/assistants/dbca/templates/General_Purpose.dbc | grep -i arch

         <archiveLogMode>true</archiveLogMode>

[oracle@orcltest ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orastrac -sid orastrac -sysPassword lhr -systemPassword lhr -responseFile NO_VALUE -datafileDestination /u01/app/oracle/oradata -redoLogFileSize 50 -recoveryAreaDestination /u01/app/oracle/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 200 -databaseType OLTP -emConfiguration NONE  -automaticMemoryManagement true

Copying database files

1% complete

3% complete

10% complete

17% complete

24% complete

35% complete

Creating and starting Oracle instance

37% complete

42% complete

47% complete

52% complete

53% complete

56% complete

58% complete

Registering database with Oracle Restart

64% complete

Completing Database Creation

68% complete

71% complete

75% complete

85% complete

86% complete

96% complete

100% complete

Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orastrac/orastrac.log" for further details.

[oracle@orcltest ~]$

[oracle@orcltest ~]$ ORACLE_SID=orastrac

[oracle@orcltest ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 11:09:02 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

SQL> show parameter name

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_file_name_convert                 string

db_name                              string      orastrac

db_unique_name                       string      orastrac

global_names                         boolean     FALSE

instance_name                        string      orastrac

lock_name_space                      string

log_file_name_convert                string

service_names                        string      orastrac

SQL> create user lhr identified by lhr;

 

User created.

 

SQL> grant dba to lhr;

 

Grant succeeded.

 

SQL> create table lhr.test_rac as select * from dba_objects;

 

Table created.

 

SQL> select count(1) FROM LHR.TEST_RAC;

 

  COUNT(1)

----------

     72468

 

SQL>

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     3

Next log sequence to archive   5

Current log sequence           5

SQL>

 

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      /u01/app/oracle/product/11.2.0

                                                 /dbhome_1/dbs/spfileorastrac.o

                                                 ra

SQL>

 

 

一.3.2.2  source庫執行備份操作

 

 

備份指令碼如下,注意控制檔案需要最後備份:

run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup database format  '/home/oracle/rman_back/full_%n_%T_%t_%s_%p.bak';

sql 'alter system archive log current';

backup archivelog all format '/home/oracle/rman_back/arch_%d_%T_%s_%p.bak' delete input;

backup current controlfile format '/home/oracle/rman_back/ctl_%d_%T_%s_%p.bak';

release channel c1;

release channel c2;

}

 

 

執行過程如下:

[oracle@orcltest ~]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 1 11:12:15 2015

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database: ORASTRAC (DBID=1317814272)

 

RMAN> run

2> {

3>  allocate channel c1 type disk;

4>  allocate channel c2 type disk;

5>  backup database format  '/home/oracle/rman_back/full_%n_%T_%t_%s_%p.bak';

6>  sql 'alter system archive log current';

7>  backup archivelog all format '/home/oracle/rman_back/arch_%d_%T_%s_%p.bak' delete input;

8>  backup current controlfile format '/home/oracle/rman_back/ctl_%d_%T_%s_%p.bak';

9>  release channel c1;

10>  release channel c2;

11> }

 

using target database control file instead of recovery catalog

allocated channel: c1

channel c1: SID=142 device type=DISK

 

allocated channel: c2

channel c2: SID=20 device type=DISK

 

Starting backup at 2015-06-01 11:12:28

channel c1: starting full datafile backup set

channel c1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/orastrac/system01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/orastrac/users01.dbf

channel c1: starting piece 1 at 2015-06-01 11:12:29

channel c2: starting full datafile backup set

channel c2: specifying datafile(s) in backup set

input datafile file number=00002 name=/u01/app/oracle/oradata/orastrac/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/orastrac/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/orastrac/undotbs01.dbf

channel c2: starting piece 1 at 2015-06-01 11:12:29

channel c2: finished piece 1 at 2015-06-01 11:15:26

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak tag=TAG20150601T111228 comment=NONE

channel c2: backup set complete, elapsed time: 00:02:59

channel c2: starting full datafile backup set

channel c2: specifying datafile(s) in backup set

including current control file in backup set

channel c2: starting piece 1 at 2015-06-01 11:15:48

channel c2: finished piece 1 at 2015-06-01 11:15:49

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881234138_3_1.bak tag=TAG20150601T111228 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:01

channel c2: starting full datafile backup set

channel c2: specifying datafile(s) in backup set

including current SPFILE in backup set

channel c2: starting piece 1 at 2015-06-01 11:15:50

channel c2: finished piece 1 at 2015-06-01 11:15:51

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak tag=TAG20150601T111228 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:01

channel c1: finished piece 1 at 2015-06-01 11:15:53

piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak tag=TAG20150601T111228 comment=NONE

channel c1: backup set complete, elapsed time: 00:03:24

Finished backup at 2015-06-01 11:15:53

 

sql statement: alter system archive log current

 

Starting backup at 2015-06-01 11:16:05

current log archived

channel c1: starting archived log backup set

channel c1: specifying archived log(s) in backup set

input archived log thread=1 sequence=5 RECID=1 STAMP=881234164

channel c1: starting piece 1 at 2015-06-01 11:16:05

channel c2: starting archived log backup set

channel c2: specifying archived log(s) in backup set

input archived log thread=1 sequence=6 RECID=2 STAMP=881234165

channel c2: starting piece 1 at 2015-06-01 11:16:06

channel c1: finished piece 1 at 2015-06-01 11:16:09

piece handle=/home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak tag=TAG20150601T111605 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:04

channel c1: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORASTRAC/archivelog/2015_06_01/o1_mf_1_5_bpqmmhbp_.arc RECID=1 STAMP=881234164

channel c2: finished piece 1 at 2015-06-01 11:16:10

piece handle=/home/oracle/rman_back/arch_ORASTRAC_20150601_6_1.bak tag=TAG20150601T111605 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:04

channel c2: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORASTRAC/archivelog/2015_06_01/o1_mf_1_6_bpqmmo4t_.arc RECID=2 STAMP=881234165

Finished backup at 2015-06-01 11:16:10

 

Starting backup at 2015-06-01 11:16:10

channel c1: starting full datafile backup set

channel c1: specifying datafile(s) in backup set

including current control file in backup set

channel c1: starting piece 1 at 2015-06-01 11:16:11

channel c1: finished piece 1 at 2015-06-01 11:16:12

piece handle=/home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak tag=TAG20150601T111610 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:01

Finished backup at 2015-06-01 11:16:12

 

released channel: c1

 

released channel: c2

 

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

1       Full    501.84M    DISK        00:02:42     2015-06-01 11:15:11

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak

  List of Datafiles in backup set 1

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  2       Full 1027268    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/sysaux01.dbf

  3       Full 1027268    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/undotbs01.dbf

  5       Full 1027268    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

2       Full    9.33M      DISK        00:00:10     2015-06-01 11:15:48

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234138_3_1.bak

  Control File Included: Ckp SCN: 1027334      Ckp time: 2015-06-01 11:15:38

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

3       Full    80.00K     DISK        00:00:00     2015-06-01 11:15:50

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak

  SPFILE Included: Modification time: 2015-06-01 11:12:28

  SPFILE db_unique_name: ORASTRAC

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

4       Full    599.97M    DISK        00:03:24     2015-06-01 11:15:52

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak

  List of Datafiles in backup set 4

  File LV Type Ckp SCN    Ckp Time            Name

  ---- -- ---- ---------- ------------------- ----

  1       Full 1027267    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/system01.dbf

  4       Full 1027267    2015-06-01 11:12:29 /u01/app/oracle/oradata/orastrac/users01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

5       41.16M     DISK        00:00:02     2015-06-01 11:16:07

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak

 

  List of Archived Logs in backup set 5

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    5       1012317    2015-06-01 11:04:50 1027356    2015-06-01 11:15:59

 

BS Key  Size       Device Type Elapsed Time Completion Time   

------- ---------- ----------- ------------ -------------------

6       2.00K      DISK        00:00:02     2015-06-01 11:16:07

        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_6_1.bak

 

  List of Archived Logs in backup set 6

  Thrd Seq     Low SCN    Low Time            Next SCN   Next Time

  ---- ------- ---------- ------------------- ---------- ---------

  1    6       1027356    2015-06-01 11:15:59 1027365    2015-06-01 11:16:05

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time   

------- ---- -- ---------- ----------- ------------ -------------------

7       Full    9.33M      DISK        00:00:02     2015-06-01 11:16:12

        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111610

        Piece Name: /home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak

  Control File Included: Ckp SCN: 1027386      Ckp time: 2015-06-01 11:16:10

 

RMAN> list backupset summary;

 

 

List of Backups

===============

Key     TY LV S Device Type Completion Time     #Pieces #Copies Compressed Tag

------- -- -- - ----------- ------------------- ------- ------- ---------- ---

1       B  F  A DISK        2015-06-01 11:15:11 1       1       NO         TAG20150601T111228

2       B  F  A DISK        2015-06-01 11:15:48 1       1       NO         TAG20150601T111228

3       B  F  A DISK        2015-06-01 11:15:50 1       1       NO         TAG20150601T111228

4       B  F  A DISK        2015-06-01 11:15:52 1       1       NO         TAG20150601T111228

5       B  A  A DISK        2015-06-01 11:16:07 1       1       NO         TAG20150601T111605

6       B  A  A DISK        2015-06-01 11:16:07 1       1       NO         TAG20150601T111605

7       B  F  A DISK        2015-06-01 11:16:12 1       1       NO         TAG20150601T111610

 

RMAN>

 

 

 

一.3.2.3  將備份傳遞到target

這個方法就多了,可以採用ftp上傳下載,也可以採用NFS網路檔案系統,或者scp命令都可以,這裡我們採用scp直接傳遞到rac環境的第一個節點。

 

源庫scp操作:

[oracle@orcltest ~]$ cd rman_back/

[oracle@orcltest rman_back]$ ll

total 1189660

-rw-r----- 1 oracle asmadmin  43154944 Jun  1 11:16 arch_ORASTRAC_20150601_5_1.bak

-rw-r----- 1 oracle asmadmin      2560 Jun  1 11:16 arch_ORASTRAC_20150601_6_1.bak

-rw-r----- 1 oracle asmadmin   9797632 Jun  1 11:16 ctl_ORASTRAC_20150601_7_1.bak

-rw-r----- 1 oracle asmadmin 629121024 Jun  1 11:15 full_ORASTRAC_20150601_881233948_1_1.bak

-rw-r----- 1 oracle asmadmin 526229504 Jun  1 11:14 full_ORASTRAC_20150601_881233949_2_1.bak

-rw-r----- 1 oracle asmadmin   9797632 Jun  1 11:15 full_ORASTRAC_20150601_881234138_3_1.bak

-rw-r----- 1 oracle asmadmin     98304 Jun  1 11:15 full_ORASTRAC_20150601_881234150_4_1.bak

[oracle@orcltest rman_back]$ ll -h

total 1.2G

-rw-r----- 1 oracle asmadmin  42M Jun  1 11:16 arch_ORASTRAC_20150601_5_1.bak

-rw-r----- 1 oracle asmadmin 2.5K Jun  1 11:16 arch_ORASTRAC_20150601_6_1.bak

-rw-r----- 1 oracle asmadmin 9.4M Jun  1 11:16 ctl_ORASTRAC_20150601_7_1.bak

-rw-r----- 1 oracle asmadmin 600M Jun  1 11:15 full_ORASTRAC_20150601_881233948_1_1.bak

-rw-r----- 1 oracle asmadmin 502M Jun  1 11:14 full_ORASTRAC_20150601_881233949_2_1.bak

-rw-r----- 1 oracle asmadmin 9.4M Jun  1 11:15 full_ORASTRAC_20150601_881234138_3_1.bak

-rw-r----- 1 oracle asmadmin  96K Jun  1 11:15 full_ORASTRAC_20150601_881234150_4_1.bak

[oracle@orcltest rman_back]$

[oracle@orcltest rman_back]$ scp -r /home/oracle/rman_back  oracle@192.168.1.31:/home/oracle

oracle@192.168.1.31's password:

ctl_ORASTRAC_20150601_7_1.bak                                                                                                                                                  100%  9.4MB  17.7MB/s   00:01   

arch_ORASTRAC_20150601_5_1.bak                                                                                                                                                 100%   42MB  27.0MB/s   00:03   

arch_ORASTRAC_20150601_6_1.bak                                                                                                                                                 100%  2.5KB  16.5MB/s   00:02   

full_ORASTRAC_20150601_881233948_1_1.bak                                                                                                                                       100%   18MB  17.7MB/s   00:01   

full_ORASTRAC_20150601_881233949_2_1.bak                                                                                                                                       100%  618MB  12.4MB/s   00:50   

full_ORASTRAC_20150601_881234138_3_1.bak                                                                                                                                       100%  500MB  15.2MB/s   00:33   

full_ORASTRAC_20150601_881234150_4_1.bak                                                                                                                                       100%   96KB  96.0KB/s   00:00   

[oracle@node2 rman_back]$

 

 

 

 

 

target庫檢視備份檔案:

[oracle@node1 rman_back]$ ll -h

total 1.2G

-rw-r----- 1 oracle oinstall  42M Jun  1 11:19 arch_ORASTRAC_20150601_5_1.bak

-rw-r----- 1 oracle oinstall 2.5K Jun  1 11:23 arch_ORASTRAC_20150601_6_1.bak

-rw-r----- 1 oracle oinstall 9.4M Jun  1 11:21 ctl_ORASTRAC_20150601_7_1.bak

-rw-r----- 1 oracle oinstall 600M Jun  1 11:23 full_ORASTRAC_20150601_881233948_1_1.bak

-rw-r----- 1 oracle oinstall 502M Jun  1 11:21 full_ORASTRAC_20150601_881233949_2_1.bak

-rw-r----- 1 oracle oinstall 9.4M Jun  1 11:21 full_ORASTRAC_20150601_881234138_3_1.bak

-rw-r----- 1 oracle oinstall  96K Jun  1 11:23 full_ORASTRAC_20150601_881234150_4_1.bak

[oracle@node1 rman_back]$

 

 

一.3.3  target庫操作

 

以下操作若無特殊說明均在節點一操作。

 

一.3.3.1  檢視rac環境

 

target庫已經有3個庫,都處於close狀態。

[root@node2 ~]# crsstat

Name                           Type                       Target     State      Host      

------------------------------ -------------------------- ---------- ---------  -------  

ora.ARCH.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.DATA.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.LISTENER.lsnr              ora.listener.type          ONLINE     ONLINE     node1    

ora.LISTENER_SCAN1.lsnr        ora.scan_listener.type     ONLINE     ONLINE     node1    

ora.OVDISK.dg                  ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.TEST.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.asm                        ora.asm.type               ONLINE     ONLINE     node1    

ora.db.db                      ora.database.type          OFFLINE    OFFLINE             

ora.eons                       ora.eons.type              ONLINE     ONLINE     node1    

ora.gsd                        ora.gsd.type               OFFLINE    OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     ONLINE     node1    

ora.jmrac.haha.svc             ora.service.type           ONLINE     ONLINE     node1    

ora.net1.network               ora.network.type           ONLINE     ONLINE     node1    

ora.node1.ASM1.asm             application                ONLINE     ONLINE     node1    

ora.node1.LISTENER_NODE1.lsnr  application                ONLINE     ONLINE     node1    

ora.node1.gsd                  application                OFFLINE    OFFLINE             

ora.node1.ons                  application                ONLINE     ONLINE     node1    

ora.node1.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node1    

ora.node2.ASM2.asm             application                ONLINE     ONLINE     node2    

ora.node2.LISTENER_NODE2.lsnr  application                ONLINE     ONLINE     node2    

ora.node2.gsd                  application                OFFLINE    OFFLINE             

ora.node2.ons                  application                ONLINE     ONLINE     node2    

ora.node2.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node2    

ora.oc4j                       ora.oc4j.type              OFFLINE    OFFLINE             

ora.ons                        ora.ons.type               ONLINE     ONLINE     node1    

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.registry.acfs              ora.registry.acfs.type     ONLINE     ONLINE     node1    

ora.scan1.vip                  ora.scan_vip.type          ONLINE     ONLINE     node1

[root@node2 ~]# crsstat | grep ora.database.type

ora.db.db                      ora.database.type          OFFLINE    OFFLINE             

ora.jmrac.db                   ora.database.type          OFFLINE    OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

[root@node2 ~]#

 

 

檢視磁碟組的情況,確保有足夠的空間來還原資料庫:

[root@node2 ~]# su - grid

[grid@node2 ~]$ asmcmd

ASMCMD>

ASMCMD> lsdg

State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name

MOUNTED  EXTERN  N         512   4096  1048576      9999     8905                0            8905              0             N  ARCH/

MOUNTED  EXTERN  N         512   4096  1048576     19999    11604                0           11604              0             N  DATA/

MOUNTED  EXTERN  N         512   4096  1048576      3099     2703                0            2703              0             N  OVDISK/

MOUNTED  EXTERN  N         512   4096  1048576      1024      929                0             929              0             N  TEST/

ASMCMD>

 

[root@node2 ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1       localhost.localdomain localhost

::1             localhost6.localdomain6 localhost6

 

#public

192.168.1.31     node1

192.168.1.32     node2

#vip

192.168.1.131   node1-vip

192.168.1.132   node2-vip

#priv

9.9.9.31    node1-priv

9.9.9.32    node2-priv

 

#scan

192.168.1.35     cluster-scan

 

 

 

[root@node2 ~]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:79:BA:86 

          inet addr:192.168.1.32 Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:150190 errors:0 dropped:0 overruns:0 frame:0

          TX packets:109804 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:205303912 (195.7 MiB)  TX bytes:20182601 (19.2 MiB)

 

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:79:BA:86 

          inet addr:192.168.1.132  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

 

eth1      Link encap:Ethernet  HWaddr 00:0C:29:79:BA:90 

          inet addr:9.9.9.32  Bcast:9.9.9.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:49075 errors:0 dropped:0 overruns:0 frame:0

          TX packets:49811 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:23642469 (22.5 MiB)  TX bytes:31528595 (30.0 MiB)

 

lo        Link encap:Local Loopback 

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:16496 errors:0 dropped:0 overruns:0 frame:0

          TX packets:16496 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:15118447 (14.4 MiB)  TX bytes:15118447 (14.4 MiB)

 

[root@node2 ~]#

 

 

一.3.3.2  恢復spfilepfile,修改pfile,建立相關路徑:

 

 

首先利用rman恢復spfile

[oracle@node1 rman_back]$ ORACLE_SID=orastrac

[oracle@node1 rman_back]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 1 13:25:33 2015

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database (not started)

 

RMAN> set dbid 1317814272

 

executing command: SET DBID

 

RMAN> startup nomount;

 

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorastrac.ora'

 

starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started

 

Total System Global Area     158662656 bytes

 

Fixed Size                     2211448 bytes

Variable Size                 96469384 bytes

Database Buffers              54525952 bytes

Redo Buffers                   5455872 bytes

 

RMAN> restore spfile to pfile '?/dbs/initorastrac.ora' from '/home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak';

 

Starting restore at 01-JUN-2015 13:25:59

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=25 device type=DISK

 

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 01-JUN-2015 13:26:00

 

RMAN>

RMAN> exit

 

 

Recovery Manager complete.

[oracle@node1 rman_back]$ ll /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorastrac.ora

-rw-r--r-- 1 oracle asmadmin 997 Jun  1 13:25 /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorastrac.ora

[oracle@node1 rman_back]$

[oracle@node1 rman_back]$ more /u01/app/oracle/product/11.2.0/dbhome_1/dbs/initorastrac.ora

orastrac.__db_cache_size=121634816

orastrac.__java_pool_size=4194304

orastrac.__large_pool_size=4194304

orastrac.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment

orastrac.__pga_aggregate_target=167772160

orastrac.__sga_target=243269632

orastrac.__shared_io_pool_size=0

orastrac.__shared_pool_size=100663296

orastrac.__streams_pool_size=0

*.audit_file_dest='/u01/app/oracle/admin/orastrac/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='/u01/app/oracle/oradata/orastrac/control01.ctl','/u01/app/oracle/flash_recovery_area/orastrac/control02.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='orastrac'

*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orastracXDB)'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=408944640

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

[oracle@node1 rman_back]$

 

 

修改與路徑相關的引數,修改後如下:

[oracle@node1 dbs]$ more initorastrac.ora

*.audit_file_dest='/u01/app/oracle/admin/orastrac/adump'

*.audit_trail='db'

*.compatible='11.2.0.0.0'

*.control_files='+DATA/orastrac/controlfile/control01.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='orastrac'

*.db_recovery_file_dest='+ARCH'

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orastracXDB)'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=408944640

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

 

 

插曲:注意,這裡如果想讓控制檔案的格式為ASM格式,可以這樣設定控制檔案的路徑:

 

pfile檔案中的control_files這樣寫: *.control_files='+DATA','+ARCH',然後還原的時候就可以直接還原為asm格式的檔案了,我這裡由於是後邊補上的,所以就不採用如下的形式了,如下:

 

 

RMAN> restore controlfile   from '/home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak';

 

Starting restore at 01-JUN-2015 17:59:39

using channel ORA_DISK_1

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

output file name=+DATA/orastrac/controlfile/current.357.881258379

output file name=+ARCH/orastrac/controlfile/current.369.881258379

Finished restore at 01-JUN-2015 17:59:40

 

RMAN>

 

 

建立os檔案路徑,注意在節點一和節點二都執行:

[oracle@node1 ~]$ mkdir -p /u01/app/oracle/admin/orastrac/adump

[oracle@node1 ~]$

 

 

注意喲,建立的 spfile 可是要放到共享儲存上去的: 

 

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 15:49:22 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL>  create spfile='+DATA' from pfile;

 

File created.

 

SQL>

File created.

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string

SQL>

 

 

檢視新建立的spfile的檔名:

ASMCMD> pwd

+DATA/orastrac/PARAMETERFILE

ASMCMD> ls

spfile.335.881250575

ASMCMD>

 

 

[oracle@node1 dbs]$ cp initorastrac.ora initorastrac.ora_bk2

[oracle@node1 dbs]$ echo "SPFILE='+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575'" > $ORACLE_HOME/dbs/initorastrac.ora

[oracle@node1 dbs]$

[oracle@node1 dbs]$ more initorastrac.ora

SPFILE='+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575'

[oracle@node1 dbs]$

 

一.3.3.3  恢復控制檔案

 

[oracle@node1 dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 1 15:46:55 2015

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

 

connected to target database (not started)

 

RMAN> startup nomount force;

 

Oracle instance started

 

Total System Global Area     409194496 bytes

 

Fixed Size                     2213856 bytes

Variable Size                272631840 bytes

Database Buffers             130023424 bytes

Redo Buffers                   4325376 bytes

 

RMAN> restore controlfile   from '/home/oracle/rman_back/ctl_ORASTRAC_20150601_7_1.bak';

 

Starting restore at 01-JUN-2015 15:47:14

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=29 device type=DISK

 

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:07

output file name=+DATA/orastrac/controlfile/control01.ctl

Finished restore at 01-JUN-2015 15:47:21

 

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

RMAN>

 

 

 

 

 

一.3.3.4  還原及恢復資料檔案

 

首先得到執行的指令碼:

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 15:58:47 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL> set line 9999 pagesize 9999

SQL> col FILE_NAME format a60

SQL> select 'datafile' file_type, file#,name FILE_NAME,status,enabled from v$datafile

  2  union all

  3  select 'tempfile',file#,name FILE_NAME,status,enabled from v$tempfile

  4  union all

  5  select 'logfile',group# file#,member FILE_NAME,status,'' from v$logfile

  6  union all

  7  select 'controlfile', to_number('') ,name FILE_NAME,status,'' from v$controlfile

  8  ;

 

FILE_TYPE        FILE# FILE_NAME                                                    STATUS  ENABLED

----------- ---------- ------------------------------------------------------------ ------- ----------

datafile             1 /u01/app/oracle/oradata/orastrac/system01.dbf                SYSTEM  READ WRITE

datafile             2 /u01/app/oracle/oradata/orastrac/sysaux01.dbf                ONLINE  READ WRITE

datafile             3 /u01/app/oracle/oradata/orastrac/undotbs01.dbf               ONLINE  READ WRITE

datafile             4 /u01/app/oracle/oradata/orastrac/users01.dbf                 ONLINE  READ WRITE

datafile             5 /u01/app/oracle/oradata/orastrac/example01.dbf               ONLINE  READ WRITE

tempfile             1 /u01/app/oracle/oradata/orastrac/temp01.dbf                  ONLINE  READ WRITE

logfile              3 /u01/app/oracle/oradata/orastrac/redo03.log

logfile              2 /u01/app/oracle/oradata/orastrac/redo02.log

logfile              1 /u01/app/oracle/oradata/orastrac/redo01.log

controlfile            +DATA/orastrac/controlfile/control01.ctl

 

10 rows selected.

 

SQL> set pagesize  200 linesize 200

SQL> select 'set newname for datafile ' || a.FILE# || ' to "' || a.NAME || '";'

  2    from v$datafile a

  3  union all

  4  select 'set newname for tempfile ' || a.FILE# || ' to "' || a.NAME || '";'

  5    from v$tempfile a

  6  union all

  7  SELECT 'SQL "ALTER DATABASE RENAME FILE ''''' || a.MEMBER || '''''  to  ''''' ||

  8         a.MEMBER || ''''' ";'

  9    FROM v$logfile a;

 

'SETNEWNAMEFORDATAFILE'||A.FILE#||'TO"'||A.NAME||'";'

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

set newname for datafile 1 to "/u01/app/oracle/oradata/orastrac/system01.dbf";

set newname for datafile 2 to "/u01/app/oracle/oradata/orastrac/sysaux01.dbf";

set newname for datafile 3 to "/u01/app/oracle/oradata/orastrac/undotbs01.dbf";

set newname for datafile 4 to "/u01/app/oracle/oradata/orastrac/users01.dbf";

set newname for datafile 5 to "/u01/app/oracle/oradata/orastrac/example01.dbf";

set newname for tempfile 1 to "/u01/app/oracle/oradata/orastrac/temp01.dbf";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo03.log''  to  ''/u01/app/oracle/oradata/orastrac/redo03.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo02.log''  to  ''/u01/app/oracle/oradata/orastrac/redo02.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo01.log''  to  ''/u01/app/oracle/oradata/orastrac/redo01.log'' ";

 

9 rows selected.

 

SQL>

 

 

 

 

檢視備份集及還原資料庫:

RMAN> list backupset;

 

 

List of Backup Sets

===================

 

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

1       Full    501.84M    DISK        00:02:42     01-JUN-2015 11:15:11

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak

  List of Datafiles in backup set 1

  File LV Type Ckp SCN    Ckp Time             Name

  ---- -- ---- ---------- -------------------- ----

  2       Full 1027268    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/sysaux01.dbf

  3       Full 1027268    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/undotbs01.dbf

  5       Full 1027268    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/example01.dbf

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

2       Full    9.33M      DISK        00:00:10     01-JUN-2015 11:15:48

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234138_3_1.bak

  Control File Included: Ckp SCN: 1027334      Ckp time: 01-JUN-2015 11:15:38

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

3       Full    80.00K     DISK        00:00:00     01-JUN-2015 11:15:50

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881234150_4_1.bak

  SPFILE Included: Modification time: 01-JUN-2015 11:12:28

  SPFILE db_unique_name: ORASTRAC

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    

------- ---- -- ---------- ----------- ------------ --------------------

4       Full    599.97M    DISK        00:03:24     01-JUN-2015 11:15:52

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111228

        Piece Name: /home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak

  List of Datafiles in backup set 4

  File LV Type Ckp SCN    Ckp Time             Name

  ---- -- ---- ---------- -------------------- ----

  1       Full 1027267    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/system01.dbf

  4       Full 1027267    01-JUN-2015 11:12:29 /u01/app/oracle/oradata/orastrac/users01.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time    

------- ---------- ----------- ------------ --------------------

5       41.16M     DISK        00:00:02     01-JUN-2015 11:16:07

        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak

 

  List of Archived Logs in backup set 5

  Thrd Seq     Low SCN    Low Time             Next SCN   Next Time

  ---- ------- ---------- -------------------- ---------- ---------

  1    5       1012317    01-JUN-2015 11:04:50 1027356    01-JUN-2015 11:15:59

 

BS Key  Size       Device Type Elapsed Time Completion Time    

------- ---------- ----------- ------------ --------------------

6       2.00K      DISK        00:00:02     01-JUN-2015 11:16:07

        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20150601T111605

        Piece Name: /home/oracle/rman_back/arch_ORASTRAC_20150601_6_1.bak

 

  List of Archived Logs in backup set 6

  Thrd Seq     Low SCN    Low Time             Next SCN   Next Time

  ---- ------- ---------- -------------------- ---------- ---------

  1   6       1027356    01-JUN-2015 11:15:59 1027365    01-JUN-2015 11:16:05

 

RMAN>

RMAN> run {

2> ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

3> set newname for datafile 1 to "+DATA";

4> set newname for datafile 2 to "+DATA";

5> set newname for datafile 3 to "+DATA";

6> set newname for datafile 4 to "+DATA";

7> set newname for datafile 5 to "+DATA";

8> set newname for tempfile 1 to "+DATA";

9> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo03.log''  to  ''+DATA'' ";

10> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo02.log''  to  ''+DATA'' ";

11> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo01.log''  to  ''+DATA'' ";

12> restore database;

13> SWITCH DATAFILE ALL;

14> SWITCH TEMPFILE ALL;

15> release channel c1;

16> }

 

allocated channel: c1

channel c1: SID=27 device type=DISK

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo03.log''  to  ''+DATA''

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo02.log''  to  ''+DATA''

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/orastrac/redo01.log''  to  ''+DATA''

 

Starting restore at 01-JUN-2015 16:04:19

Starting implicit crosscheck backup at 01-JUN-2015 16:04:19

Crosschecked 6 objects

Finished implicit crosscheck backup at 01-JUN-2015 16:04:19

 

Starting implicit crosscheck copy at 01-JUN-2015 16:04:19

Finished implicit crosscheck copy at 01-JUN-2015 16:04:19

 

searching for all files in the recovery area

cataloging files...

no files cataloged

 

 

channel c1: starting datafile backup set restore

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00002 to +DATA

channel c1: restoring datafile 00003 to +DATA

channel c1: restoring datafile 00005 to +DATA

channel c1: reading from backup piece /home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak

channel c1: piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233949_2_1.bak tag=TAG20150601T111228

channel c1: restored backup piece 1

channel c1: restore complete, elapsed time: 00:00:48

channel c1: starting datafile backup set restore

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00001 to +DATA

channel c1: restoring datafile 00004 to +DATA

channel c1: reading from backup piece /home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak

channel c1: piece handle=/home/oracle/rman_back/full_ORASTRAC_20150601_881233948_1_1.bak tag=TAG20150601T111228

channel c1: restored backup piece 1

channel c1: restore complete, elapsed time: 00:00:49

Finished restore at 01-JUN-2015 16:05:58

 

datafile 1 switched to datafile copy

input datafile copy RECID=7 STAMP=881251559 file name=+DATA/orastrac/datafile/system.330.881251509

datafile 2 switched to datafile copy

input datafile copy RECID=8 STAMP=881251559 file name=+DATA/orastrac/datafile/sysaux.331.881251461

datafile 3 switched to datafile copy

input datafile copy RECID=9 STAMP=881251559 file name=+DATA/orastrac/datafile/undotbs1.329.881251463

datafile 4 switched to datafile copy

input datafile copy RECID=10 STAMP=881251559 file name=+DATA/orastrac/datafile/users.327.881251511

datafile 5 switched to datafile copy

input datafile copy RECID=11 STAMP=881251559 file name=+DATA/orastrac/datafile/example.332.881251463

 

renamed tempfile 1 to +DATA in control file

 

released channel: c1

 

RMAN>

 

RMAN> RUN

2> {

3> set until sequence 6; 

4> recover database;

5> }

 

executing command: SET until clause

 

Starting recover at 01-JUN-2015 16:08:53

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=27 device type=DISK

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=5

channel ORA_DISK_1: reading from backup piece /home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak

channel ORA_DISK_1: piece handle=/home/oracle/rman_back/arch_ORASTRAC_20150601_5_1.bak tag=TAG20150601T111605

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

archived log file name=+ARCH/orastrac/archivelog/2015_06_01/thread_1_seq_5.350.881251737 thread=1 sequence=5

channel default: deleting archived log(s)

archived log file name=+ARCH/orastrac/archivelog/2015_06_01/thread_1_seq_5.350.881251737 RECID=3 STAMP=881251739

media recovery complete, elapsed time: 00:00:02

Finished recover at 01-JUN-2015 16:09:01

 

RMAN>

 

 

 

 

 

 

告警日誌:

 

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orastrac/redo03.log'  to  '+DATA'

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orastrac/redo03.log'  to  '+DATA'

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orastrac/redo02.log'  to  '+DATA'

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orastrac/redo02.log'  to  '+DATA'

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orastrac/redo01.log'  to  '+DATA'

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/orastrac/redo01.log'  to  '+DATA'

SUCCESS: diskgroup ARCH was mounted

Mon Jun 01 16:04:40 2015

Full restore complete of datafile 5 to datafile copy +DATA/orastrac/datafile/example.332.881251463.  Elapsed time: 0:00:14

  checkpoint is 1027268

  last deallocation scn is 965277

Full restore complete of datafile 3 to datafile copy +DATA/orastrac/datafile/undotbs1.329.881251463.  Elapsed time: 0:00:18

  checkpoint is 1027268

  last deallocation scn is 983226

Mon Jun 01 16:05:05 2015

Full restore complete of datafile 2 to datafile copy +DATA/orastrac/datafile/sysaux.331.881251461.  Elapsed time: 0:00:43

  checkpoint is 1027268

  last deallocation scn is 1026156

Full restore complete of datafile 4 to datafile copy +DATA/orastrac/datafile/users.327.881251511.  Elapsed time: 0:00:03

  checkpoint is 1027267

Mon Jun 01 16:05:49 2015

Full restore complete of datafile 1 to datafile copy +DATA/orastrac/datafile/system.330.881251509.  Elapsed time: 0:00:39

  checkpoint is 1027267

  last deallocation scn is 1025383

Mon Jun 01 16:05:59 2015

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/system01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 1 complete to datafile copy

  checkpoint is 1027267

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/sysaux01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 2 complete to datafile copy

  checkpoint is 1027268

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/undotbs01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 3 complete to datafile copy

  checkpoint is 1027268

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/users01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 4 complete to datafile copy

  checkpoint is 1027267

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/orastrac/example01.dbf

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

Switch of datafile 5 complete to datafile copy

  checkpoint is 1027268

Mon Jun 01 16:06:02 2015

Signalling error 1152 for datafile 1!

Signalling error 1152 for datafile 2!

Signalling error 1152 for datafile 3!

Signalling error 1152 for datafile 4!

Signalling error 1152 for datafile 5!

Checker run found 5 new persistent data failures

 

 

一.3.3.5  RESETLOGS開啟資料庫並驗證資料

 

RMAN>  alter database open resetlogs;

 

database opened

 

RMAN>

 

 

告警日誌:

Mon Jun 01 16:09:51 2015

alter database open resetlogs

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

RESETLOGS after incomplete recovery UNTIL CHANGE 1027356

Resetting resetlogs activation ID 1317842432 (0x4e8cae00)

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 1 of thread 1

ORA-00312: online log 1 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_ora_19721.trc:

ORA-00313: open failed for members of log group 3 of thread 1

ORA-00312: online log 3 thread 1: '+DATA'

ORA-17503: ksfdopn:2 Failed to open file +DATA

ORA-15045: ASM file name '+DATA' is not in reference form

Mon Jun 01 16:09:54 2015

Setting recovery target incarnation to 3

Mon Jun 01 16:09:54 2015

Assigning activation ID 1317780902 (0x4e8bbda6)

LGWR: STARTING ARCH PROCESSES

Mon Jun 01 16:09:54 2015

ARC0 started with pid=33, OS id=20083

ARC0: Archival started

LGWR: STARTING ARCH PROCESSES COMPLETE

ARC0: STARTING ARCH PROCESSES

Thread 1 opened at log sequence 1

  Current log# 1 seq# 1 mem# 0: +ARCH/orastrac/onlinelog/group_1.350.881251793

Successful open of redo thread 1

MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set

Mon Jun 01 16:09:57 2015

ARC1 started with pid=34, OS id=20087

Mon Jun 01 16:09:57 2015

SMON: enabling cache recovery

Mon Jun 01 16:09:57 2015

ARC2 started with pid=35, OS id=20091

Mon Jun 01 16:09:57 2015

ARC3 started with pid=36, OS id=20095

ARC1: Archival started

ARC2: Archival started

ARC2: Becoming the 'no FAL' ARCH

ARC2: Becoming the 'no SRL' ARCH

ARC1: Becoming the heartbeat ARCH

ARC3: Archival started

ARC0: STARTING ARCH PROCESSES COMPLETE

Mon Jun 01 16:10:03 2015

Successfully onlined Undo Tablespace 2.

Dictionary check beginning

Mon Jun 01 16:10:03 2015

Errors in file /u01/app/oracle/diag/rdbms/orastrac/orastrac/trace/orastrac_dbw0_19220.trc:

ORA-01186: file 201 failed verification tests

ORA-01157: cannot identify/lock data file 201 - see DBWR trace file

ORA-01110: data file 201: '+DATA'

File 201 not verified due to error ORA-01157

Dictionary check complete

Verifying file header compatibility for 11g tablespace encryption..

Verifying 11g file header compatibility for tablespace encryption completed

SMON: enabling tx recovery

Re-creating tempfile +DATA as +DATA/orastrac/tempfile/temp.333.881251803

Database Characterset is ZHS16GBK

No Resource Manager plan active

replication_dependency_tracking turned off (no async multimaster replication found)

Starting background process QMNC

Mon Jun 01 16:10:12 2015

QMNC started with pid=37, OS id=20118

Mon Jun 01 16:10:13 2015

LOGSTDBY: Validating controlfile with logical metadata

LOGSTDBY: Validation complete

Mon Jun 01 16:10:25 2015

Completed: alter database open resetlogs

Mon Jun 01 16:10:26 2015

db_recovery_file_dest_size of 3882 MB is 3.94% used. This is a

user-specified limit on the amount of space that will be used by this

database for recovery-related files, and does not reflect the amount of

space available in the underlying filesystem or ASM diskgroup.

Mon Jun 01 16:10:28 2015

Starting background process CJQ0

Mon Jun 01 16:10:28 2015

CJQ0 started with pid=41, OS id=20162

 

 

此時的資料庫還是單例項的,需要啟用叢集特性來轉換為rac資料庫。

一.3.3.6  啟用叢集特性用於轉換為RAC環境的資料庫

需要修改如下幾類引數:

一、 指定例項引數

 

 

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 16:12:03 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL> col parameter format a50

SQL> set line 9999

SQL>  select * from v$option where parameter = 'Real Application Clusters';

 

PARAMETER                                          VALUE

-------------------------------------------------- ----------------------------------------------------------------

Real Application Clusters                          TRUE

 

SQL> show parameter cluster

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cluster_database                     boolean     FALSE

cluster_database_instances           integer     1

cluster_interconnects                string

SQL>

 

由上述返回結果可知,RAC 特性是支援的,不過尚未啟用叢集資料庫,因此接下來首先要改的,就是 enable CLUSTER DATABASE,操作如下:

 

 

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      +DATA/orastrac/parameterfile/s

                                                 pfile.335.881250575

SQL>  alter system set cluster_database=true scope=spfile;

 

System altered.

 

SQL>

 

SQL> alter system set cluster_database_instances=2 scope=spfile;

 

System altered.

 

SQL>  alter system set instance_number=1 scope=spfile sid='orastrac1';

 

System altered.

 

SQL>  alter system set instance_number=2 scope=spfile sid='orastrac2';

 

System altered.

 

SQL> alter system set thread=1 scope=spfile sid='orastrac1';

 

System altered.

 

SQL> alter system set thread=2 scope=spfile sid='orastrac2';

 

System altered.

 

SQL>

 

 

二、 增加undo

新建一組 UNDO 表空間和執行緒 2 使用的兩組 REDO 檔案:

 

SQL> select * from v$tablespace;

 

       TS# NAME                           INC BIG FLA ENC

---------- ------------------------------ --- --- --- ---

         0 SYSTEM                         YES NO  YES

         1 SYSAUX                         YES NO  YES

         2 UNDOTBS1                       YES NO  YES

         4 USERS                          YES NO  YES

         3 TEMP                           NO  NO  YES

         6 EXAMPLE                        YES NO  YES

 

6 rows selected.

 

SQL>  create undo tablespace undotbs2 datafile '+DATA' SIZE 50m;

 

Tablespace created.

 

SQL> alter system set undo_tablespace='undotbs1' scope=spfile sid='orastrac1';

 

System altered.

 

SQL> alter system set undo_tablespace='undotbs2' scope=spfile sid='orastrac2';

 

System altered.

 

 

 

三、 增加redo

SQL> select * from v$log;

 

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------

         1          1          1   52428800        512          1 NO  CURRENT                1027357 01-JUN-15   2.8147E+14

         2          1          0   52428800        512          1 YES UNUSED                       0                      0

         3          1          0   52428800        512          1 YES UNUSED                       0                      0

 

SQL>  alter database add logfile thread 2 group 4 '+arch' size 50M;

 

Database altered.

 

SQL> alter database add logfile thread 2 group 5 '+arch' size 50M;

 

Database altered.

 

SQL> alter database add logfile thread 2 group 6 '+arch' size 50M;

 

Database altered.

 

SQL> select * from v$log;

 

    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------

         1          1          1   52428800        512          1 NO  CURRENT                1027357 01-JUN-15   2.8147E+14

         2          1          0   52428800        512          1 YES UNUSED                       0                      0

         3          1          0   52428800        512          1 YES UNUSED                       0                      0

         4          2          0   52428800        512          1 YES UNUSED                       0                      0

         5          2          0   52428800        512          1 YES UNUSED                       0                      0

         6          2          0   52428800        512          1 YES UNUSED                       0                      0

 

6 rows selected.

 

SQL> col instance format a8

SQL> select thread#,instance,status,enabled from v$thread;

 

   THREAD# INSTANCE STATUS ENABLED

---------- -------- ------ --------

         1 orastrac OPEN   PUBLIC

         2 UNNAMED_ CLOSED DISABLED

           INSTANCE

           _2

 

 

SQL> alter database enable thread 2 ;

 

Database altered.

 

SQL> select thread#,instance,status,enabled from v$thread;

 

   THREAD# INSTANCE STATUS ENABLED

---------- -------- ------ --------

         1 orastrac OPEN   PUBLIC

         2 UNNAMED_ CLOSED PRIVATE

           INSTANCE

           _2

 

 

SQL>

 

 

 

一.3.3.7  重啟資料庫

重啟資料庫,在每個節點上修改pfile檔案:

一、 節點一

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

[oracle@node1 dbs]$ ORACLE_SID=orastrac1

[oracle@node1 dbs]$ echo "SPFILE='+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575'" > $ORACLE_HOME/dbs/initorastrac1.ora

[oracle@node1 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 16:32:38 2015

 

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

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2213856 bytes

Variable Size             314574880 bytes

Database Buffers           88080384 bytes

Redo Buffers                4325376 bytes

Database mounted.

Database opened.

SQL>

SQL> show parameter cluster

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cluster_database                     boolean     TRUE

cluster_database_instances           integer     2

cluster_interconnects                string

SQL> set line 9999

col HOST_NAME format a10

select INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,ACTIVE_STATE,INSTANCE_ROLE,DATABASE_STATUS from gv$INSTANCE;

 

INSTANCE_NAME    HOST_NAME  VERSION           STARTUP_T STATUS       ACTIVE_ST INSTANCE_ROLE      DATABASE_STATUS

---------------- ---------- ----------------- --------- ------------ --------- ------------------ -----------------

orastrac1        node1      11.2.0.1.0        01-JUN-15 OPEN         NORMAL    PRIMARY_INSTANCE   ACTIVE

 

SQL> select INST_ID,name , open_mode, log_mode,force_logging from gv$database;

 

   INST_ID NAME      OPEN_MODE            LOG_MODE     FOR

---------- --------- -------------------- ------------ ---

         1 ORASTRAC  READ WRITE           ARCHIVELOG   NO

 

SQL>

SQL>  select count(1) FROM LHR.TEST_RAC;

 

  COUNT(1)

----------

     72468

 

SQL>

 

 

 

二、 節點二

[oracle@node1 dbs]$ ORACLE_SID=orastrac2

[oracle@node1 dbs]$ echo "SPFILE='+DATA/ORASTRAC/PARAMETERFILE/spfile.335.881250575'" > $ORACLE_HOME/dbs/initorastrac2.ora

[oracle@node1 dbs]$ sqlplus / as sysdba

[oracle@node2 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 1 17:14:00 2015

 

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

 

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  409194496 bytes

Fixed Size                  2213856 bytes

Variable Size             314574880 bytes

Database Buffers           88080384 bytes

Redo Buffers                4325376 bytes

Database mounted.

Database opened.

 

 

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      +DATA/orastrac/parameterfile/s

                                                 pfile.335.881250575

SQL>

 

SQL> show parameter cluster

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cluster_database                     boolean     TRUE

cluster_database_instances           integer     2

cluster_interconnects                string

SQL> set line 9999

SQL> col HOST_NAME format a10

SQL> select INSTANCE_NAME,HOST_NAME,VERSION,STARTUP_TIME,STATUS,ACTIVE_STATE,INSTANCE_ROLE,DATABASE_STATUS from gv$INSTANCE;

 

INSTANCE_NAME    HOST_NAME  VERSION           STARTUP_T STATUS       ACTIVE_ST INSTANCE_ROLE      DATABASE_STATUS

---------------- ---------- ----------------- --------- ------------ --------- ------------------ -----------------

orastrac1        node1      11.2.0.1.0        01-JUN-15 OPEN         NORMAL    PRIMARY_INSTANCE   ACTIVE

orastrac2        node2      11.2.0.1.0        01-JUN-15 OPEN         NORMAL    PRIMARY_INSTANCE   ACTIVE

 

SQL> select INST_ID,name , open_mode, log_mode,force_logging from gv$database;

 

   INST_ID NAME      OPEN_MODE            LOG_MODE     FOR

---------- --------- -------------------- ------------ ---

         1 ORASTRAC  READ WRITE           ARCHIVELOG   NO

         2 ORASTRAC  READ WRITE           ARCHIVELOG   NO

 

SQL>

SQL>  select count(1) FROM LHR.TEST_RAC;

 

  COUNT(1)

----------

     72468

 

SQL>

 

 

 

 

 

資料已經恢復,下邊把新恢復的資料庫註冊到crs

 

 

 

一.3.3.8  註冊到crs服務

 

[oracle@node2 ~]$ crsstat

Name                           Type                       Target     State      Host      

------------------------------ -------------------------- ---------- ---------  -------  

ora.ARCH.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.DATA.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.LISTENER.lsnr              ora.listener.type          ONLINE     ONLINE     node1    

ora.LISTENER_SCAN1.lsnr        ora.scan_listener.type     ONLINE     ONLINE     node1    

ora.OVDISK.dg                  ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.TEST.dg                    ora.diskgroup.type         ONLINE     ONLINE     node1    

ora.asm                        ora.asm.type               ONLINE     ONLINE     node1    

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.eons                       ora.eons.type              ONLINE     ONLINE     node1    

ora.gsd                        ora.gsd.type               OFFLINE    OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.jmrac.haha.svc             ora.service.type           ONLINE     OFFLINE             

ora.net1.network               ora.network.type           ONLINE     ONLINE     node1    

ora.node1.ASM1.asm             application                ONLINE     ONLINE     node1    

ora.node1.LISTENER_NODE1.lsnr  application                ONLINE     ONLINE     node1    

ora.node1.gsd                  application                OFFLINE    OFFLINE             

ora.node1.ons                  application                ONLINE     ONLINE     node1    

ora.node1.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node1    

ora.node2.ASM2.asm             application                ONLINE     ONLINE     node2    

ora.node2.LISTENER_NODE2.lsnr  application                ONLINE     ONLINE     node2    

ora.node2.gsd                  application                OFFLINE    OFFLINE             

ora.node2.ons                  application                ONLINE     ONLINE     node2    

ora.node2.vip                  ora.cluster_vip_net1.type  ONLINE     ONLINE     node2    

ora.oc4j                       ora.oc4j.type              OFFLINE    OFFLINE             

ora.ons                        ora.ons.type               ONLINE     ONLINE     node1    

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.registry.acfs              ora.registry.acfs.type     ONLINE     ONLINE     node1    

ora.scan1.vip                  ora.scan_vip.type          ONLINE     ONLINE     node1    

[oracle@node2 ~]$ crsstat | grep ora.database.type

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

[oracle@node2 ~]$

[oracle@node2 ~]$ srvctl add database -d orastrac -h

 

Adds a database configuration to the Oracle Clusterware.

 

Usage: srvctl add database -d <db_unique_name> -o <oracle_home> [-m <domain_name>] [-p <spfile>] [-r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}] [-s <start_options>] [-t <stop_options>] [-n <db_name>] [-y {AUTOMATIC | MANUAL}] [-g "<serverpool_list>"] [-x <node_name>] [-a "<diskgroup_list>"]

    -d <db_unique_name>      Unique name for the database

    -o <oracle_home>         ORACLE_HOME path

    -x <node_name>           Node name. -x option is specified for single-instance databases

    -m <domain>              Domain for database. Must be set if database has DB_DOMAIN set.

    -p <spfile>              Server parameter file path

    -r <role>                Role of the database (primary, physical_standby, logical_standby, snapshot_standby)

    -s <start_options>       Startup options for the database. Examples of startup options are open, mount, or nomount.

    -t <stop_options>        Stop options for the database. Examples of shutdown options are normal, transactional, immediate, or abort.

    -n <db_name>        Database name (DB_NAME), if different from the unique name given by the -d option

    -y <dbpolicy>            Management policy for the database (AUTOMATIC or MANUAL)

    -g "<serverpool_list>"    Comma separated list of database server pool names

    -a "<diskgroup_list>"      Comma separated list of disk groups

    -h                       Print usage

[oracle@node2 ~]$ srvctl add database -d orastrac -o $ORACLE_HOME -p +DATA/orastrac/parameterfile/spfile.335.881250575

[oracle@node2 ~]$ srvctl config database -d orastrac

Database unique name: orastrac

Database name:

Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/orastrac/parameterfile/spfile.335.881250575

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: orastrac

Database instances:

Disk Groups:

Services:

Database is administrator managed

[oracle@node2 ~]$ srvctl add instance -d orastrac -i orastrac1 -n node1

[oracle@node2 ~]$ srvctl add instance -d orastrac -i orastrac2 -n node2

[oracle@node2 ~]$ srvctl config database -d orastrac

Database unique name: orastrac

Database name:

Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1

Oracle user: oracle

Spfile: +DATA/orastrac/parameterfile/spfile.335.881250575

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Server pools: orastrac

Database instances: orastrac1,orastrac2

Disk Groups:

Services:

Database is administrator managed

[oracle@node2 ~]$

[oracle@node2 ~]$ crsstat | grep ora.database.type

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.orastrac.db                ora.database.type          OFFLINE    OFFLINE             

[oracle@node2 ~]$

[oracle@node2 ~]$ srvctl status database -d orastrac

Instance orastrac1 is not running on node node1

Instance orastrac2 is not running on node node2

[oracle@node2 ~]$ srvctl start database -d orastrac

[oracle@node2 ~]$ srvctl status database -d orastrac

Instance orastrac1 is running on node node1

Instance orastrac2 is running on node node2

[oracle@node2 ~]$

[oracle@node2 ~]$ crsstat | grep ora.database.type

ora.db.db                      ora.database.type          ONLINE     OFFLINE             

ora.jmrac.db                   ora.database.type          ONLINE     OFFLINE             

ora.ora11g.db                  ora.database.type          OFFLINE    OFFLINE             

ora.orastrac.db                ora.database.type          ONLINE     ONLINE     node1    

[oracle@node2 ~]$

 

 

 

上述 3 條命令分別配置了資料庫和兩個例項,此時 3 項服務剛剛配置完成,crs 中尚未同步其狀態,因此需要執行一下 srvctl start database,然後再透過 crs_stat 即可檢視正確的狀態了

 

 

 

OK,現在已經是叢集的資料庫了,整個恢復工作基本完成。剩下的比如修改監聽、配置網路服務名,建立金鑰檔案等操作相信大家已經熟悉的不能再熟悉,這裡不再演示相關操作了(注意金鑰檔案也是建議建立到共享儲存端,否則的話就得在各個節點分別建立一份)

 

一.3.4  實驗總結

 

單例項的資料庫備份集恢復到rac環境下其實很簡單,和一般的恢復步驟都一樣的,不過在恢復spfilecontrol filedatafile的時候需要放在共享儲存裡邊,另外恢復完成後需要修改一些叢集相關的引數才可以轉換為叢集資料庫。

 

 

一.4  總結

 

到此所有的處理算是基本完畢,過程很簡單,但是不同的場景處理方式有很多種,我們應該學會靈活變通。

 

 

 

一.5  About Me

 

...........................................................................................................................................................................................

本文作者:小麥苗,只專注於資料庫的技術,更注重技術的運用

ITPUB BLOG:http://blog.itpub.net/26736162

本文地址:http://blog.itpub.net/26736162/viewspace-1682250/

本文pdf版:  提取碼:af2d

QQ:642808185 若加QQ請註明你所正在讀的文章標題

創作時間地點:2015-06-01 10:00~ 2015-06-02 12:00 於外匯交易中心

<版權所有,文章允許轉載,但須以連結方式註明源地址,否則追究法律責任!>

...........................................................................................................................................................................................

 

 

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

相關文章