恢復RAC資料庫到單例項(ASM)

liglewang發表於2011-09-15

源端為10.2.0.4RAC+ASM,現透過熱備並應用歸檔日誌的方式將資料庫恢復到相同版本的單例項上,單機也同樣採用ASM方式。

單機環境為:ORACLE 10.2.0.4 , ASM

1、 將從生產機上ftp過來的pfile.ora檔案進行修改,主要去掉和叢集相關的一些引數:
引數檔案修改後如下:

#racdb2.__db_cache_size=13287555072
#racdb1.__db_cache_size=5033164800
#racdb2.__java_pool_size=16777216
#racdb1.__java_pool_size=16777216
#racdb2.__large_pool_size=33554432
#racdb1.__large_pool_size=83886080
#racdb2.__shared_pool_size=1325400064
#racdb1.__shared_pool_size=3439329280
#racdb2.__streams_pool_size=0
#racdb1.__streams_pool_size=0
#*.cluster_database_instances=2
#*.cluster_database=true
#racdb2.cursor_sharing='FORCE'
#racdb1.instance_number=1
#racdb2.instance_number=2
#racdb2.local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.11.53 ) ( port =1521 ))'
#racdb2.sga_max_size=16777216000#internally adjusted
#racdb2.sga_target=14680064000
#racdb2.thread=2
#racdb1.thread=1
#racdb2.undo_tablespace='UNDOTBS2'
#*.remote_listener='LISTENERS_RACDB'
#*.lock_sga=TRUE
*.audit_file_dest='/oranm01/app/oracle/admin/racdb/adump'
*.background_dump_dest='/oranm01/app/oracle/admin/racdb/bdump'
*.compatible='10.2.0.3.0'
*.control_files='+DATA/racdb/controlfile/current.290.692567429','+FLASH/racdb/controlfile/current.718.692567431'
*.core_dump_dest='/oranm01/app/oracle/admin/racdb/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_flashback_retention_target=120
*.db_name='racdb'
*.db_recovery_file_dest='+FLASH'
*.db_recovery_file_dest_size=375809638400
*.dispatchers='(PROTOCOL=TCP) (SERVICE=racdbXDB)'
*.job_queue_processes=10
racdb.local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.11.83 ) ( port = 1521))'
*.nls_territory='CHINA'
*.open_cursors=600
*.pga_aggregate_target=4847566848
*.processes=1000
*.remote_login_passwordfile='exclusive'
racdb.sga_max_size=12884901888#internally adjusted
*.sga_target=1610612736
racdb.sga_target=8589934592
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oranm01/app/oracle/admin/racdb/udump'
#racdb2.__db_cache_size=13287555072
#racdb1.__db_cache_size=5033164800
#racdb2.__java_pool_size=16777216
#racdb1.__java_pool_size=16777216
#racdb2.__large_pool_size=33554432
#racdb1.__large_pool_size=83886080
#racdb2.__shared_pool_size=1325400064
#racdb1.__shared_pool_size=3439329280
#racdb2.__streams_pool_size=0
#racdb1.__streams_pool_size=0
#*.cluster_database_instances=2
#*.cluster_database=true
#racdb2.cursor_sharing='FORCE'
#racdb1.instance_number=1
#racdb2.instance_number=2
#racdb2.local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.11.53 ) ( port =1521 ))'
#racdb2.sga_max_size=16777216000#internally adjusted
#racdb2.sga_target=14680064000
#racdb2.thread=2
#racdb1.thread=1
#racdb2.undo_tablespace='UNDOTBS2'
#*.remote_listener='LISTENERS_RACDB'
#*.lock_sga=TRUE
*.audit_file_dest='/oranm01/app/oracle/admin/racdb/adump'
*.background_dump_dest='/oranm01/app/oracle/admin/racdb/bdump'
*.compatible='10.2.0.3.0'
*.control_files='+DATA/racdb/controlfile/current.290.692567429','+FLASH/racdb/controlfile/current.718.692567431'
*.core_dump_dest='/oranm01/app/oracle/admin/racdb/cdump'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_flashback_retention_target=120
*.db_name='racdb'
*.db_recovery_file_dest='+FLASH'
*.db_recovery_file_dest_size=375809638400
*.dispatchers='(PROTOCOL=TCP) (SERVICE=racdbXDB)'
*.job_queue_processes=10
racdb.local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.11.83 ) ( port = 1521))'
*.nls_territory='CHINA'
*.open_cursors=600
*.pga_aggregate_target=4847566848
*.processes=1000
*.remote_login_passwordfile='exclusive'
racdb.sga_max_size=12884901888#internally adjusted
*.sga_target=1610612736
racdb.sga_target=8589934592
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oranm01/app/oracle/admin/racdb/udump'

2、 pfile檔案轉換成spfile

P750_25:oracle:/home/oracle>sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.4.0 - Production on Wed Sep 14 13:25:45 2011
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Connected to an idle instance.

SQL> create spfile from pfile='/home/oracle/pfile.ora';

File created.

3、 NOMOUNT資料庫

SQL> alter database nomount;

4、 恢復控制檔案

RMAN> restore controlfile from '/cb_backup/ctl_201109131913.ctl';

5、 MOUNT資料庫

RMAN> sql 'alter database mount';

6、 重新指定線上聯機日誌檔案(SQLPLUS下執行)

alter database rename file '+DATA/racdb/onlinelog/group_1.259.727912683' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_1.720.727912685' to '+FLASH';
alter database rename file '+DATA/racdb/onlinelog/group_2.261.727912333' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_2.719.727912335' to '+FLASH';
alter database rename file '+DATA/racdb/onlinelog/group_3.289.727912713' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_3.722.727912713' to '+FLASH';
alter database rename file '+DATA/racdb/onlinelog/group_4.292.727912375' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_4.721.727912377' to '+FLASH';
alter database rename file '+DATA/racdb/onlinelog/group_5.309.727911829' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_5.2794.727911827' to '+FLASH';
alter database rename file '+DATA/racdb/onlinelog/group_6.310.727912035' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_6.2515.727912037' to '+FLASH';
alter database rename file '+DATA/racdb/onlinelog/group_7.311.727912117' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_7.1112.727912117' to '+FLASH';
alter database rename file '+DATA/racdb/onlinelog/group_8.312.727912163' to '+DATA';
alter database rename file '+FLASH/racdb/onlinelog/group_8.2592.727912165' to '+FLASH';

7、 在待恢復資料庫上對從源庫FTP過來的備份集進行註冊(RMAN下執行)

catalog backuppiece '/cb_backup/rvmmfdj2_1_1_7039.bak';
catalog backuppiece '/cb_backup/s0mmfdj2_1_1_7040.bak';
catalog backuppiece '/cb_backup/s1mmfdm3_1_1_7041.bak';
catalog backuppiece '/cb_backup/s2mmfdml_10_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_11_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_12_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_13_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_14_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_1_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_2_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_3_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_4_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_5_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_6_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_7_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_8_1_7042.bak';
catalog backuppiece '/cb_backup/s2mmfdml_9_1_7042.bak';
catalog backuppiece '/cb_backup/s3mmfdml_10_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_11_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_12_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_13_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_14_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_15_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_16_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_17_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_1_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_2_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_3_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_4_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_5_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_6_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_7_1_7043.bak';
atalog backuppiece '/cb_backup/s3mmfdml_8_1_7043.bak';
catalog backuppiece '/cb_backup/s3mmfdml_9_1_7043.bak';
catalog backuppiece '/cb_backup/s4mmfkbu_1_1_7044.bak';
catalog backuppiece '/cb_backup/s5mmfkbu_1_1_7045.bak';

 

8、 修復資料庫

RMAN> run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
restore database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

9、 FTP源庫上的歸檔檔案至目標主機上

a)     在源庫上,歸檔檔案存放在ASM上,因此首先需要將歸檔檔案複製到本地檔案系統上:
SQL> create or replace directory ARCH_DIR as '+flash/racdb/archivelog/2011_09_13';

b)     SQL> create or replace directory ARCL_DEST as '/xdbackup/cityb';

c)     SQL> BEGIN
SQL> dbms_file_transfer.copy_file(
SQL> source_directory_object =>'ARCH_DIR',
SQL> source_file_name => '
thread_2_seq_38337.1435.761786245',
SQL> destination_directory_object => 'ARCL_DEST',
SQL> destination_file_name => '
thread_2_seq_38337.1435.761786245');
SQL> END;
SQL> /

d)     把需要的歸檔檔案都copy下來後,FTP到目標主機

10、         註冊歸檔檔案

SQL> catalog archivelog '/cb_backup/arch/thread_1_seq_68228.2464.761783913';
SQL> catalog archivelog '/cb_backup/arch/thread_1_seq_68229.976.761783957';
SQL> catalog archivelog '/cb_backup/arch/thread_1_seq_68230.1125.761784003';
SQL> catalog archivelog '/cb_backup/arch/thread_1_seq_68231.2838.761784049';
SQL> catalog archivelog '/cb_backup/arch/thread_1_seq_68232.2717.761784099';
………………………………………

11、         恢復資料庫

RMAN> recover database;

12、         開啟資料庫

SQL> alter database open resetlogs;

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

相關文章