程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> 異機rman數據不完全恢復,rman數據

異機rman數據不完全恢復,rman數據

編輯:Oracle教程

異機rman數據不完全恢復,rman數據


源庫:Red Hat Enterprise Linux Server release 5.5 (Tikanga) 64bit +  ORACLE  V11.2.0.4.0 + DG + RAC

目標庫:Red Hat Enterprise Linux Server release 5.8 (Catthage) 64bit + ORACLE  V11.2.0.4.0

1、在目標庫,安裝好相同版本的oracle數據庫,創建同名實例orcl;

數據庫實例默認安裝路徑為:

/u01/app/oracle/oradata/orcl/…

 

2、查詢源庫數據文件路徑;

Select * from dba_data_files;

如下圖所示:數據文件路徑為+DATA/standby/datafile/…

3、拷貝源庫rman備份文件:

查看源rman備份腳本,內容如下:

run {
allocate channel t1 type disk;
sql 'alter system archive log current';
backup as compressed backupset database format='/mnt/rmanbackup/backup/db_%U';
backup current controlfile format='/mnt/rmanbackup/backup/ctl_%U';
crosscheck backupset;
crosscheck archivelog all;
delete expired backup;
delete noprompt obsolete;
delete archivelog all completed before 'sysdate-60';
delete archivelog until time 'sysdate-60';
delete  backupset completed before 'sysdate-1';
release channel t1;
}

備份路徑/mnt/rmanbackup/backup/下,找到備份文教拷貝。

4、在目標庫中創建相同的目錄,並拷貝以上rman備份數據;

 

5、根據源數據庫,數據存儲路徑制作rman恢復腳本

如下:

Rman>run

{

set newname for datafile 1 to '/u01/app/oracle/oradata/orcl/system.275.867195235';

set newname for datafile 2 to '/u01/app/oracle/oradata/orcl/sysaux.281.867195261';

set newname for datafile 3 to '/u01/app/oracle/oradata/orcl/undotbs1.283.867195263';

set newname for datafile 4 to '/u01/app/oracle/oradata/orcl/users.280.867195255';

set newname for datafile 5 to '/u01/app/oracle/oradata/orcl/undotbs2.290.867195331';

restore database;

switch datafile all;

}

/2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> 35> 36> 37> 38> 39> 40> 41> 42> 43> 44> 45> 46> 47> 48> 49> 50> 51> 52> 53> 54> 55> 56> 57> 58> 59> 60> 61> 62> 63> 64> 65>

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 12-JUN-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=134 device type=DISK

 

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

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

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

RMAN-03002: failure of restore command at 06/12/2016 17:26:18

RMAN-06026: some targets not found - aborting restore

RMAN-06023: no backup or copy of datafile 4 found to restore

RMAN-06023: no backup or copy of datafile 3 found to restore

RMAN-06023: no backup or copy of datafile 2 found to restore

RMAN-06023: no backup or copy of datafile 1 found to restore

6、在目標庫上恢復控制文件:

SQL>shutdown immediate

SQL>startup nomount

connected to target database (not started)

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2260088 bytes

Variable Size                671089544 bytes

Database Buffers             390070272 bytes

Redo Buffers                   5517312 bytes

------cmd

Rman target /

------Rman命令:

RMAN>restore controlfile from '/mnt/rmanbackup/backup/ctl_5er51tei_1_1';

Starting restore at 12-JUN-16

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:03

output file name=/u01/app/oracle/oradata/orcl/control01.ctl

output file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctl

Finished restore at 12-JUN-16

 

7、在目標庫上恢復數據文件,處理各種報錯問題:

注意:數據文件恢復完成後重啟數據庫過程中會遇到很多問題,以下是事後整理內容,多有不完善之處!!!

RMAN>alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN> run

{set newname for datafile 1 to '/u01/app/oracle/oradata/orcl/system.275.867195235';

set newname for datafile 2 to '/u01/app/oracle/oradata/orcl/sysaux.281.867195261';

set newname for datafile 3 to '/u01/app/oracle/oradata/orcl/undotbs1.283.867195263';

set newname for datafile 4 to '/u01/app/oracle/oradata/orcl/users.280.867195255';

set newname for datafile 5 to '/u01/app/oracle/oradata/orcl/undotbs2.290.867195331';

restore database;

switch datafile all;

}

/2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> 35> 36> 37> 38> 39> 40> 41> 42> 43> 44> 45> 46> 47> 48> 49> 50> 51> 52> 53> 54> 55> 56> 57> 58> 59> 60> 61> 62> 63>

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 12-JUN-16

Starting implicit crosscheck backup at 12-JUN-16

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

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

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

RMAN-03002: failure of restore command at 06/12/2016 17:48:42

RMAN-12010: automatic channel allocation initialization failed

RMAN-06189: current DBID 1442122161 does not match target mounted database (1318669939)

 

RMAN> shutdown immediate;

database dismounted

Oracle instance shut down

RMAN> startup nomount;

connected to target database (not started)

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2260088 bytes

Variable Size                671089544 bytes

Database Buffers             390070272 bytes

Redo Buffers                   5517312 bytes

 

RMAN> set dbid=1318669939

executing command: SET DBID

RMAN> alter database mount;

database mounted

RMAN> run

{set newname for datafile 1 to '/u01/app/oracle/oradata/orcl/system.275.867195235';

set newname for datafile 2 to '/u01/app/oracle/oradata/orcl/sysaux.281.867195261';

set newname for datafile 3 to '/u01/app/oracle/oradata/orcl/undotbs1.283.867195263';

set newname for datafile 4 to '/u01/app/oracle/oradata/orcl/users.280.867195255';

restore database;

switch datafile all;

}

/2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> 29> 30> 31> 32> 33> 34> 35> 36> 37> 38> 39> 40> 41> 42> 43> 44> 45> 46> 47> 48> 49> 50> 51> 52> 53> 54> 55> 56> 57> 58> 59> 60> 61> 62> 63>

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 12-JUN-16

Starting implicit crosscheck backup at 12-JUN-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=134 device type=DISK

Crosschecked 5 objects

Finished implicit crosscheck backup at 12-JUN-16

 

Starting implicit crosscheck copy at 12-JUN-16

using channel ORA_DISK_1

Finished implicit crosscheck copy at 12-JUN-16

 

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 00001 to /u01/app/oracle/oradata/orcl/system.275.867195235

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux.281.867195261

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs1.283.867195263

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users.280.867195255

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/undotbs2.290.867195331

channel ORA_DISK_1: reading from backup piece /mnt/rmanbackup/backup/db_5cr51m5e_1_1

 

RMAN> alter database open resetlogs;

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

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

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

RMAN-03002: failure of alter db command at 06/12/2016 22:42:40

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system.275.867195235'

RMAN> exit

Recovery Manager complete.

[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Sun Jun 12 22:48:23 2016

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

SQL> conn / as sysdba;

Connected.

SQL> alter system set "_allow_resetlogs_corruption"=true scope=spfile;

System altered.

SQL> shutdown immediate;

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 1068937216 bytes

Fixed Size                  2260088 bytes

Variable Size             671089544 bytes

Database Buffers          390070272 bytes

Redo Buffers                5517312 bytes

Database mounted.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-00349: failure obtaining block size for '+DATA/orcl/redo01.log'

SQL> SELECT GROUP#,SEQUENCE#,BYTES,MEMBERS,STATUS FROM V$LOG;

    GROUP#  SEQUENCE#      BYTES    MEMBERS STATUS

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

         1          0   52428800          1 CLEARING

         2          0   52428800          1 CLEARING

         3          0   52428800          1 CLEARING_CURRENT

         4          0   52428800          1 CLEARING

         5          0   52428800          1 CLEARING_CURRENT

         6          0   52428800          1 CLEARING

6 rows selected.

SQL> alter database drop logfile group 6;

Database altered.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-00392: log 3 of thread 1 is being cleared, operation not allowed

ORA-00312: online log 3 thread 1: '+DATA/orcl/redo03.log'

SQL> alter database clear logfile group 1;

alter database clear logfile group 1

*

ERROR at line 1:

ORA-00349: failure obtaining block size for '+DATA/orcl/redo01.log'

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

Database altered.

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

Database altered.

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

Database altered.

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-00392: log 3 of thread 1 is being cleared, operation not allowed

ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/orcl/redo03.log'

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 2;

Database altered.

SQL> ALTER DATABASE CLEAR LOGFILE GROUP 3;

Database altered.

SQL> alter database rename file '+DATA/orcl/redo05.log' to '/u01/app/oracle/oradata/orcl/redo05.log';

Database altered.

SQL> alter database clear logfile group 5;

Database altered.

SQL> alter database rename file '+DATA/orcl/redo04.log' to '/u01/app/oracle/oradata/orcl/redo04.log';

Database altered.

SQL> alter database clear logfile group 4;

Database altered.

SQL> select group#,bytes,status from v$log;

    GROUP#      BYTES STATUS

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

         1   52428800 UNUSED

         2   52428800 UNUSED

         3   52428800 CURRENT

         4   52428800 UNUSED

         5   52428800 CURRENT

 

以上是自己最近兩個星期做的一次數據庫rman恢復,自己實踐搭建linux環境,安裝oracle,測試恢復數據。實踐出真知啊!!!!

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved