Oracle 11.2.0.4 從單例項,使用RMAN 異機恢復到RAC

梓沐發表於2016-07-14

Oracle 11.2.0.4 從單例項,使用RMAN 異機恢復到RAC

注意:

(1)遷移的2db版本版本要一致。包括小版本。

(2)RMAN 異機恢復的時候,db_name必須相同。 如果說要想改成其他的例項名,可以在恢復成功後,用nid 命令修改。 例項名的資訊會記錄到控制檔案裡,所以如果在恢復的時候,如果例項名不一致,恢復的時候會報錯。

 

--源庫資訊:平臺:Linux 6.5,單例項, 版本如下:

SQL> select * from v$version;

 

BANNER

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

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

PL/SQL Release 11.2.0.4.0 - Production

CORE   11.2.0.4.0 Production

TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production

 

--目標庫:11.2.0.4 RAC,平臺:Linux 6.5,版本如下:

SQL> set lin 160 pages 200

SQL> select * from gv$version;

 

   INST_ID BANNER

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

     1 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

     1 PL/SQL Release 11.2.0.4.0 - Production

     1 CORE 11.2.0.4.0 Production

     1 TNS for Linux: Version 11.2.0.4.0 - Production

     1 NLSRTL Version 11.2.0.4.0 - Production

     2 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

     2 PL/SQL Release 11.2.0.4.0 - Production

     2 CORE 11.2.0.4.0 Production

     2 TNS for Linux: Version 11.2.0.4.0 - Production

     2 NLSRTL Version 11.2.0.4.0 - Production

 

10 rows selected.

 

我的RAC 環境上已經存在了例項orcl,而我們源庫的例項名是:neal。所以恢復完成後會有2個例項。

[root@rac1 ~]# crsctl stat res -t

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

NAME           TARGET  STATE        SERVER                   STATE_DETAILS      

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

Local Resources

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

ora.DATA.dg

               ONLINE  ONLINE       rac1                                         

               ONLINE  ONLINE       rac2                                        

ora.FRA.dg

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                         

ora.LISTENER.lsnr

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

ora.OCRVOTING.dg

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

ora.asm

               ONLINE  ONLINE       rac1                     Started            

               ONLINE  ONLINE       rac2                     Started            

ora.gsd

               OFFLINE OFFLINE      rac1                                        

               OFFLINE OFFLINE      rac2                                        

ora.net1.network

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

ora.ons

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

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

Cluster Resources

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

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       rac1                                        

ora.cvu

      1        ONLINE  ONLINE       rac1                                        

ora.oc4j

      1        ONLINE  ONLINE       rac1                                         

ora.orcl.db

      1        ONLINE  ONLINE       rac1                     Open               

      2        ONLINE  ONLINE       rac2                     Open               

ora.rac1.vip

      1        ONLINE  ONLINE       rac1                                        

ora.rac2.vip

      1        ONLINE  ONLINE       rac2                                        

ora.scan1.vip

      1        ONLINE  ONLINE       rac1      

 

遷移步驟說明

2.1 在源庫用RMAN進行全備

 

源庫例項名:neal,為了確認遷移成功,我們現在源庫上建立一個表test,並插入幾條記錄。

 

SQL> select * from test;

 

     A

----------

     1

     2

     3

     4

 

備份之後的資訊:

RMAN> list backup summary;

 

using target database control file instead of recovery catalog

 

List of Backups

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

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

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

3       B  0  A DISK        12-JUL-16       1       1       NO         NEAL_LV0

5       B  0  A DISK        12-JUL-16       1       1       NO         NEAL_LV0

6       B  0  A DISK        12-JUL-16       1       1       NO         NEAL_LV0

7       B  0  A DISK        12-JUL-16       1       1       NO         NEAL_LV0

9       B  A  A DISK        12-JUL-16       1       1       NO         ARC_BAK

10      B  A  A DISK        12-JUL-16       1       1       NO         ARC_BAK

11      B  F  A DISK        12-JUL-16       1       1       NO         CTLFILE_BAK

12      B  F  A DISK        12-JUL-16       1       1       NO         SPFILE_BAK

 

2.2 將備份檔案SCP RAC 節點1的相同位置。

當然也可以copy到不同位置,但那樣就需要註冊一下,我這裡copy到相同的位置()

[oracle@centos backup]$ scp /home/oracle/backup/* 192.168.8.221:~/backup/

oracle@192.168.8.221's password:

neal_arch_0drah3bo_1_1_20160712                                                                                                                                                  100% 4358KB   4.3MB/s   00:00   

neal_arch_0erah3bo_1_1_20160712                                                                                                                                                  100% 2560     2.5KB/s   00:00   

neal_ctlfile_0frah3bq_1_1_20160712                                                                                                                                               100% 9568KB   9.3MB/s   00:00   

neal_lv0_07rah391_1_1_20160712                                                                                                                                                   100%  634MB  25.4MB/s   00:25   

neal_lv0_08rah391_1_1_20160712                                                                                                                                                   100%  375MB   9.9MB/s   00:38   

neal_lv0_09rah391_1_1_20160712                                                                                                                                                   100% 2912KB   2.8MB/s   00:00   

neal_lv0_0brah399_1_1_20160712                                                                                                                                                   100% 1344KB   1.3MB/s   00:00   

neal_spfile_0grah3bs_1_1_20160712                                                                                                                                                100%   96KB  96.0KB/s   00:00   

 

2.3 還原並修改初始化檔案

2.3.1 還原spfile pfile

 

[oracle@rac1 ~]$ export ORACLE_SID=neal1

[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jul 13 07:05:47 2016

 

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

 

connected to target database (not started)

 

RMAN> startup nomount

 

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

LRM-00109: could not open parameter file '/u01/app/oracle/11.2.0/db_1/dbs/initneal1.ora'

 

starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started

 

Total System Global Area    1068937216 bytes

 

Fixed Size                     2260088 bytes

Variable Size                281019272 bytes

Database Buffers             780140544 bytes

Redo Buffers                   5517312 bytes

 

RMAN> restore spfile to pfile '/u01/app/oracle/11.2.0/db_1/dbs/initneal1.ora' from '/home/oracle/backup/neal_spfile_0grah3bs_1_1_20160712';

 

Starting restore at 2016/07/13 07:07:52

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/backup/neal_spfile_0grah3bs_1_1_20160712

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 2016/07/13 07:07:57

 

2.3.2 檢視ASM 例項的相關目錄資訊

 

[grid@rac1 ~]$ 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     10240     6798                0            6798              0             N  DATA/

MOUNTED  EXTERN  N         512   4096  1048576     10240     9152                0            9152              0             N  FRA/

MOUNTED  NORMAL  N         512   4096  1048576      3072     2146             1024             561              0             Y  OCRVOTING/

 

 

2.3.3 修改初始化引數

注意事項:

(1)RMAN 異機恢復的db_name 必須和備份的一致,如果說想改成其他名稱,可以等還原之後,在用nid 命令修改。

(2)控制檔案需要指定到共享裝置上

(3)檢查audit_file_destbackground_dump_dest core_dump_destlog_archive_dest_1user_dump_dest等引數的位置。 如果2個節點和共享位置沒有對應的目錄,先把目錄建好。

 

--根據initneal1.ora 檔案中的引數建立節點的目錄,在所有節點所有檢查:

 

[oracle@rac1 ~]$ mkdir -p /u01/app/oracle/admin/neal/adump

[oracle@rac2 ~]$ mkdir -p /u01/app/oracle/admin/neal/adump

 

 

--最終我們修改之後的pfile 檔案如下:

 

[oracle@rac1 dbs]$ cat initneal1.ora

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

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_files='+DATA','+FRA'

*.db_block_size=8192

*.db_domain=''

*.db_name='neal'

*.db_recovery_file_dest='+FRA'

*.db_recovery_file_dest_size=4385144832

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

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

*.memory_target=524288000

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_management='AUTO'

*.cluster_database_instances=2

*.cluster_database=false

orcl2.thread=2

orcl1.thread=1

orcl2.undo_tablespace='UNDOTBS2'

orcl1.undo_tablespace='UNDOTBS1'

orcl2.instance_number=2

orcl1.instance_number=1

 

具體記憶體根據實際情況進行調整。

*.cluster_database=false

這裡要先設定為flase,才能進行RMAN 恢復操作。恢復完成在改成true

 

2.3.4 用修改的pfile 來建立spfile,注意放在共享裝置上

--先建立這個目錄結構:

ASMCMD> pwd

+data/NEAL/PARAMETERFILE

 

[oracle@rac1 ~]$ sqlplus / as sysdba

 

SQL> create spfile='+DATA/NEAL/PARAMETERFILE/spfileneal.ora' from pfile='/u01/app/oracle/11.2.0/db_1/dbs/initneal1.ora';

 

File created.

 

--驗證:

ASMCMD> pwd

+data/NEAL/PARAMETERFILE

ASMCMD> ls

spfileneal.ora

 

 

在所有節點上,修改pfile內容,將其指向共享裝置上的spfile

--節點1

[oracle@rac1 ~]# echo "SPFILE='+DATA/NEAL/PARAMETERFILE/spfileneal.ora'" > /u01/app/oracle/11.2.0/db_1/dbs/initneal1.ora

 

--節點2

[oracle@rac2 dbs]$ echo "SPFILE='+DATA/NEAL/PARAMETERFILE/spfileneal.ora'" > /u01/app/oracle/11.2.0/db_1/dbs/initneal2.ora

 

2.4 建立口令檔案

在所有節點執行,注意密碼要和原庫一樣:

[oracle@rac1 ~]# orapwd file=?/dbs/orapwneal1 password=oracle

[oracle@rac2 ~]$ orapwd file=?/dbs/orapwneal2 password=oracle

 

2.5 還原控制檔案

在其中一個節點上執行。

 

2.5.1 spfile,將DB 啟動到nomount 狀態

SQL> shutdown immediate;

ORA-01507: database not mounted

ORACLE instance shut down.

 

SQL> startup nomount

ORACLE instance started.

 

2.5.2 RMAN 執行對控制檔案的恢復

RMAN> restore controlfile from '/home/oracle/backup/neal_ctlfile_0frah3bq_1_1_20160712';

 

Starting restore at 2016/07/13 07:19:49

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1 device type=DISK

 

channel ORA_DISK_1: restoring control file

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

output file name=+DATA/neal/controlfile/current.269.917075991

output file name=+FRA/neal/controlfile/current.285.917075991

Finished restore at 2016/07/13 07:19:51

--這個位置是我們在spfile裡指定的。

 

2.6 restore資料庫

在其中一個節點執行。 我這裡在節點1操作。 個人習慣,相關操作都在節點1進行。

 

2.6.1 將資料庫啟動到MOUNT狀態

RMAN> alter database mount;

 

database mounted

released channel: ORA_DISK_1

 

2.6.2 檢視源庫資料檔案儲存位置資訊

注意一點,我們單例項和RAC 例項儲存資料檔案的位置不同,如果我們使用rman duplicate,那麼我們使用log_file_name_convert  db_file_name_convert來進行轉換,

在這個實驗中,我們使用的是RMAN的異機恢復,所以只能在restore的時候用set newname來進行轉換。

 

在源庫執行如下查詢:

SQL> set linesize 80

SQL> set lin 160 pages 200

SQL> col file_name for a50

SQL> select 'set newname for datafile '||file_id||' to '''||'+DATA'||''';' from dba_data_files;

 

'SETNEWNAMEFORDATAFILE'||FILE_ID||'TO'''||'+DATA'||''';'

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

set newname for datafile 4 to '+DATA';

set newname for datafile 3 to '+DATA';

set newname for datafile 2 to '+DATA';

set newname for datafile 1 to '+DATA';

 

SQL> select 'set newname for tempfile '||file_id||' to '''||'+DATA'||''';' from dba_temp_files;

 

'SETNEWNAMEFORTEMPFILE'||FILE_ID||'TO'''||'+DATA'||''';'

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

set newname for tempfile 1 to '+DATA';

 

2.6.3 RACrestore 資料檔案

指令碼:

run {

set newname for datafile 4 to '+DATA';

set newname for datafile 3 to '+DATA';

set newname for datafile 2 to '+DATA';

set newname for datafile 1 to '+DATA';

set newname for tempfile 1 to '+DATA';

restore database;

switch datafile all;

switch tempfile all;

}

 

注意,對switch的說明:

對於nocatalog 模式下,rman備份的資訊是儲存在控制檔案裡的,包括檔案的路徑資訊。 這裡的switch的作用,就是更新控制檔案裡的資訊。

restore 的時候不會對temp 表空間進行restore。所以等restore 之後,我們需要手工建立temp表空間。

不過在這個測試裡,我們還是對tempfile 進行了指定。 但是這個操作只更新控制檔案,不恢復資料檔案。

RMAN> run {

set newname for datafile 4 to '+DATA';

set newname for datafile 3 to '+DATA';

set newname for datafile 2 to '+DATA';

set newname for datafile 1 to '+DATA';

set newname for tempfile 1 to '+DATA';

restore database;

switch datafile all;

3> switch tempfile all;

4> 5> 6> 7> 8> 9> 10> }

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting restore at 2016/07/13 07:22:44

Starting implicit crosscheck backup at 2016/07/13 07:22:44

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1 device type=DISK

Crosschecked 10 objects

Finished implicit crosscheck backup at 2016/07/13 07:22:46

 

Starting implicit crosscheck copy at 2016/07/13 07:22:46

using channel ORA_DISK_1

Finished implicit crosscheck copy at 2016/07/13 07:22:46

 

searching for all files in the recovery area

cataloging files...

no files cataloged

 

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting datafile backup set restore

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

channel ORA_DISK_1: restoring datafile 00003 to +DATA

channel ORA_DISK_1: reading from backup piece /home/oracle/backup/neal_lv0_09rah391_1_1_20160712

channel ORA_DISK_1: piece handle=/home/oracle/backup/neal_lv0_09rah391_1_1_20160712 tag=NEAL_LV0

channel ORA_DISK_1: restored backup piece 1

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

channel ORA_DISK_1: starting datafile backup set restore

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

channel ORA_DISK_1: restoring datafile 00004 to +DATA

channel ORA_DISK_1: reading from backup piece /home/oracle/backup/neal_lv0_0brah399_1_1_20160712

channel ORA_DISK_1: piece handle=/home/oracle/backup/neal_lv0_0brah399_1_1_20160712 tag=NEAL_LV0

channel ORA_DISK_1: restored backup piece 1

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

channel ORA_DISK_1: starting datafile backup set restore

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

channel ORA_DISK_1: restoring datafile 00002 to +DATA

channel ORA_DISK_1: reading from backup piece /home/oracle/backup/neal_lv0_08rah391_1_1_20160712

channel ORA_DISK_1: piece handle=/home/oracle/backup/neal_lv0_08rah391_1_1_20160712 tag=NEAL_LV0

channel ORA_DISK_1: restored backup piece 1

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

channel ORA_DISK_1: starting datafile backup set restore

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

channel ORA_DISK_1: restoring datafile 00001 to +DATA

channel ORA_DISK_1: reading from backup piece /home/oracle/backup/neal_lv0_07rah391_1_1_20160712

channel ORA_DISK_1: piece handle=/home/oracle/backup/neal_lv0_07rah391_1_1_20160712 tag=NEAL_LV0

channel ORA_DISK_1: restored backup piece 1

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

Finished restore at 2016/07/13 07:25:03

 

datafile 1 switched to datafile copy

input datafile copy RECID=5 STAMP=917076307 file name=+DATA/neal/datafile/system.273.917076249

datafile 2 switched to datafile copy

input datafile copy RECID=6 STAMP=917076307 file name=+DATA/neal/datafile/sysaux.272.917076175

datafile 3 switched to datafile copy

input datafile copy RECID=7 STAMP=917076309 file name=+DATA/neal/datafile/undotbs1.270.917076169

datafile 4 switched to datafile copy

input datafile copy RECID=8 STAMP=917076309 file name=+DATA/neal/datafile/users.271.917076171

 

renamed tempfile 1 to +DATA in control file

 

2.7 recover 資料庫

在執行restore的節點執行,因為備份檔案在該節點上。

 

RMAN> recover database;

 

Starting recover at 2016/07/13 07:25:28

using channel ORA_DISK_1

 

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=6

channel ORA_DISK_1: reading from backup piece /home/oracle/backup/neal_arch_0drah3bo_1_1_20160712

channel ORA_DISK_1: piece handle=/home/oracle/backup/neal_arch_0drah3bo_1_1_20160712 tag=ARC_BAK

channel ORA_DISK_1: restored backup piece 1

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

archived log file name=+FRA/neal/archivelog/2016_07_13/thread_1_seq_6.286.917076331 thread=1 sequence=6

channel default: deleting archived log(s)

archived log file name=+FRA/neal/archivelog/2016_07_13/thread_1_seq_6.286.917076331 RECID=3 STAMP=917076331

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=7

channel ORA_DISK_1: reading from backup piece /home/oracle/backup/neal_arch_0erah3bo_1_1_20160712

channel ORA_DISK_1: piece handle=/home/oracle/backup/neal_arch_0erah3bo_1_1_20160712 tag=ARC_BAK

channel ORA_DISK_1: restored backup piece 1

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

archived log file name=+FRA/neal/archivelog/2016_07_13/thread_1_seq_7.286.917076333 thread=1 sequence=7

channel default: deleting archived log(s)

archived log file name=+FRA/neal/archivelog/2016_07_13/thread_1_seq_7.286.917076333 RECID=4 STAMP=917076332

unable to find archived log

archived log thread=1 sequence=8

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 07/13/2016 07:25:40

RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 8 and starting SCN of 1007315

 

這裡是提醒恢復到一個未知的scn號。 因為這部分SCN 還在online redo裡,可以在alter database mount之後,透過set until scn或者set until time命令設定恢復到的scn號或時間,

或者把源庫的這些檔案在copy過來,在應用一下。就可以避免這個錯誤。

 

2.8 最重要一步:將源庫剩下的歸檔和online redo copy過來進行recover

 

在資料量大的時候,用RMAN進行資料遷移,能夠降低切換的時間。即先用之前的備份進行恢復,然後把剩下的歸檔copy過來,進行recover

這裡對業務的影響,僅僅是最後小部分歸檔的處理,資料庫可能很大,但最後決定我們停機時間的,就是最後一部分歸檔的處理。

 

2.8.1 在源庫建立一張表,然後把資料庫例項停掉

SQL> alter system switch logfile;

 

System altered.

 

SQL> /

 

System altered.

 

SQL> create table sun(id number,name varchar2(100));

 

Table created.

 

SQL> insert into sun values(1,'sun');

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

--關閉資料庫,保證資料一致性:

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

 

2.8.2 將剩下的歸檔和online redo 全部copyRAC 的備份目錄下

[oracle@centos 2016_07_12]$ scp /u01/oracle/fast_recovery_area/NEAL/archivelog/2016_07_12/* 192.168.8.221:~/backup/

oracle@192.168.8.221's password:

o1_mf_1_8_cr9vhr6q_.arc                                                                                                                                                          100%   12MB  11.7MB/s   00:00   

 

[oracle@centos 2016_07_13]$ scp /u01/oracle/fast_recovery_area/NEAL/archivelog/2016_07_13/* 192.168.8.221:~/backup/

oracle@192.168.8.221's password:

o1_mf_1_10_crc2ss6g_.arc                                                                                                                                                         100%  109KB 109.0KB/s   00:00   

o1_mf_1_11_crc2ssy6_.arc                                                                                                                                                         100% 1024     1.0KB/s   00:00   

o1_mf_1_9_crc2h7j2_.arc                                                                                                                                                          100%   55KB  55.0KB/s   00:00

 

[oracle@centos neal]$ scp /u01/oracle/oradata/neal/redo0*.log 192.168.8.221:~/backup/

oracle@192.168.8.221's password:

redo01.log                                                                                                                                                                       100%   50MB  16.7MB/s   00:03   

redo02.log                                                                                                                                                                       100%   50MB  50.0MB/s   00:01   

redo03.log                                                                                                                                                                       100%   50MB  12.5MB/s   00:04       

 

2.8.3重新註冊歸檔檔案和online redo log,並同步資料

2.8.3.1 註冊歸檔檔案

如果有歸檔,我們需要從單機複製到RAC 節點上,但RAC節點的資料庫並沒有相關記錄。所以我們需要先將歸檔檔案註冊到控制檔案裡。 然後才能使用。

RMAN> catalog archivelog '/home/oracle/backup/o1_mf_1_8_cr9vhr6q_.arc','/home/oracle/backup/o1_mf_1_10_crc2ss6g_.arc','/home/oracle/backup/o1_mf_1_11_crc2ssy6_.arc','/home/oracle/backup/o1_mf_1_9_crc2h7j2_.arc';

 

cataloged archived log

archived log file name=/home/oracle/backup/o1_mf_1_8_cr9vhr6q_.arc RECID=8 STAMP=917077069

cataloged archived log

archived log file name=/home/oracle/backup/o1_mf_1_10_crc2ss6g_.arc RECID=5 STAMP=917076646

cataloged archived log

archived log file name=/home/oracle/backup/o1_mf_1_11_crc2ssy6_.arc RECID=6 STAMP=917076646

cataloged archived log

archived log file name=/home/oracle/backup/o1_mf_1_9_crc2h7j2_.arc RECID=7 STAMP=917076646

 

2.8.3.2 移動online redo log到對應位置

--現在單例項進行查詢:

SQL> select member from v$logfile;

 

MEMBER

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

/u01/oracle/oradata/neal/redo03.log

/u01/oracle/oradata/neal/redo02.log

/u01/oracle/oradata/neal/redo01.log

 

RAC上把online redo log日誌放入到對應的位置(目錄位置必須還原來單例項目錄一致):

[oracle@rac1 ~]$ mkdir -p /u01/oracle/oradata/neal/

[oracle@rac1 ~]$ mv /home/oracle/backup/redo*.log /u01/oracle/oradata/neal/

 

--再次執行recover 操作:

 

RMAN> recover database;

 

Starting recover at 2016/07/13 07:37:50

using channel ORA_DISK_1

 

starting media recovery

 

archived log for thread 1 with sequence 8 is already on disk as file /home/oracle/backup/o1_mf_1_8_cr9vhr6q_.arc

archived log for thread 1 with sequence 9 is already on disk as file /home/oracle/backup/o1_mf_1_9_crc2h7j2_.arc

archived log for thread 1 with sequence 10 is already on disk as file /home/oracle/backup/o1_mf_1_10_crc2ss6g_.arc

archived log for thread 1 with sequence 11 is already on disk as file /home/oracle/backup/o1_mf_1_11_crc2ssy6_.arc

archived log file name=/home/oracle/backup/o1_mf_1_8_cr9vhr6q_.arc thread=1 sequence=8

archived log file name=/home/oracle/backup/o1_mf_1_9_crc2h7j2_.arc thread=1 sequence=9

archived log file name=/home/oracle/backup/o1_mf_1_10_crc2ss6g_.arc thread=1 sequence=10

archived log file name=/home/oracle/backup/o1_mf_1_11_crc2ssy6_.arc thread=1 sequence=11

archived log for thread 1 with sequence 12 is already on disk as file /u01/oracle/oradata/neal/redo03.log

archived log file name=/u01/oracle/oradata/neal/redo03.log thread=1 sequence=12

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

Finished recover at 2016/07/13 07:44:27

 

--注意:這次我們是第二次進行recover database,這裡會我們copy過來的日誌全部應用了,並且,注意這裡是完全恢復,也就說這裡沒有資料丟失,我們不需要用open resetlogs來開啟資料庫。

 

 

--重置歸檔位置:

[oracle@rac1 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 13 07:45:02 2016

 

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

 

 

Connected to:

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

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

Data Mining and Real Application Testing options

 

SQL> alter system set log_archive_dest_1='LOCATION=+FRA' SID='*';

 

System altered.

 

2.9 處理online redo

--原來的redo存放位置:

 

SQL> select * from v$logfile;

 

    GROUP# STATUS  TYPE    MEMBER

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

          3          ONLINE /u01/oracle/oradata/neal/redo03.log                

        2            ONLINE /u01/oracle/oradata/neal/redo02.log                 

          1          ONLINE /u01/oracle/oradata/neal/redo01.log

         

RACredo是需要存放在共享裝置上的,所以我們這裡需要進行一些轉換操作。

 

SQL> alter database rename file '/u01/oracle/oradata/neal/redo01.log' to '+DATA';

 

Database altered.

 

SQL> alter database rename file '/u01/oracle/oradata/neal/redo02.log' to '+DATA';

 

Database altered.

 

SQL> alter database rename file '/u01/oracle/oradata/neal/redo03.log' to '+DATA';

 

Database altered.

我們這裡只是更改了online redo的記錄,實際上檔案並沒有生成,當我們open db的時候,會自動建立online redo log。
 

2.10 open resetlogs 開啟DB

雖然我們前面做的是完全恢復,確保沒有資料丟失, 但我們的需要用resetlogs來開啟資料庫,來重建我們的online redo log

 

SQL> alter database open resetlogs;

Database altered.

 

2.11 檢查並修改幾個初始化引數

 

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> show parameter thread

 

NAME                   TYPE  VALUE

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

parallel_threads_per_cpu      integer   2

thread                 integer   0

 

SQL> show parameter instance_number

 

NAME                   TYPE  VALUE

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

instance_number           integer   0

 

SQL> alter system set cluster_database=true scope=spfile sid='*';

 

System altered.

 

SQL> alter system set cluster_database_instances=2 scope=spfile sid='*';

 

System altered.

 

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

 

System altered.

 

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

 

System altered.

 

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

 

System altered.

 

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

 

System altered.

 

2.12 建立節點2undo 表空間

 

SQL> show parameter undo_tablespace

 

NAME                   TYPE  VALUE

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

undo_tablespace           string UNDOTBS1

SQL> create undo tablespace UNDOTBS2 datafile '+DATA' size 100m;

 

Tablespace created.

 

SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='neal2';

 

System altered.

 

2.13 新增rac2 節點的redo 檔案

rac redo 是接其他節點來的,我們之前的rac1上已經有3組,所以我們這裡從4開始,在新增2組給rac2,使用thread 2.

SQL> alter database add logfile thread 2 group 4 '+DATA' size 50m;

 

Database altered.

 

SQL> alter database add logfile thread 2 group 5 '+DATA' size 50m;

 

Database altered.

 

SQL> alter database add logfile thread 2 group 6 '+DATA' size 50m;

 

Database altered.

 

SQL> alter database enable thread 2;

 

Database altered.

 

2.14 將其他資訊註冊到CRS

--一定要用oracle 來執行

[oracle@rac1 ~]$ srvctl add database -d neal -o $ORACLE_HOME -p +DATA/NEAL/PARAMETERFILE/spfileneal.ora

[oracle@rac1 ~]$ srvctl add instance -d neal -i neal1 -n rac1

[oracle@rac1 ~]$ srvctl add instance -d neal -i neal2 -n rac2

 

2.15 重啟節點1和節點上的例項,使相關引數生效

我們之前都只啟動了一個例項1,所以這裡重啟例項1,在啟動例項2

[oracle@rac1 ~]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 13 07:52:23 2016

 

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

 

 

Connected to:

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

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

Data Mining and Real Application Testing options

 

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  521936896 bytes

Fixed Size        2254824 bytes

Variable Size       419432472 bytes

Database Buffers     96468992 bytes

Redo Buffers          3780608 bytes

Database mounted.

Database opened.

 

[oracle@rac2 dbs]$ export ORACLE_SID=neal2

[oracle@rac2 dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jul 13 07:53:10 2016

 

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

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  521936896 bytes

Fixed Size        2254824 bytes

Variable Size       423626776 bytes

Database Buffers     92274688 bytes

Redo Buffers          3780608 bytes

Database mounted.

Database opened.

 

2.16 執行catclust.sql指令碼來建立相關檢視

執行$ORACLE_HOME/rdbms/admin/catclust.sql指令碼,建立cluster database的相關檢視。

SQL>@$ORACLE_HOME/rdbms/admin/catclust.sql

 

2.17 重建Temp 表空間

因為在restore 的時候不會對temp 表空間進行restore。所以等restore 之後,我們需要手工建立temp表空間。

不過在11g ASM ,查到了這個檔案。

 

[grid@rac1 ~]$ asmcmd lsof |grep temp

neal     neal1          +data/neal/tempfile/temp.274.917077561       

orcl     orcl1          +data/orcl/tempfile/temp.263.917074137 

 

2.18 新增叢集的監聽

grid使用者連線,在其中一個節點上用netca 配置一下。

 

2.19 驗證

[root@rac1 ~]# crsctl stat res -t

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

NAME           TARGET  STATE        SERVER                   STATE_DETAILS      

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

Local Resources

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

ora.DATA.dg

               ONLINE  ONLINE       rac1                                         

               ONLINE  ONLINE       rac2                                        

ora.FRA.dg

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                         

ora.LISTENER.lsnr

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

ora.OCRVOTING.dg

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

ora.asm

               ONLINE  ONLINE       rac1                     Started            

               ONLINE  ONLINE       rac2                     Started            

ora.gsd

               OFFLINE OFFLINE      rac1                                        

               OFFLINE OFFLINE      rac2                                        

ora.net1.network

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

ora.ons

               ONLINE  ONLINE       rac1                                        

               ONLINE  ONLINE       rac2                                        

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

Cluster Resources

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

ora.LISTENER_SCAN1.lsnr

      1        ONLINE  ONLINE       rac1                                        

ora.cvu

      1        ONLINE  ONLINE       rac1                                        

ora.neal.db

      1        ONLINE  ONLINE       rac1                     Open               

      2        ONLINE  ONLINE       rac2                     Open               

ora.oc4j

      1        ONLINE  ONLINE       rac1                                        

ora.orcl.db

      1        ONLINE  ONLINE       rac1                     Open               

      2        ONLINE  ONLINE       rac2                     Open               

ora.rac1.vip

      1        ONLINE  ONLINE       rac1                                        

ora.rac2.vip

      1        ONLINE  ONLINE       rac2                                        

ora.scan1.vip

      1        ONLINE  ONLINE       rac1    

 

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

相關文章