【RMAN】RMAN跨版本恢復(中)

Appleses發表於2016-01-30

RMANRMAN跨版本恢復()--大版本異機恢復

BLOG文件結構圖

 

 

wps2987.tmp 

 

 

 

 

 

ORACLE_SID=jiagulun

原機:  OS:Linux x86 64-bit  IP:192.168.59.156  oracle:10.2.0.1.0 歸檔模式

異機:  OS:Linux x86 64-bit  IP:192.168.59.10   oracle:11.2.0.3.0  歸檔模式

目的:利用原機的rman備份集將原庫恢復到異機。

 

 

注意: 不能成功upgrade,請看本文的最後的小結部分

 

 

關於10g的跨小版本恢復參考:http://blog.chinaunix.net/uid-26736162-id-4942816.html

關於11g的跨小版本恢復參考:http://blog.itpub.net/26736162/viewspace-1561185/

關於在不同版本和平臺之間進行還原或複製的常見問題 http://blog.itpub.net/26736162/viewspace-1549041/

 

 

 

一、 全備份原資料庫並複製到異機

備份指令碼如下:

[oracle@redhat4 ~]$ mkdir -p /home/oracle/oracle_bk/orcl/

 

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup database filesperset 4 format  '/home/oracle/oracle_bk/orcl/full_%n_%T_%t_%s_%p.bak';

backup spfile format='/home/oracle/oracle_bk/orcl/spfile_%n_%U_%T.bak';

sql 'alter system archive log current';

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

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

release channel c1;

release channel c2;

}

 

 

 

 

[oracle@redhat4 ~]$  sqlplus / as sysdba

 

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 4月 9 16:27:13 2015

 

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

 

 

連線到:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options

 

 

SQL> create pfile from spfile;

 

File created.

 

 

[oracle@redhat4 ~]$ rman target /

 

恢復管理器: Release 10.2.0.1.0 - Production on 星期四 4月 9 16:22:07 2015

 

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

 

連線到目標資料庫: JIAGULUN (DBID=2694191837)

 

RMAN> list backupset;

 

使用目標資料庫控制檔案替代恢復目錄

 

RMAN> run{

2>  allocate channel c1 type disk;

3>  allocate channel c2 type disk;

4>  backup database filesperset 4 format  '/home/oracle/oracle_bk/orcl/full_%n_%T_%t_%s_%p.bak';

5>  backup spfile format='/home/oracle/oracle_bk/orcl/spfile_%n_%U_%T.bak';

6>  sql 'alter system archive log current';

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

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

9> release channel c1;

10> release channel c2;

11> }

 

分配的通道: c1

通道 c1: sid=140 devtype=DISK

 

分配的通道: c2

通道 c2: sid=144 devtype=DISK

 

啟動 backup 於 09-4月 -15

通道 c1: 啟動全部資料檔案備份集

通道 c1: 正在指定備份集中的資料檔案

輸入資料檔案 fno=00001 name=/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_system_7p5b14xs_.dbf

輸入資料檔案 fno=00004 name=/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_users_7p5b157q_.dbf

通道 c1: 正在啟動段 1 於 09-4月 -15

通道 c2: 啟動全部資料檔案備份集

通道 c2: 正在指定備份集中的資料檔案

輸入資料檔案 fno=00003 name=/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_sysaux_7p5b14yl_.dbf

輸入資料檔案 fno=00005 name=/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_example_7p5b3r36_.dbf

輸入資料檔案 fno=00002 name=/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_undotbs1_7p5b155m_.dbf

通道 c2: 正在啟動段 1 於 09-4月 -15

通道 c1: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_14_1.bak 標記=TAG20150409T162224 註釋=NONE

通道 c1: 備份集已完成, 經過時間:00:01:35

通道 c1: 啟動全部資料檔案備份集

通道 c1: 正在指定備份集中的資料檔案

備份集中包括當前控制檔案

通道 c1: 正在啟動段 1 於 09-4月 -15

通道 c2: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_15_1.bak 標記=TAG20150409T162224 註釋=NONE

通道 c2: 備份集已完成, 經過時間:00:01:36

通道 c2: 啟動全部資料檔案備份集

通道 c2: 正在指定備份集中的資料檔案

通道 c1: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587040_16_1.bak 標記=TAG20150409T162224 註釋=NONE

通道 c1: 備份集已完成, 經過時間:00:00:02

在備份集中包含當前的 SPFILE

通道 c2: 正在啟動段 1 於 09-4月 -15

通道 c2: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587041_17_1.bak 標記=TAG20150409T162224 註釋=NONE

通道 c2: 備份集已完成, 經過時間:00:00:02

完成 backup 於 09-4月 -15

 

啟動 backup 於 09-4月 -15

通道 c1: 啟動全部資料檔案備份集

通道 c1: 正在指定備份集中的資料檔案

在備份集中包含當前的 SPFILE

通道 c1: 正在啟動段 1 於 09-4月 -15

通道 c1: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/spfile_JIAGULUN_0iq3va14_1_1_20150409.bak 標記=TAG20150409T162404 註釋=NONE

通道 c1: 備份集已完成, 經過時間:00:00:02

完成 backup 於 09-4月 -15

 

sql 語句: alter system archive log current

 

啟動 backup 於 09-4月 -15

當前日誌已存檔

通道 c1: 正在啟動存檔日誌備份集

通道 c1: 正在指定備份集中的存檔日誌

輸入存檔日誌執行緒 =1 序列 =12 記錄 ID=5 時間戳=876587046

通道 c1: 正在啟動段 1 於 09-4月 -15

通道 c2: 正在啟動存檔日誌備份集

通道 c2: 正在指定備份集中的存檔日誌

輸入存檔日誌執行緒 =1 序列 =13 記錄 ID=6 時間戳=876587046

通道 c2: 正在啟動段 1 於 09-4月 -15

通道 c1: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_19_1.bak 標記=TAG20150409T162406 註釋=NONE

通道 c1: 備份集已完成, 經過時間:00:00:01

通道 c1: 正在刪除存檔日誌

存檔日誌檔名 =/u01/app/oracle/flash_recovery_area/JIAGULUN/archivelog/2015_04_09/o1_mf_1_12_bldfs6o6_.arc 記錄 ID=5 時間戳 =876587046

通道 c2: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_20_1.bak 標記=TAG20150409T162406 註釋=NONE

通道 c2: 備份集已完成, 經過時間:00:00:02

通道 c2: 正在刪除存檔日誌

存檔日誌檔名 =/u01/app/oracle/flash_recovery_area/JIAGULUN/archivelog/2015_04_09/o1_mf_1_13_bldfs6sp_.arc 記錄 ID=6 時間戳 =876587046

完成 backup 於 09-4月 -15

 

啟動 backup 於 09-4月 -15

通道 c1: 啟動全部資料檔案備份集

通道 c1: 正在指定備份集中的資料檔案

備份集中包括當前控制檔案

通道 c1: 正在啟動段 1 於 09-4月 -15

通道 c1: 已完成段 1 於 09-4月 -15

段控制程式碼=/home/oracle/oracle_bk/orcl/ctl_JIAGULUN_20150409_21_1.bak 標記=TAG20150409T162410 註釋=NONE

通道 c1: 備份集已完成, 經過時間:00:00:01

完成 backup 於 09-4月 -15

 

釋放的通道: c1

 

釋放的通道: c2

 

RMAN>

 

 

 

 

 

[root@redhat4 ~]# cd /home/oracle/oracle_bk/orcl/

[root@redhat4 orcl]# ll

總用量 653796

-rw-r-----  1 oracle oinstall    103936  4月  9 16:24 arch_JIAGULUN_20150409_19_1.bak

-rw-r-----  1 oracle oinstall      2560  4月  9 16:24 arch_JIAGULUN_20150409_20_1.bak

-rw-r-----  1 oracle oinstall   7110656  4月  9 16:24 ctl_JIAGULUN_20150409_21_1.bak

-rw-r-----  1 oracle oinstall 392822784  4月  9 16:23 full_JIAGULUN_20150409_876586944_14_1.bak

-rw-r-----  1 oracle oinstall 261447680  4月  9 16:23 full_JIAGULUN_20150409_876586944_15_1.bak

-rw-r-----  1 oracle oinstall   7110656  4月  9 16:24 full_JIAGULUN_20150409_876587040_16_1.bak

-rw-r-----  1 oracle oinstall     98304  4月  9 16:24 full_JIAGULUN_20150409_876587041_17_1.bak

-rw-r-----  1 oracle oinstall     98304  4月  9 16:24 spfile_JIAGULUN_0iq3va14_1_1_20150409.bak

[root@redhat4 orcl]#

 

[root@redhat4 orcl]# su - oracle

[oracle@redhat4 ~]$ cd /home/oracle/oracle_bk/

[oracle@redhat4 oracle_bk]$ scp -r orcl oracle@192.168.59.10:/tmp/

The authenticity of host '192.168.59.10 (192.168.59.10)' can't be established.

RSA key fingerprint is 77:e6:11:1a:7c:c7:81:7c:88:c9:21:18:51:2a:84:d1.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.59.10' (RSA) to the list of known hosts.

oracle@192.168.59.10's password:

ctl_JIAGULUN_20150409_21_1.bak                                                                                                                                                  100% 6944KB   6.8MB/s   00:00   

full_JIAGULUN_20150409_876586944_14_1.bak                                                                                                                                       100%  375MB  19.7MB/s   00:19   

arch_JIAGULUN_20150409_20_1.bak                                                                                                                                                 100% 2560     2.5KB/s   00:00   

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

arch_JIAGULUN_20150409_19_1.bak                                                                                                                                                 100%  102KB 101.5KB/s   00:00   

full_JIAGULUN_20150409_876586944_15_1.bak                                                                                                                                       100%  249MB  16.6MB/s   00:15   

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

full_JIAGULUN_20150409_876587040_16_1.bak                                                                                                                                       100% 6944KB   6.8MB/s   00:01   

[oracle@redhat4 oracle_bk]$ scp $ORACLE_HOME/dbs/initjiagulun.ora oracle@192.168.59.10:/tmp/orcl/

oracle@192.168.59.10's password:

initjiagulun.ora                                                                                                                                                                100% 1171     1.1KB/s   00:00   

[oracle@redhat4 oracle_bk]$

 

 

 

 

 

二、 在異機的操作 1、 恢復spfile

 

這裡不採用rman恢復了,因為要實驗異機不同路徑的恢復,所以直接修改pfile檔案吧。

 

[oracle@testdb orcl]$ cd /tmp/orcl

[oracle@testdb orcl]$ cp initjiagulun.ora $ORACLE_HOME/dbs/

[oracle@testdb orcl]$ vi $ORACLE_HOME/dbs/initjiagulun.ora

 

 

修改pfile檔案之後:

[oracle@testdb orcl]$ more  $ORACLE_HOME/dbs/initjiagulun.ora

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

*.compatible='10.2.0.1.0'

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

*.db_block_size=8192

*.db_create_file_dest='/u01/app/oracle/oradata'

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_name='jiagulun'

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

*.db_recovery_file_dest_size=2147483648

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

*.job_queue_processes=10

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sessions=170

*.memory_target=500572800

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

[oracle@testdb orcl]$

[oracle@testdb orcl]$

 

 

建立相關路徑:

[oracle@testdb orcl]$ mkdir -p /u01/app/oracle/admin/jiagulun/adump

[oracle@testdb orcl]$ mkdir -p /u01/app/oracle/oradata/jiagulun/

[oracle@testdb orcl]$

 

---建立原庫的相關路徑

[oracle@testdb dbs]$ mkdir -p /u01/app/oracle/oradata/JIAGULUN/datafile/

[oracle@testdb dbs]$ mkdir -p /u01/app/oracle/oradata/JIAGULUN/onlinelog/

[oracle@testdb dbs]$ mkdir -p /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/

[oracle@testdb dbs]$

 

 

 

 

 

[oracle@testdb dbs]$ ORACLE_SID=jiagulun

[oracle@testdb dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 9 16:54:26 2015

 

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

 

Connected to an idle instance.

 

SQL>  create spfile from pfile;

 

File created.

 

SQL>

 

 

SQL> startup nomount;

ORACLE instance started.

 

Total System Global Area  501059584 bytes

Fixed Size                  2229744 bytes

Variable Size             310381072 bytes

Database Buffers          180355072 bytes

Redo Buffers                8093696 bytes

SQL>

 

 

 

 

 

2、  恢復控制檔案

 

 

[oracle@testdb dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Apr 9 16:55:37 2015

 

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

 

connected to target database: JIAGULUN (not mounted)

 

RMAN> restore controlfile to '/u01/app/oracle/oradata/jiagulun/control01.ctl' from '/tmp/orcl/ctl_JIAGULUN_20150409_21_1.bak';

 

Starting restore at 09-APR-15

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=134 device type=DISK

 

channel ORA_DISK_1: restoring control file

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

Finished restore at 09-APR-15

 

RMAN>

 

Recovery Manager complete.

[oracle@testdb orcl]$ cp  /u01/app/oracle/oradata/jiagulun/control01.ctl /u01/app/oracle/oradata/jiagulun/control02.ctl

[oracle@testdb dbs]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Apr 9 16:57:53 2015

 

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

 

connected to target database: JIAGULUN (not mounted)

 

RMAN> alter database mount;

 

using target database control file instead of recovery catalog

 

 

 

database mounted

 

RMAN>

RMAN>

 

 

3、 恢復歸檔檔案

 

RMAN> catalog start with '/tmp/orcl/';

 

Starting implicit crosscheck backup at 09-APR-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=125 device type=DISK

Crosschecked 7 objects

Finished implicit crosscheck backup at 09-APR-15

 

Starting implicit crosscheck copy at 09-APR-15

using channel ORA_DISK_1

Finished implicit crosscheck copy at 09-APR-15

 

searching for all files in the recovery area

cataloging files...

no files cataloged

 

searching for all files that match the pattern /tmp/orcl/

 

List of Files Unknown to the Database

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

File Name: /tmp/orcl/arch_JIAGULUN_20150409_20_1.bak

File Name: /tmp/orcl/initjiagulun.ora

File Name: /tmp/orcl/full_JIAGULUN_20150409_876587040_16_1.bak

File Name: /tmp/orcl/spfile_JIAGULUN_0iq3va14_1_1_20150409.bak

File Name: /tmp/orcl/full_JIAGULUN_20150409_876587041_17_1.bak

File Name: /tmp/orcl/full_JIAGULUN_20150409_876586944_15_1.bak

File Name: /tmp/orcl/arch_JIAGULUN_20150409_19_1.bak

File Name: /tmp/orcl/full_JIAGULUN_20150409_876586944_14_1.bak

File Name: /tmp/orcl/ctl_JIAGULUN_20150409_21_1.bak

 

Do you really want to catalog the above files (enter YES or NO)? yes

cataloging files...

cataloging done

 

List of Cataloged Files

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

File Name: /tmp/orcl/arch_JIAGULUN_20150409_20_1.bak

File Name: /tmp/orcl/full_JIAGULUN_20150409_876587040_16_1.bak

File Name: /tmp/orcl/spfile_JIAGULUN_0iq3va14_1_1_20150409.bak

File Name: /tmp/orcl/full_JIAGULUN_20150409_876587041_17_1.bak

File Name: /tmp/orcl/full_JIAGULUN_20150409_876586944_15_1.bak

File Name: /tmp/orcl/arch_JIAGULUN_20150409_19_1.bak

File Name: /tmp/orcl/full_JIAGULUN_20150409_876586944_14_1.bak

File Name: /tmp/orcl/ctl_JIAGULUN_20150409_21_1.bak

 

List of Files Which Where Not Cataloged

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

File Name: /tmp/orcl/initjiagulun.ora

  RMAN-07517: Reason: The file header is corrupted

 

RMAN>

 

RMAN>  crosscheck archivelog all;

 

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=125 device type=DISK

specification does not match any archived log in the repository

 

RMAN>

using channel ORA_DISK_1

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_15_1.bak RECID=14 STAMP=876586944

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/full_JIAGULUN_20150409_876586944_15_1.bak RECID=25 STAMP=876589228

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_14_1.bak RECID=15 STAMP=876586944

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/full_JIAGULUN_20150409_876586944_14_1.bak RECID=27 STAMP=876589228

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587040_16_1.bak RECID=16 STAMP=876587040

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/full_JIAGULUN_20150409_876587040_16_1.bak RECID=22 STAMP=876589228

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587041_17_1.bak RECID=17 STAMP=876587042

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/full_JIAGULUN_20150409_876587041_17_1.bak RECID=24 STAMP=876589228

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/home/oracle/oracle_bk/orcl/spfile_JIAGULUN_0iq3va14_1_1_20150409.bak RECID=18 STAMP=876587045

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/spfile_JIAGULUN_0iq3va14_1_1_20150409.bak RECID=23 STAMP=876589228

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_19_1.bak RECID=19 STAMP=876587048

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/arch_JIAGULUN_20150409_19_1.bak RECID=26 STAMP=876589228

crosschecked backup piece: found to be 'EXPIRED'

backup piece handle=/home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_20_1.bak RECID=20 STAMP=876587048

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/arch_JIAGULUN_20150409_20_1.bak RECID=21 STAMP=876589228

crosschecked backup piece: found to be 'AVAILABLE'

backup piece handle=/tmp/orcl/ctl_JIAGULUN_20150409_21_1.bak RECID=28 STAMP=876589228

Crosschecked 15 objects

 

 

RMAN> delete noprompt obsolete;

 

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

using channel ORA_DISK_1

Deleting the following obsolete backups and copies:

Type                 Key    Completion Time    Filename/Handle

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

Backup Set           16     09-APR-15        

  Backup Piece       16     09-APR-15          /home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587040_16_1.bak

Backup Set           17     09-APR-15        

  Backup Piece       17     09-APR-15          /home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587041_17_1.bak

deleted backup piece

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587040_16_1.bak RECID=16 STAMP=876587040

deleted backup piece

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876587041_17_1.bak RECID=17 STAMP=876587042

Deleted 2 objects

 

 

RMAN>

 

RMAN> crosscheck archivelog all;

 

released channel: ORA_DISK_1

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=125 device type=DISK

specification does not match any archived log in the repository

 

RMAN> 

 

RMAN> delete EXPIRED backupset;

 

using channel ORA_DISK_1

 

List of Backup Pieces

BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name

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

14      14      1   1   EXPIRED     DISK        /home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_15_1.bak

15      15      1   1   EXPIRED     DISK        /home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_14_1.bak

18      18      1   1   EXPIRED     DISK        /home/oracle/oracle_bk/orcl/spfile_JIAGULUN_0iq3va14_1_1_20150409.bak

19      19      1   1   EXPIRED     DISK        /home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_19_1.bak

20      20      1   1   EXPIRED     DISK        /home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_20_1.bak

 

Do you really want to delete the above objects (enter YES or NO)? yes

deleted backup piece

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_15_1.bak RECID=14 STAMP=876586944

deleted backup piece

backup piece handle=/home/oracle/oracle_bk/orcl/full_JIAGULUN_20150409_876586944_14_1.bak RECID=15 STAMP=876586944

deleted backup piece

backup piece handle=/home/oracle/oracle_bk/orcl/spfile_JIAGULUN_0iq3va14_1_1_20150409.bak RECID=18 STAMP=876587045

deleted backup piece

backup piece handle=/home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_19_1.bak RECID=19 STAMP=876587048

deleted backup piece

backup piece handle=/home/oracle/oracle_bk/orcl/arch_JIAGULUN_20150409_20_1.bak RECID=20 STAMP=876587048

Deleted 5 EXPIRED objects

 

 

RMAN>

 

RMAN> list backup of archivelog all;

 

 

List of Backup Sets

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

 

 

BS Key  Size       Device Type Elapsed Time Completion Time

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

19      101.00K    DISK        00:00:01     09-APR-15     

        BP Key: 26   Status: AVAILABLE  Compressed: NO  Tag: TAG20150409T162406

        Piece Name: /tmp/orcl/arch_JIAGULUN_20150409_19_1.bak

 

  List of Archived Logs in backup set 19

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

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

  1   12      694289     09-APR-15 694583     09-APR-15

 

BS Key  Size       Device Type Elapsed Time Completion Time

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

20      2.00K      DISK        00:00:01     09-APR-15     

        BP Key: 21   Status: AVAILABLE  Compressed: NO  Tag: TAG20150409T162406

        Piece Name: /tmp/orcl/arch_JIAGULUN_20150409_20_1.bak

 

  List of Archived Logs in backup set 20

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

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

  1    13      694583     09-APR-15 694588     09-APR-15

 

RMAN>

RMAN> restore archivelog sequence between 12 and 13;

 

Starting restore at 09-APR-15

using channel ORA_DISK_1

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=12

channel ORA_DISK_1: reading from backup piece /tmp/orcl/arch_JIAGULUN_20150409_19_1.bak

channel ORA_DISK_1: piece handle=/tmp/orcl/arch_JIAGULUN_20150409_19_1.bak tag=TAG20150409T162406

channel ORA_DISK_1: restored backup piece 1

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

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=13

channel ORA_DISK_1: reading from backup piece /tmp/orcl/arch_JIAGULUN_20150409_20_1.bak

channel ORA_DISK_1: piece handle=/tmp/orcl/arch_JIAGULUN_20150409_20_1.bak tag=TAG20150409T162406

channel ORA_DISK_1: restored backup piece 1

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

Finished restore at 09-APR-15

 

RMAN>

 

 

 

4、 恢復資料檔案

 

由於恢復路徑不同,所以需要set newname

 

set pagesize  200 linesize 200

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

  from v$datafile a

union all

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

  from v$tempfile a

union all

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

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

  FROM v$logfile a;

 

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/JIAGULUN/datafile/o1_mf_system_7p5b14xs_.dbf";

set newname for datafile 2 to "/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_undotbs1_7p5b155m_.dbf";

set newname for datafile 3 to "/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_sysaux_7p5b14yl_.dbf";

set newname for datafile 4 to "/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_users_7p5b157q_.dbf";

set newname for datafile 5 to "/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_example_7p5b3r36_.dbf";

set newname for tempfile 1 to "/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_temp_7p5b3loz_.tmp";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log''  to  ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log''  to  ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log'' "

;

 

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log''  to  ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log''  to  ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log'' "

;

 

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log''  to  ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log''  to  ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log'' "

;

 

 

已選擇12行。

SQL>

 

 

修改指令碼:

RUN

{

  ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

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

set newname for datafile 2 to "/u01/app/oracle/oradata/jiagulun/undotbs01.dbf";

set newname for datafile 3 to "/u01/app/oracle/oradata/jiagulun/sysaux01.dbf";

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

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

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

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo03.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo03_1.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo02.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo02_1.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo01.log'' ";

SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo01_1.log'' ";

 

  SET UNTIL sequence 13 thread 1;

  RESTORE DATABASE;

  SWITCH DATAFILE ALL;

  RECOVER DATABASE;

}

 

 

 

啟動資料庫到mount狀態:

 

 

 

RMAN> shutdown abort;

 

Oracle instance shut down

 

RMAN> startup mount;

 

connected to target database (not started)

Oracle instance started

database mounted

 

Total System Global Area     501059584 bytes

 

Fixed Size                     2229744 bytes

Variable Size                310381072 bytes

Database Buffers             180355072 bytes

Redo Buffers                   8093696 bytes

 

RMAN>

 

RMAN> RUN

2> {

3>   ALLOCATE CHANNEL c1 DEVICE TYPE DISK;

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

5> set newname for datafile 2 to "/u01/app/oracle/oradata/jiagulun/undotbs01.dbf";

6> set newname for datafile 3 to "/u01/app/oracle/oradata/jiagulun/sysaux01.dbf";

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

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

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

10> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo03.log'' ";

11> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo03_1.log'' ";

12> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo02.log'' ";

13> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo02_1.log'' ";

14> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo01.log'' ";

15> SQL "ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo01_1.log'' ";

16>

17>   SET UNTIL sequence 13 thread 1;

18>   RESTORE DATABASE;

19>   SWITCH DATAFILE ALL;

20>   RECOVER DATABASE;

21> }

 

released channel: ORA_DISK_1

allocated channel: c1

channel c1: SID=133 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/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo03.log''

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo03_1.log''

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo02.log''

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo02_1.log''

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo01.log''

 

sql statement: ALTER DATABASE RENAME FILE ''/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log''  to  ''/u01/app/oracle/oradata/jiagulun/redo01_1.log''

 

executing command: SET until clause

 

Starting restore at 09-APR-15

 

channel c1: starting datafile backup set restore

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

channel c1: restoring datafile 00002 to /u01/app/oracle/oradata/jiagulun/undotbs01.dbf

channel c1: restoring datafile 00003 to /u01/app/oracle/oradata/jiagulun/sysaux01.dbf

channel c1: restoring datafile 00005 to /u01/app/oracle/oradata/jiagulun/example01.dbf

channel c1: reading from backup piece /tmp/orcl/full_JIAGULUN_20150409_876586944_15_1.bak

channel c1: piece handle=/tmp/orcl/full_JIAGULUN_20150409_876586944_15_1.bak tag=TAG20150409T162224

channel c1: restored backup piece 1

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

channel c1: starting datafile backup set restore

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

channel c1: restoring datafile 00001 to /u01/app/oracle/oradata/jiagulun/system01.dbf

channel c1: restoring datafile 00004 to /u01/app/oracle/oradata/jiagulun/users01.dbf

channel c1: reading from backup piece /tmp/orcl/full_JIAGULUN_20150409_876586944_14_1.bak

channel c1: piece handle=/tmp/orcl/full_JIAGULUN_20150409_876586944_14_1.bak tag=TAG20150409T162224

channel c1: restored backup piece 1

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

Finished restore at 09-APR-15

 

datafile 1 switched to datafile copy

input datafile copy RECID=7 STAMP=876591796 file name=/u01/app/oracle/oradata/jiagulun/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=8 STAMP=876591796 file name=/u01/app/oracle/oradata/jiagulun/undotbs01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=9 STAMP=876591796 file name=/u01/app/oracle/oradata/jiagulun/sysaux01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=10 STAMP=876591796 file name=/u01/app/oracle/oradata/jiagulun/users01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=11 STAMP=876591796 file name=/u01/app/oracle/oradata/jiagulun/example01.dbf

 

Starting recover at 09-APR-15

 

starting media recovery

 

archived log for thread 1 with sequence 12 is already on disk as file /u01/app/oracle/flash_recovery_area/JIAGULUN/archivelog/2015_04_09/o1_mf_1_12_bldjk2wt_.arc

archived log file name=/u01/app/oracle/flash_recovery_area/JIAGULUN/archivelog/2015_04_09/o1_mf_1_12_bldjk2wt_.arc thread=1 sequence=12

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

Finished recover at 09-APR-15

released channel: c1

 

RMAN>

 

 

 

 

 

 

 

告警日誌:

Thu Apr 09 17:42:45 2015

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo03.log'

Deleted Oracle managed file /u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_3_7p5b35yp_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo03.log'

ALTER DATABASE RENAME FILE '/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo03_1.log'

Deleted Oracle managed file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_3_7p5b36x4_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo03_1.log'

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo02.log'

Deleted Oracle managed file /u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_2_7p5b33sx_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo02.log'

ALTER DATABASE RENAME FILE '/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo02_1.log'

Deleted Oracle managed file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_2_7p5b34v6_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo02_1.log'

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo01.log'

Deleted Oracle managed file /u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/JIAGULUN/onlinelog/o1_mf_1_7p5b30lb_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo01.log'

ALTER DATABASE RENAME FILE '/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo01_1.log'

Deleted Oracle managed file /u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log

Completed: ALTER DATABASE RENAME FILE '/u01/app/oracle/flash_recovery_area/JIAGULUN/onlinelog/o1_mf_1_7p5b31mg_.log'  to  '/u01/app/oracle/oradata/jiagulun/redo01_1.log'

Thu Apr 09 17:42:47 2015

Full restore complete of datafile 2 to datafile copy /u01/app/oracle/oradata/jiagulun/undotbs01.dbf.  Elapsed time: 0:00:00

  checkpoint is 694528

Full restore complete of datafile 5 to datafile copy /u01/app/oracle/oradata/jiagulun/example01.dbf.  Elapsed time: 0:00:02

  checkpoint is 694528

Full restore complete of datafile 3 to datafile copy /u01/app/oracle/oradata/jiagulun/sysaux01.dbf.  Elapsed time: 0:00:05

  checkpoint is 694528

Thu Apr 09 17:43:01 2015

Full restore complete of datafile 4 to datafile copy /u01/app/oracle/oradata/jiagulun/users01.dbf.  Elapsed time: 0:00:00

  checkpoint is 694529

Thu Apr 09 17:43:04 2015

Time drift detected. Please check VKTM trace file for more details.

Thu Apr 09 17:43:15 2015

Full restore complete of datafile 1 to datafile copy /u01/app/oracle/oradata/jiagulun/system01.dbf.  Elapsed time: 0:00:13

  checkpoint is 694529

Thu Apr 09 17:43:17 2015

Errors in file /u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_ora_13658.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_system_7p5b14xs_.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 694529

Errors in file /u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_ora_13658.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_undotbs1_7p5b155m_.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 694528

Errors in file /u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_ora_13658.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_sysaux_7p5b14yl_.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 694528

Errors in file /u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_ora_13658.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_users_7p5b157q_.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 694529

Errors in file /u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_ora_13658.trc:

ORA-19625: error identifying file /u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_example_7p5b3r36_.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 694528

alter database recover datafile list clear

Completed: alter database recover datafile list clear

alter database recover datafile list

1 , 2 , 3 , 4 , 5

Completed: alter database recover datafile list

1 , 2 , 3 , 4 , 5

alter database recover if needed

start until cancel using backup controlfile

Media Recovery Start

started logmerger process

Parallel Media Recovery started with 2 slaves

ORA-279 signalled during: alter database recover if needed

start until cancel using backup controlfile

...

alter database recover logfile '/u01/app/oracle/flash_recovery_area/JIAGULUN/archivelog/2015_04_09/o1_mf_1_12_bldjk2wt_.arc'

Media Recovery Log /u01/app/oracle/flash_recovery_area/JIAGULUN/archivelog/2015_04_09/o1_mf_1_12_bldjk2wt_.arc

ORA-279 signalled during: alter database recover logfile '/u01/app/oracle/flash_recovery_area/JIAGULUN/archivelog/2015_04_09/o1_mf_1_12_bldjk2wt_.arc'...

alter database recover cancel

Media Recovery Canceled

Completed: alter database recover cancel

 

 

 

5、 startup upgrade開啟資料庫

注意:startup upgrade開啟資料庫之前應該首先採用alter database open resetlogs;開啟資料庫一次,然後執行startup upgrade重新開啟資料庫,或者直接執行alter database open resetlogs upgrade;

 

[oracle@testdb dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 9 17:44:46 2015

 

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

 

 

Connected to:

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

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

 

SQL> select open_mode from v$database;

 

OPEN_MODE

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

MOUNTED

 

SQL>  alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-00704: bootstrap process failure

ORA-39700: database must be opened with UPGRADE option

Process ID: 11035

Session ID: 59 Serial number: 29

 

 

SQL>

SQL> shutdown abort;

ORA-24324: service handle not initialized

ORA-01041: internal error. hostdef extension doesn't exist

SQL> exit

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

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

 

 

 

--因為相同平臺的資料庫軟體版本不一樣,所以需要upgrade選項開啟。

 

--shutdown資料庫用upgrade選項開啟資料庫:

 

[oracle@testdb orcl]$ sqlplus / as sysdba

 

 

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 9 17:47:31 2015

 

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

 

Connected to an idle instance.

 

 

SQL> startup upgrade;

ORACLE instance started.

 

Total System Global Area  313159680 bytes

Fixed Size                  2227944 bytes

Variable Size             230687000 bytes

Database Buffers           75497472 bytes

Redo Buffers                4747264 bytes

Database mounted.

Database opened.

SQL> 

 

 

告警日誌:

ALTER DATABASE   MOUNT

Successful mount of redo thread 1, with mount id 2792694741

Database mounted in Exclusive Mode

Lost write protection disabled

Completed: ALTER DATABASE   MOUNT

Thu Apr 09 17:48:09 2015

ALTER DATABASE OPEN MIGRATE

Beginning crash recovery of 1 threads

parallel recovery started with 2 processes

Started redo scan

Completed redo scan

read 0 KB redo, 0 data blocks need recovery

Started redo application at

Thread 1: logseq 1, block 2, scn 694587

Recovery of Online Redo Log: Thread 1 Group 1 Seq 1 Reading mem 0

  Mem# 0: /u01/app/oracle/oradata/jiagulun/redo01.log

  Mem# 1: /u01/app/oracle/oradata/jiagulun/redo01_1.log

Completed redo application of 0.00MB

Completed crash recovery at

Thread 1: logseq 1, block 3, scn 714589

0 data blocks read, 0 data blocks written, 0 redo k-bytes read

LGWR: STARTING ARCH PROCESSES

Thu Apr 09 17:48:09 2015

ARC0 started with pid=20, OS id=14074

ARC0: Archival started

LGWR: STARTING ARCH PROCESSES COMPLETE

ARC0: STARTING ARCH PROCESSES

Thu Apr 09 17:48:10 2015

ARC1 started with pid=23, OS id=14076

Thread 1 advanced to log sequence 2 (thread open)

Thu Apr 09 17:48:10 2015

ARC2 started with pid=24, OS id=14078

Thread 1 opened at log sequence 2

  Current log# 2 seq# 2 mem# 0: /u01/app/oracle/oradata/jiagulun/redo02.log

  Current log# 2 seq# 2 mem# 1: /u01/app/oracle/oradata/jiagulun/redo02_1.log

Successful open of redo thread 1

MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set

SMON: enabling cache recovery

Thu Apr 09 17:48:10 2015

ARC1: Archival started

ARC3 started with pid=25, OS id=14080

ARC2: Archival started

ARC2: Becoming the 'no FAL' ARCH

ARC2: Becoming the 'no SRL' ARCH

ARC1: Becoming the heartbeat ARCH

Archived Log entry 9 added for thread 1 sequence 1 ID 0xa67589a0 dest 1:

[14064] Successfully onlined Undo Tablespace 1.

Undo initialization finished serial:0 start:62795144 end:62795464 diff:320 (3 seconds)

Dictionary check beginning

Errors in file /u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_dbw0_14007.trc:

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

ORA-01110: data file 201: '/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_temp_7p5b3loz_.tmp'

ORA-27037: unable to obtain file status

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

Additional information: 3

Errors in file /u01/app/oracle/diag/rdbms/jiagulun/jiagulun/trace/jiagulun_dbw0_14007.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: '/u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_temp_7p5b3loz_.tmp'

File 201 not verified due to error ORA-01157

Dictionary check complete

SMON: enabling tx recovery

Re-creating tempfile /u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_temp_7p5b3loz_.tmp as /u01/app/oracle/oradata/JIAGULUN/datafile/o1_mf_temp_bldlptwz_.tmp

Database Characterset is ZHS16GBK

Updating 10.2.0.1.0 NLS parameters in sys.props$

-- adding 11.2.0.3.0 NLS parameters.

ARC3: Archival started

ARC0: STARTING ARCH PROCESSES COMPLETE

Stopping background process MMNL

Stopping background process MMON

Starting background process MMON

Thu Apr 09 17:48:15 2015

MMON started with pid=15, OS id=14082

Starting background process MMNL

Thu Apr 09 17:48:15 2015

MMNL started with pid=16, OS id=14084

ALTER SYSTEM enable restricted session;

ALTER SYSTEM SET _system_trig_enabled=FALSE SCOPE=MEMORY;

Autotune of undo retention is turned off.

ALTER SYSTEM SET _undo_autotune=FALSE SCOPE=MEMORY;

ALTER SYSTEM SET undo_retention=900 SCOPE=MEMORY;

ALTER SYSTEM SET aq_tm_processes=0 SCOPE=MEMORY;

ALTER SYSTEM SET enable_ddl_logging=FALSE SCOPE=MEMORY;

Resource Manager disabled during database migration: plan '' not set

ALTER SYSTEM SET resource_manager_plan='' SCOPE=MEMORY;

ALTER SYSTEM SET recyclebin='OFF' DEFERRED SCOPE=MEMORY;

Resource Manager disabled during database migration

replication_dependency_tracking turned off (no async multimaster replication found)

XDB UNINITIALIZED: XDB$SCHEMA not accessible

LOGSTDBY: Validating controlfile with logical metadata

LOGSTDBY: Validation complete

Completed: ALTER DATABASE OPEN MIGRATE

Thu Apr 09 17:48:17 2015

Starting background process CJQ0

Thu Apr 09 17:48:17 2015

CJQ0 started with pid=26, OS id=14087

 

 

 

6、 執行升級指令碼catupgrd.sql  並編譯失效物件

 

SQL> SELECT d.owner, count(1)

  2    FROM dba_objects d

  3   where status = 'INVALID'

  4   GROUP BY d.owner;

 

OWNER                            COUNT(1)

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

PUBLIC                                396

CTXSYS                                  1

SYS                                    93

 

SQL>

 

SQL> select  INSTANCE_NAME,version,status from  v$instance;

 

INSTANCE_NAME    VERSION           STATUS

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

jiagulun         11.2.0.3.0       OPEN MIGRATE

 

 

 

$ORACLE_HOME\RDBMS\ADMIN\catupgrd.sql 

--執行這個指令碼。這個指令碼呼叫catlog.sqlcatproc.sql來重建字典物件等,在執行完這個指令碼之後,我們可以關閉資料庫後,正常開啟資料庫:

 

 

spool /tmp/upgrade.log

set echo on

@$ORACLE_HOME/rdbms/admin/catupgrd.sql;

spool off

Shutdown immediate

 

執行之前可以把以下引數設定大點,否則可能導致升級指令碼不能正常執行,如果指令碼執行失敗可以關閉資料庫重新startup upgrade後再重新執行該指令碼:

wps29A7.tmp 

Thu Apr 09 14:40:46 2015

Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_11151.trc  (incident=2870):

ORA-04031: unable to allocate 4096 bytes of shared memory ("java pool","unknown object","JOXLE^5e8bb91c",":SGAClass")

Use ADRCI or Support Workbench to package the incident.

See Note 411.1 at My Oracle Support for error and packaging details.

Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_11151.trc  (incident=2871):

ORA-04031: unable to allocate 4096 bytes of shared memory ("java pool","unknown object","JOXLE^5e8bb91c",":SGAClass")

Use ADRCI or Support Workbench to package the incident.

See Note 411.1 at My Oracle Support for error and packaging details.

 

但是這裡執行的時候就報錯了,不能完整的執行升級指令碼,後來網上查了下是因為10.2.0.1不能直接升級到11g的版本,10g的版本必須大於10.2.0.2.暈死人,╮(╯▽╰)╭,,,,不過回想一下這樣的資料庫可以作為找回一些由於誤操作導致丟失了的資料,其實也是一種辦法。

SELECT TO_NUMBER('MUST_HAVE_RUN_PRE-UPGRADE_TOOL_FOR_TIMEZONE') 
   *  ERROR at line 1: 
   ORA-01722: invalid number

 

算了,再找個高版本實驗吧,請看下一篇文章。。。。。

 

 

7、 小結

10g Restore 11g 2個關鍵內容:

1.     必須在10g庫上先執行@?/rdbms/admin/utlu112i.sql指令碼,然後在備份,否則Restore之後的升級將失敗。

2.     10g的版本必須大於10.2.0.2.

 

參考文件:http://blog.csdn.net/tianlesoftware/article/details/7311352#t13

 

 

 

 

 

 

 

 

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

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

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

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

QQ:642808185 註明:ITPUB的文章標題

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

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

 

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

相關文章