直播通过rman将oracle 12c整库全备后进行异机同目录恢复遇到的小坑

来源:互联网 发布:js放大镜效果代码 编辑:程序博客网 时间:2024/05/30 02:24

参考自:http://blog.itpub.net/26506993/viewspace-1873417/

挖坑流程:

1、源库rman全备(备份的过程请自行查阅我另一篇blog)

2、在目标库(要在哪台服务器恢复?)安装好同版本的oracle数据库软件,我这里是12.2.0.1.0,不用建库!不用建库!不同建库!真的不用。。。

3、在目标库创建好与源库一样的目录结构,如果不清楚,可以在源库创建pfile查看。(否则,嘿嘿,有你烦的~)

4、将备份好的备份集(就是备份得到的一坨~~~)传送到目标端(不要告诉我你没用过scp哈!)

5、在目标库export ORACLE_SID=SID(如果你的oracle用户环境变量中设置了,请飘过~)

6、在目标库执行rman target /

7、这时,你可以先大肆地进行参数,例如,执行list backup of database;,然后看看结果是否和你臆想的一样?思考下why?

8、在目标库执行startup nomount;

9、咦?居然Oracle instance started???纳尼?为什么没参数文件都可以启动?什么鬼?db_name=DUMMY是什么情况?

10、下面开始进坑:

首先是恢复参数文件:

(下边这个run代码块我也是拿来主义的,里边有坑,先不说,君请继续往下看)

RMAN> RUN

2> {
3>   ALLOCATE CHANNEL c1 DEVICE TYPE disk;
4>   SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';
5>   RESTORE SPFILE 
6>     TO PFILE '/u01/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora' 
7>     FROM AUTOBACKUP;
8>   SHUTDOWN ABORT;
9> }


released channel: ORA_DISK_1
allocated channel: c1
channel c1: SID=2853 device type=DISK


executing command: SET CONTROLFILE AUTOBACKUP FORMAT


Starting restore at 22-DEC-17


AUTOBACKUP search with format "/u01/backup/%F" not attempted because DBID was not set
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:09:21
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> 

好了,很明显的提示,DBID was not set,那就满足它:



RMAN> SET DBID 1489393547;


executing command: SET DBID


RMAN> 


she好后,我们继续:


RMAN> RUN
2> {
3>   ALLOCATE CHANNEL c1 DEVICE TYPE disk;
4>   SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';
5>   RESTORE SPFILE 
6>     TO PFILE '/u01/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora' 
7>     FROM AUTOBACKUP;
8>   SHUTDOWN ABORT;
9> }


allocated channel: c1
channel c1: SID=2853 device type=DISK


executing command: SET CONTROLFILE AUTOBACKUP FORMAT


Starting restore at 22-DEC-17


channel c1: looking for AUTOBACKUP on day: 20171222
channel c1: looking for AUTOBACKUP on day: 20171221
channel c1: looking for AUTOBACKUP on day: 20171220
channel c1: looking for AUTOBACKUP on day: 20171219
channel c1: looking for AUTOBACKUP on day: 20171218
channel c1: looking for AUTOBACKUP on day: 20171217
channel c1: looking for AUTOBACKUP on day: 20171216
channel c1: no AUTOBACKUP in 7 days found
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:11:29
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> 


what?还报错?

RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece

什么情况?

这时,怎么办?你说怎么办?当然百度、谷歌什么的啦?没错,我也是这么搞的。

我还找到我可以理解的blog:https://www.cnblogs.com/pengineer/p/4558395.html

关键信息:

1、CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; 后面的default没有的,但是值还是不变

2、nomount状态下只能看到RMAN最原始的配置信息

再看看当前目标库的rman配置:


RMAN> show all;


RMAN configuration parameters for database with db_unique_name DUMMY are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
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 MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default


RMAN> 


RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';


executing command: SET CONTROLFILE AUTOBACKUP FORMAT


RMAN> 


RMAN> show all;  


RMAN configuration parameters for database with db_unique_name DUMMY are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
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 MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default


RMAN> 

这时,我想试试将路径改为/u01/backup/%,然并卵。。。


RMAN> 


RMAN> RUN
2> {
3>   ALLOCATE CHANNEL c1 DEVICE TYPE disk;
4>   SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backup/%F';
5>   RESTORE SPFILE 
6>     TO PFILE '/u01/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora' 
7>     FROM AUTOBACKUP;
8>   SHUTDOWN ABORT;
9> }


allocated channel: c1
channel c1: SID=2853 device type=DISK


executing command: SET CONTROLFILE AUTOBACKUP FORMAT


Starting restore at 22-DEC-17


channel c1: looking for AUTOBACKUP on day: 20171222
channel c1: looking for AUTOBACKUP on day: 20171221
channel c1: looking for AUTOBACKUP on day: 20171220
channel c1: looking for AUTOBACKUP on day: 20171219
channel c1: looking for AUTOBACKUP on day: 20171218
channel c1: looking for AUTOBACKUP on day: 20171217
channel c1: looking for AUTOBACKUP on day: 20171216
channel c1: no AUTOBACKUP in 7 days found
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:30:13
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> 


一直说RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece

我又百度了一轮。。。。。

网上说的基本都差不多,类似这篇http://blog.51cto.com/407882/282259

所以,与我遇到的并不一样。


此时,我的内心是崩溃的。。。


于是,想直接restore spfile from '';

把所有备份集都试:


RMAN> restore spfile from '/u01/backup/full_bk1_05smpp7p15.dfb';


Starting restore at 22-DEC-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2295 device type=DISK


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:34:24
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> 


RMAN> restore spfile from '/u01/backup/full_bk1_04smpp6m14.dfb;'

2> 
3> 


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "end-of-file": expecting one of: "allforeign, archivelog, as, backupset, channel, check, controlfile, database, database root, datafile, device, dump, farsync, file_name_convert, force, foreign, from, frompreplugin, from service, high, pluggable, preview, primary, section, skip readonly, spfile, standby, tablespace, to restore point, until restore point, until, using, validate, (, ;"
RMAN-01007: at line 4 column 1 file: standard input


RMAN> 


上边的命令都打错。。。


RMAN> restore spfile from '/u01/backup/full_bk1_04smpp6m14.dfb';


Starting restore at 22-DEC-17
using channel ORA_DISK_1


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:42:22
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> restore spfile from '/u01/backup/full_bk1_03smpp4113.dfb';


Starting restore at 22-DEC-17
using channel ORA_DISK_1


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:43:07
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> 


RMAN> restore spfile from '/u01/backup/full_bk1_02smpm3j12.dfb';


Starting restore at 22-DEC-17
using channel ORA_DISK_1


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:43:30
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> 



有人说,用CATALOG START WITH试试:


RMAN> CATALOG START WITH '/u01/backup';


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of catalog command at 12/22/2017 22:45:01
ORA-01507: database not mounted


RMAN> 


也是不行的。。。。


RMAN> restore spfile from '/u01/backup/full_bk1_05smpp7p15.dfb';


Starting restore at 22-DEC-17
using channel ORA_DISK_1


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/full_bk1_05smpp7p15.dfb
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:53:51
ORA-19687: SPFILE not found in backup set


RMAN> 


RMAN> restore spfile from '/u01/backup/full_bk1_04smpp6m14.dfb';


Starting restore at 22-DEC-17
using channel ORA_DISK_1


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/full_bk1_04smpp6m14.dfb
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:54:24
ORA-19687: SPFILE not found in backup set


RMAN> 


RMAN> restore spfile to '/u01/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora' from '/u01/app/oracle/recovery_area/ORCL/autobackup/2017_12_22/o1_mf_s_963437820_f3t2mwz5_.bkp';


Starting restore at 22-DEC-17
using channel ORA_DISK_1


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 22:55:20
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> 


可以看到,一直是无法找到备份或指定的是无效的备份集,明明是有的。

乱试了一番后,突然想到会不会是权限问题???
检查发现,从源库传过来用的是root用户,所有文件的所属者都是root,晕。。。

所以,执行:chown oracle:oinstall  /u01/backup/




RMAN> 


RMAN> restore spfile to '/u01/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora' from '/u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp';


Starting restore at 22-DEC-17
using channel ORA_DISK_1


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 22-DEC-17


RMAN> 

这里,各位看到有没有发现什么问题?

没有的话,继续往下看:


RMAN> 


RMAN> shutdown immediate;


Oracle instance shut down


RMAN> 


RMAN> startup nomount;


connected to target database (not started)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 12/22/2017 23:00:14
RMAN-04014: startup failed: ORA-01078: failure in processing system parameters
LRM-00123: invalid character 0 found in the input file


RMAN> 


这里居然报错,一开始我也不清楚原因,后来发现,是前边restore spfile to时少加了pfile,导致创建出来的pfile实际是spfile,spfile不是普通文本,当oracle找到pfile后发现有无效字符串(乱码),所以报错。。。


干脆直接还原spfile:
RMAN> restore spfile from '/u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp';


Starting restore at 22-DEC-17
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/22/2017 23:03:06
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3701
Additional information: -923528497


RMAN> 


将错误的pfile删除后重新启动实例:


RMAN> startup nomount;


startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora'


starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started


Total System Global Area    2147483648 bytes


Fixed Size                     8622776 bytes
Variable Size               1073745224 bytes
Database Buffers            1006632960 bytes
Redo Buffers                  58482688 bytes


RMAN> 

还原spfile:

RMAN> restore spfile from '/u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp';


Starting restore at 22-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2853 device type=DISK


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 22-DEC-17


RMAN> 

关闭实例,重启实例(因为已经有spfile了,oracle会找到它并用来启动实例)


RMAN> shutdown immediate;


Oracle instance shut down


RMAN> 


RMAN> startup nomount;


connected to target database (not started)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 12/22/2017 23:04:57
RMAN-04014: startup failed: ORA-09925: Unable to create audit trail file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9925

无法创建audit文件

ORA-09925问题参考http://www.dbdream.com.cn/2015/08/11/%E5%8F%88%E9%81%87ora-09925-unable-to-create-audit-trail-file/

原因是没创建好目录。

创建好目录后删除刚刚恢复的spfile,重新还原:


RMAN> startup nomount;


startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/12.2.0/db_1/dbs/initorcl.ora'


starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started


Total System Global Area    2147483648 bytes


Fixed Size                     8622776 bytes
Variable Size               1073745224 bytes
Database Buffers            1006632960 bytes
Redo Buffers                  58482688 bytes


RMAN> 

RMAN> 


RMAN> restore spfile from '/u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp';


Starting restore at 22-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2853 device type=DISK


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 22-DEC-17


RMAN> 


RMAN> 


RMAN> shutdown immediate;


Oracle instance shut down


RMAN> 


RMAN> 


RMAN> startup nomount;


connected to target database (not started)
Oracle instance started


Total System Global Area   10133438464 bytes


Fixed Size                    12342160 bytes
Variable Size               2348813424 bytes
Database Buffers            7717519360 bytes
Redo Buffers                  54763520 bytes


RMAN> 

终于成功了一半。。。哈哈


下面进行恢复控制文件:


RMAN> restore controlfile from '/u01/backup/o1_mf_s_963437820_f3t2mwz5_.bkp';


Starting restore at 22-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=57 device type=DISK


channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/recovery_area/orcl/control02.ctl
Finished restore at 22-DEC-17


RMAN> 


RMAN> alter database mount;


Statement processed
released channel: ORA_DISK_1


RMAN> 


RMAN> run{
2> restore database;
3> recover database;
4> }


Starting restore at 22-DEC-17
Starting implicit crosscheck backup at 22-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=379 device type=DISK
Crosschecked 6 objects
Finished implicit crosscheck backup at 22-DEC-17


Starting implicit crosscheck copy at 22-DEC-17
using channel ORA_DISK_1
Finished implicit crosscheck copy at 22-DEC-17


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 00009 to /u01/app/oracle/oradata/orcl/orclpdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/orcl/orclpdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/orcl/orclpdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/orcl/orclpdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00025 to /u01/app/oracle/oradata/orcl/orclpdb/V3XSPACE01.dbf
channel ORA_DISK_1: restoring datafile 00026 to /u01/app/oracle/oradata/orcl/orclpdb/TESTSPACE01.dbf
channel ORA_DISK_1: restoring datafile 00027 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_DATA0101.dbf
channel ORA_DISK_1: restoring datafile 00028 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_DATA0201.dbf
channel ORA_DISK_1: restoring datafile 00029 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_DATA0301.dbf
channel ORA_DISK_1: restoring datafile 00030 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_INDEX0101.dbf
channel ORA_DISK_1: restoring datafile 00031 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_INDEX0201.dbf
channel ORA_DISK_1: restoring datafile 00032 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_INDEX0301.dbf
channel ORA_DISK_1: restoring datafile 00033 to /u01/app/oracle/oradata/orcl/orclpdb/OAV60SPACE01.dbf
channel ORA_DISK_1: restoring datafile 00034 to /u01/app/oracle/oradata/orcl/orclpdb/OATEST01.dbf
channel ORA_DISK_1: restoring datafile 00035 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_DATA0102.dbf
channel ORA_DISK_1: restoring datafile 00036 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_DATA0103.dbf
channel ORA_DISK_1: restoring datafile 00037 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_DATA0104.dbf
channel ORA_DISK_1: restoring datafile 00038 to /u01/app/oracle/oradata/orcl/orclpdb/NNC_INDEX0102.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/full_bk1_02smpm3j12.dfb


现在还在恢复中。。。

原创粉丝点击