共计 9494 个字符,预计需要花费 24 分钟才能阅读完成。
源库: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、在目标库,安装好相同版本的 O racle 数据库,创建同名实例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,测试恢复数据。实践出真知啊!!!!
更多 Oracle 相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-06/132289.htm