【資料遷移1】Oracle 10gR2 rman異機恢復實驗(FS->RAW)(1)

liuyingfei755發表於2018-06-02

【資料遷移1】Oracle 10gR2 rman異機恢復實驗(FS->RAW)(1)

轉載請註明原文:http://xunzhaoxz.itpub.net/post/40016/521239

PDF版詳細恢復步驟(截圖)

【資料遷移2】Oracle 10gR2 rman異機恢復實驗(FS-FS)(截圖)

環境說明

Oracle源主機

Oracle目標主機

主機平臺

RHEL5.4 2.6.18-164.el5

RHEL5.4 2.6.18-164.el5

主機名

olddbser

newdbser

DB name

oradb

oradb

例項名

oradb

oradb

Oracle版本

10.2.0.1

10.2.0.1>10.2.0.4

Oracle資料檔案儲存

Filesystem

LVM RAW LV

單機或RAC

單機

單機

[@more@]

二、 前期準備

2.1. 資訊採集

sys使用者登入源庫oradb,執行以下命令收集相關資訊。

2.1.1. 檢視引數檔案

SQL> show parameter spfile;

NAME TYPE VALUE

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

spfile string /oracle/product/10.2/db_1/dbs/

spfileoradb.ora

SQL>

2.1.2. cat 引數檔案

[oracle@Oradb1 ~]$ cat /oracle/product/10.2/db_1/dbs/spfileoradb.ora

[1][1]??oradb.__db_cache_size=75497472

oradb.__java_pool_size=4194304

oradb.__large_pool_size=4194304

oradb.__shared_pool_size=75497472

oradb.__streams_pool_size=0

*.audit_file_dest='/oracle/admin/oradb/adump'

*.background_dump_dest='/oracle/admin/oradb/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/oracle/oradata/ORADB/controlfile/o1_mf_6ccmcxjq_.ctl'

*.core_dump_dest='/oracle/admin/oradb/cdump'

*.db_block_size=8192

*.db_create_file_dest='/oracle/oradata'

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='oradb'

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

*.job_queue_processes=10

*.log_archive_dest_1='LOCATION=/oracle/oradata/oradb/archivelog'

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

*.nls_language='SIMPLIFIED CHINESE'

*.nls_territory='CHINA'

*.open_cursors=300

*.pga_aggregate_target=16777216

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=167772160

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/oracle/admin/oradb/udump'

[oracle@Oradb1 ~]$

2.1.3. 檢視redo log

SQL> set linesize 250

SQL> col member format a60

SQL> select group#,status,type, member from v$logfile;

GROUP# STATUS TYPE MEMBER

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

3 ONLINE /oracle/oradata/ORADB/onlinelog/o1_mf_3_6ccmd4s8_.log

2 ONLINE /oracle/oradata/ORADB/onlinelog/o1_mf_2_6ccmd34r_.log

1 ONLINE /oracle/oradata/ORADB/onlinelog/o1_mf_1_6ccmd1ns_.log

SQL>

2.1.4. 檢視資料檔案

SQL> col name format a65

SQL> select file#,name,bytes/1024/1024 MB from v$datafile;

2.1.5. 檢視控制檔案

SQL> col name format a66

SQL> select name from v$controlfile;

NAME

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

/oracle/oradata/ORADB/controlfile/o1_mf_6ccmcxjq_.ctl

SQL>

2.1.6. strings控制檔案

[oracle@Oradb1 ~]$ strings /oracle/oradata/ORADB/controlfile/o1_mf_6ccmcxjq_.ctl

}|{z

ORADB

+ORADB

+ORADB

oradb

oradb

/oracle/oradata/ORADB/onlinelog/o1_mf_3_6ccmd4s8_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_2_6ccmd34r_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_1_6ccmd1ns_.log

/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_temp_6ccmdhv3_.tmp

/oracle/oradata/autobackup/snapcf_rman.f

/oracle/oradata/ORADB/onlinelog/o1_mf_3_6ccmd4s8_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_2_6ccmd34r_.log

/oracle/oradata/ORADB/onlinelog/o1_mf_1_6ccmd1ns_.log

/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf

/oracle/oradata/ORADB/datafile/o1_mf_temp_6ccmdhv3_.tmp

/oracle/oradata/autobackup/snapcf_rman.f

SYSTEM

UNDOTBS1

SYSAUX

USERS

TEMP

SYSTEM

UNDOTBS1

SYSAUX

USERS

TEMP

CONTROLFILE AUTOBACKUP

CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE

DISK TO '/oracle/oradata/autobackup/oradb-cf-%F.dbf'

CHANNEL

DEVICE TYPE DISK FORMAT '/oracle/oradata/backupset/oradb-bs-%T-%U.dbf'

RETENTION POLICY

TO RECOVERY WINDOW OF 2 DAYS

CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE

DISK TO '/oracle/oradata/autobackup/oradb-cf-%F.dbf'

CHANNEL

DEVICE TYPE DISK FORMAT '/oracle/oradata/backupset/oradb-bs-%T-%U.dbf'

RETENTION POLICY

TO RECOVERY WINDOW OF 2 DAYS

oracle/oradata/oradb/archivelog/1_2_732323841.dbf

oracle/oradata/oradb/archivelog/1_3_732323841.dbf

oracle/oradata/oradb/archivelog/1_4_732323841.dbf

oracle/oradata/oradb/archivelog/1_5_732323841.dbf

oracle/oradata/oradb/archivelog/1_6_732323841.dbf

oracle/oradata/oradb/archivelog/1_7_732323841.dbf

……………………………………

……………………………………

2.1.7. 檢視當前歸檔模式、歸檔路徑

SQL> set linesize 120

SQL> col error format a10

SQL> col dest_name format a20

SQL> col destination format a50

SQL> col status format a14

SQL> select dest_name,destination,status,error from v$archive_dest;

2.1.8. 檢視當前rman配置策略

RMAN> show all;

RMAN configuration parameters are:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1000 DAYS;

CONFIGURE BACKUP OPTIMIZATION OFF; # default

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oracle/oradata/autobackup/oradb-cf-%F.dbf';

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle/oradata/backupset/oradb-bs-%T-%U.dbf';

CONFIGURE MAXSETSIZE TO UNLIMITED; # default

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default

CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/product/10.2/db_1/dbs/snapcf_oradb.f'; # default

RMAN>

2.2. 資料備份

2.2.1. 手工建立pfile以備用

SQL> create pfile='/oracle/oradb-pfile-201011111134.ora' from spfile;

File created.

SQL>

[oracle@Oradb1 ~]$ ls -l /oracle/oradb-pfile*

-rw-r--r-- 1 oracle oinstall 990 Nov 11 11:28 /oracle/oradb-pfile-201011111134.ora

[oracle@Oradb1 ~]$

2.2.2. rman啟用控制檔案自動備份

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

old RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP OFF;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored

RMAN>

2.2.3. 切換logfile

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

RMAN> sql 'ALTER SYSTEM SWITCH LOGFILE';

2.2.4. 備份資料庫

備份生成的備份集為 /oracle/ oradb-20101114-1jlt0ptg_1_1.rman,同時控制檔案和引數檔案也自動備份為/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-00.dbf

RMAN> backup database format '/oracle/oradb-%T-%U.rman';

Starting backup at 2010-11-14 20:25:19

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=136 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf

input datafile fno=00003 name=/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf

input datafile fno=00002 name=/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf

input datafile fno=00004 name=/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf

channel ORA_DISK_1: starting piece 1 at 2010-11-14 20:25:20

channel ORA_DISK_1: finished piece 1 at 2010-11-14 20:26:25

piece handle=/oracle/oradb-20101114-1jlt0ptg_1_1.rman tag=TAG20101114T202520 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05

Finished backup at 2010-11-14 20:26:26

Starting Control File and SPFILE Autobackup at 2010-11-14 20:26:26

piece handle=/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-00.dbf comment=NONE

Finished Control File and SPFILE Autobackup at 2010-11-14 20:26:27

RMAN>

2.2.5. 備份歸檔日誌並刪除

備份歸檔日誌生成的備份集為/oracle/oradb-20101114-1jlt0ptg_1_1.rman,同時控制檔案和引數檔案也自動備份到/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-01.dbf

注意:這裡自動備份得到的控制檔案是最新的,本環境rman採用的是nocatalog模式,因此該控制檔案備份集中記錄了歸檔日誌檔案的相關資訊,進行資料恢復需要用到。

RMAN> backup archivelog all delete input format '/oracle/oradb-archlogall-%T-%U.rman';

Starting backup at 2010-11-14 20:28:04

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log backupset

channel ORA_DISK_1: specifying archive log(s) in backup set

input archive log thread=1 sequence=21 recid=20 stamp=734574755

input archive log thread=1 sequence=22 recid=22 stamp=734579607

input archive log thread=1 sequence=23 recid=21 stamp=734579603

input archive log thread=1 sequence=24 recid=23 stamp=734579611

input archive log thread=1 sequence=25 recid=24 stamp=734579612

input archive log thread=1 sequence=26 recid=25 stamp=734579622

input archive log thread=1 sequence=27 recid=26 stamp=735064060

input archive log thread=1 sequence=28 recid=27 stamp=735077844

input archive log thread=1 sequence=29 recid=28 stamp=735077845

input archive log thread=1 sequence=30 recid=30 stamp=735077854

input archive log thread=1 sequence=31 recid=29 stamp=735077854

input archive log thread=1 sequence=32 recid=31 stamp=735077873

input archive log thread=1 sequence=33 recid=32 stamp=735077875

input archive log thread=1 sequence=34 recid=33 stamp=735077877

input archive log thread=1 sequence=35 recid=34 stamp=735077888

input archive log thread=1 sequence=36 recid=35 stamp=735078484

channel ORA_DISK_1: starting piece 1 at 2010-11-14 20:28:07

channel ORA_DISK_1: finished piece 1 at 2010-11-14 20:28:14

piece handle=/oracle/oradb-archlogall-20101114-1llt0q2m_1_1.rman tag=TAG20101114T202804 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08

channel ORA_DISK_1: deleting archive log(s)

archive log filename=/oracle/oradata/oradb/archivelog/1_21_732323841.dbf recid=20 stamp=734574755

archive log filename=/oracle/oradata/oradb/archivelog/1_22_732323841.dbf recid=22 stamp=734579607

archive log filename=/oracle/oradata/oradb/archivelog/1_23_732323841.dbf recid=21 stamp=734579603

archive log filename=/oracle/oradata/oradb/archivelog/1_24_732323841.dbf recid=23 stamp=734579611

archive log filename=/oracle/oradata/oradb/archivelog/1_25_732323841.dbf recid=24 stamp=734579612

archive log filename=/oracle/oradata/oradb/archivelog/1_26_732323841.dbf recid=25 stamp=734579622

archive log filename=/oracle/oradata/oradb/archivelog/1_27_732323841.dbf recid=26 stamp=735064060

archive log filename=/oracle/oradata/oradb/archivelog/1_28_732323841.dbf recid=27 stamp=735077844

archive log filename=/oracle/oradata/oradb/archivelog/1_29_732323841.dbf recid=28 stamp=735077845

archive log filename=/oracle/oradata/oradb/archivelog/1_30_732323841.dbf recid=30 stamp=735077854

archive log filename=/oracle/oradata/oradb/archivelog/1_31_732323841.dbf recid=29 stamp=735077854

archive log filename=/oracle/oradata/oradb/archivelog/1_32_732323841.dbf recid=31 stamp=735077873

archive log filename=/oracle/oradata/oradb/archivelog/1_33_732323841.dbf recid=32 stamp=735077875

archive log filename=/oracle/oradata/oradb/archivelog/1_34_732323841.dbf recid=33 stamp=735077877

archive log filename=/oracle/oradata/oradb/archivelog/1_35_732323841.dbf recid=34 stamp=735077888

archive log filename=/oracle/oradata/oradb/archivelog/1_36_732323841.dbf recid=35 stamp=735078484

Finished backup at 2010-11-14 20:28:15

Starting Control File and SPFILE Autobackup at 2010-11-14 20:28:15

piece handle=/oracle/oradata/autobackup/oradb-cf-c-2485588605-20101114-01.dbf comment=NONE

Finished Control File and SPFILE Autobackup at 2010-11-14 20:28:19

RMAN>

三、 異機恢復

3.1. 建立組、使用者

3.1.1. groupadduseradd

newdbser上建立使用者組、使用者如下:

#groupadd -g 501 oinstall

#groupadd -g 502 dba

#useradd -u 501 -g oinstall -G dba oracle

3.1.2. 編輯使用者配置檔案

export EDITOR=vi

export ORACLE_SID=oradb

export ORACLE_BASE=/oracle

export ORACLE_HOME=$ORACLE_BASE/product/10.2/db_1

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export NLS_LANG="American_america.zhs16gbk"

export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss';

export PATH =$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin

3.2. 安裝oracle補丁

Oracle 10.2.0.1不支援lvm lv裸裝置作為datafile,因此如果直接將備份集恢復到10.2.0.1的話,將出現ORA-27094的錯誤,錯誤日誌如下:

##########以下為10.2.0.1環境下將datafile恢復到裸裝置下的報錯日誌###############

RMAN> @/oracle/restore_raw.rman

RMAN> run

2> {

3> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_users_6ccmb0x6_.dbf'

TO '/oracle/oradata/oradb/user_128m';

4> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_sysaux_6ccmb0pf_.dbf'

TO '/oracle/oradata/oradb/sysaux_512m';

5> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_undotbs1_6ccmb0w4_.dbf'

TO '/oracle/oradata/oradb/undo01_512m';

6> SET NEWNAME FOR DATAFILE

'/oracle/oradata/ORADB/datafile/o1_mf_system_6ccmb0oy_.dbf'

TO '/oracle/oradata/oradb/system_1g';

7> set until scn 556840;

8> restore database;

9> switch datafile all;

10> recover database;

11> }

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET until clause

Starting restore at 2010-11-09 20:13:58

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore

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

restoring datafile 00001 to /oracle/oradata/oradb/system_1g

restoring datafile 00002 to /oracle/oradata/oradb/undo01_512m

restoring datafile 00003 to /oracle/oradata/oradb/sysaux_512m

restoring datafile 00004 to /oracle/oradata/oradb/user_128m

channel ORA_DISK_1: reading from backup piece /oracle/oradb-20101109-1flshds1_1_1.rman

ORA-19870: error reading backup piece /oracle/oradb-20101109-1flshds1_1_1.rman

ORA-19504: failed to create file "/oracle/oradata/oradb/system_1g"

ORA-27094: raw volume used can damage partition table

Additional information: -2

Additional information: 1073741824

##########以上為10.2.0.1環境下將datafile恢復到裸裝置下的報錯日誌###############

關於ORA-27094,詳見《Linux x86平臺下Oracle 10.2.0.1 ORA-27094》一文。

3.2.1. 停止相關程式

$ emctl stop dbconsole

$ isqlplusctl stop

$ lsnrctl stop

shutdown資料庫例項

如果使用ASM,需要將ASMshutdown

具體可以檢視補丁包中的patch_note.htm文件。

3.2.2. 備份相關檔案

Oracle recommends that you create a backup of the Oracle Inventory, Oracle 10g home and Oracle 10g Database before you install the patch set.

3.2.3. 設定DISPLAY引數

需要設定DISPLAY才能使用圖形介面方式安裝;若採用靜默安裝,則不需要設定DISPLAY

3.2.4. 執行runInstaller安裝

% cd patchset_directory/Disk1
% ./runInstaller
注意:在選擇安裝目錄時,需要指定當初安裝10.2.0.1的目錄即$ORACLE_HOME,否則將安裝失敗。

3.3. 建立空例項

對於類Unix平臺,建立oracle空例項實際上就是建立oracle相關的一些目錄。

oracle使用者執行以下命令建立相關目錄:

$mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID

$mkdir $ORACLE_BASE/admin/$ORACLE_SID

$cd $ORACLE_BASE/admin/$ORACLE_SID

$mkdir pfile bdump udump cdump

3.4. 重建密碼檔案

$orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle

3.5. 設定DBID

[oracle@Ora_tar mapper]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Mon Nov 15 14:51:02 2010

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

connected to target database (not started)

RMAN> set DBID 2485588605;

executing command: SET DBID

RMAN>

3.6. 將資料庫啟動到nomount狀態

這裡會報錯提示找不到相關的spfilepfileinitSID.ora等引數檔案。

RMAN> startup nomount;

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

LRM-00109: could not open parameter file '/oracle/product/10.2/db_1/dbs/initoradb.ora'

starting Oracle instance without parameter file for retrival of spfile

Oracle instance started

Total System Global Area 159383552 bytes

Fixed Size 1266320 bytes

Variable Size 58723696 bytes

Database Buffers 92274688 bytes

Redo Buffers 7118848 bytes

RMAN>

3.7. 恢復引數檔案

RMAN> restore spfile to pfile '/oracle/oradata/initoradb.ora' from '/oracle/oradb-cf-c-2485588605-20101114-01.dbf';

Starting restore at 2010-11-15 14:53:55

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=36 devtype=DISK

channel ORA_DISK_1: autobackup found: /oracle/oradb-cf-c-2485588605-20101114-01.dbf

channel ORA_DISK_1: SPFILE restore from autobackup complete

Finished restore at 2010-11-15 14:53:58

RMAN>

3.8. 用恢復的pfile將資料庫啟動到nomount狀態

使用上一步恢復的引數檔案/oracle/oradata/initoradb.ora將資料庫啟動到nomount狀態。

RMAN> startup force nomount pfile='/oracle/oradata/initoradb.ora';

Oracle instance started

Total System Global Area 167772160 bytes

Fixed Size 1266368 bytes

Variable Size 79695168 bytes

Database Buffers 79691776 bytes

Redo Buffers 7118848 bytes

RMAN>

3.9. 恢復控制檔案

RMAN> restore controlfile from '/oracle/oradb-cf-c-2485588605-20101114-01.dbf';

注意:這裡用於恢復的控制檔案源為上一步備份資料庫及歸檔日誌兩步中後一步生成的檔案集。

Starting restore at 2010-11-15 14:54:34

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: restoring control file

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

output filename=/oracle/oradata/ORADB/controlfile/o1_mf_6g1p9dt0_.ctl

Finished restore at 2010-11-15 14:54:37

RMAN>

3.10. mount資料庫

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN>

接:【資料遷移1】Oracle 10gR2 rman異機恢復實驗(FS->RAW)(2

http://xunzhaoxz.itpub.net/post/40016/522834

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

相關文章