Oracle备份恢复的方法有哪些
这篇“Oracle备份恢复的方法有哪些”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“Oracle备份恢复的方法有哪些”文章吧。
成都创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站建设、网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的合肥网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
一、不同场景在满足不同的条件时的恢复方法:
二、针对不同的恢复方法给出具体的恢复思路:
2.1、通过重新拷贝冗余的控制文件
1、在线或者关闭数据库后损坏了其中部分控制文件;
2、shutdown abort关闭数据库;
3、拷贝其中一个完好的控制文件;
4、startup启动数据库。
2.2、 通过备份控制文件进行完全恢复
1、在线或者关闭数据库后损坏了所有控制文件;
2、shutdown abort关闭数据库;
3、startup nomount启动数据库;
4、restore controlfile from ‘xxx’;从备份中还原控制文件;
5、alter database mount;
5、recover database using backup controlfile until cancel,在执行时选择auto自动应用所有的归档文件;
6、再次执行recover database using backup controlfile until cancel,选择应用未归档的redo文件;
7、alter database open resetlogs;
2.3、通过备份控制文件进行不完全恢复
1、在线或者关闭数据库后损坏了所有控制文件;
2、shutdown abort关闭数据库;
3、startup nomount启动数据库;
4、restore controlfile from ‘xxx’;从备份中还原控制文件;
5、alter database mount;
6、recover database using backup controlfile until cancel,在执行时选择auto自动应用尽可能多的归档文件;
7、alter database open resetlogs;
2.4、通过备份控制文件进行重建的恢复(noresetlogs方式)
1、在线或者关闭数据库后损坏了所有控制文件;
2、shutdown abort关闭数据库;
3、startup nomount启动数据库;
4、restore controlfile from ‘xxx’;从备份中还原控制文件;
5、alter database mount;
6、alter database backup controlfile to trace,生成创建控制文件的脚本;
7、shutdown immediate并启动到startup nomount状态;
8、使用noresetlogs方式创建控制文件;
9、recover database恢复数据库;
10、恢复完后通过alter database open打开数据库;
2.5、通过备份控制文件进行重建的恢复(resetlogs方式)
1、在线或者关闭数据库后损坏了所有控制文件;
2、shutdown abort关闭数据库;
3、startup nomount启动数据库;
4、restore controlfile from ‘xxx’;从备份中还原控制文件;
5、alter database mount;
6、alter database backup controlfile to trace,生成创建控制文件的脚本;
7、shutdown immediate并启动到startup nomount状态
8、使用resetlogs方式创建控制文件;
9、如果未归档的redo文件可用时,则直接recover database,然后选用未归档的redo文件应用,
最后通过alter database open resetlogs方式打开数据库。
10、如果未归档的redo文件不可用时,则需要设置隐含参数_allow_resetlogs_corruption为true跳
过一致性检查,最后用alter database open resetlogs方式打开数据库。
注:打开数据库后很多情况下会出现需要推进scn的问题。
2.6、通过手工重建的控制文件进行恢复(noresetlogs方式)
1、在线或者关闭数据库后损坏了所有控制文件;
2、shutdown abort关闭数据库;
3、startup nomount启动数据库;
4、构造控制文件;
下面的步骤参考2.4的第八步;
2.7、通过手工重建的控制文件进行恢复(resetlogs方式)
1、在线或者关闭数据库后损坏了所有控制文件;
2、shutdown abort关闭数据库;
3、startup nomount启动数据库;
4、构造控制文件;
下面的步骤参考2.5的第八步;
三、模拟几种恢复方法的操作:
下面主要对这三种恢复方法(通过备份控制文件进行完全恢复、通过备份控制文件进行重建的恢复(noresetlogs方式)、通过备份控制文件进行重建的恢复(resetlogs方式))的操作模拟,因为其他的几种恢复方法要么比较简单要么跟这三种方法共通。
3.1、通过备份控制文件进行完全恢复
1、查看数据库基本信息和数据库状态 SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string leonliao SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /home/oracle/oradata/leonliao/ control01.ctl, /home/oracle/or adata/leonliao/control02.ctl SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE 2、备份控制文件 RMAN> backup current controlfile; 3、数据库在线时删除所有控制文件 [oracle@leon1 leonliao]$ rm -rf control0*ctl [oracle@leon1 leonliao]$ pwd /home/oracle/oradata/leonliao 4、无法正常关闭数据库只能shutdown abort SQL> shutdown immediate Database closed. ORA-00210: cannot open the specified control file ORA-00202: control file: '/home/oracle/oradata/leonliao/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> shutdown abort ORACLE instance shut down. SQL> 5、启动数据库到nomount状态并还原备份的控制文件 SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes RMAN> restore controlfile from '/u01/app/oracle/dbs/01qvmql3_1_1'; 6、将数据库启动到mount状态并开始恢复 SQL> alter database mount; Database altered. SQL> SQL> SQL> recover database using backup controlfile until cancel; ORA-00279: change 1181770 generated at 03/05/2016 05:02:58 needed for thread 1 ORA-00289: suggestion : /home/oracle/oradata/leonliao/arch/1_6_905662043.dbf ORA-00280: change 1181770 for thread 1 is in sequence #6 Specify log: { auto <<<<<选择auto,自动应用所有的归档文件 ORA-00308: cannot open archived log '/home/oracle/oradata/leonliao/arch/1_6_905662043.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 ORA-00308: cannot open archived log '/home/oracle/oradata/leonliao/arch/1_6_905662043.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/home/oracle/oradata/leonliao/system01.dbf' SQL> recover database using backup controlfile until cancel; <<<<<由于未归档的redo文件需要手动应用 ORA-00279: change 1181770 generated at 03/05/2016 05:02:58 needed for thread 1 ORA-00289: suggestion : /home/oracle/oradata/leonliao/arch/1_6_905662043.dbf ORA-00280: change 1181770 for thread 1 is in sequence #6 Specify log: { /home/oracle/oradata/leonliao/redo03.log <<<<<在关闭数据库前可以查看当前current的redo文件是哪一个,不清楚可以一个个应用直到提示Log applied为止 Log applied. Media recovery complete. 7、以open resetlogs方式打开数据库 SQL> alter database open resetlogs; Database altered. SQL> SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE |
3.2、通过备份控制文件进行重建的恢复(noresetlogs方式)
1、查看数据库基本信息和数据库状态 SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string leonliao SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /home/oracle/oradata/leonliao/ control01.ctl, /home/oracle/or adata/leonliao/control02.ctl SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE 2、备份控制文件 RMAN> backup current controlfile; 3、数据库在线时删除所有控制文件 [oracle@leon1 leonliao]$ rm -rf control0*ctl [oracle@leon1 leonliao]$ pwd /home/oracle/oradata/leonliao 4、无法正常关闭数据库只能shutdown abort SQL> shutdown immediate Database closed. ORA-00210: cannot open the specified control file ORA-00202: control file: '/home/oracle/oradata/leonliao/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> shutdown abort ORACLE instance shut down. SQL> 5、启动数据库到nomount状态并还原备份的控制文件 SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes RMAN> restore controlfile from '/u01/app/oracle/dbs/03qvmrqj_1_1'; 6、将数据库启动到mount状态并生成创建控制文件的脚本 SQL> alter database mount; Database altered. SQL> alter database backup controlfile to trace; Database altered. 7、shutdown immediate并启动到startup nomount状态创建控制文件 SQL> shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes SQL> CREATE CONTROLFILE REUSE DATABASE "LEONLIAO" NORESETLOGS ARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/home/oracle/oradata/leonliao/redo01.log' SIZE 50M BLOCKSIZE 512, 9 GROUP 2 '/home/oracle/oradata/leonliao/redo02.log' SIZE 50M BLOCKSIZE 512, 10 GROUP 3 '/home/oracle/oradata/leonliao/redo03.log' SIZE 50M BLOCKSIZE 512 11 -- STANDBY LOGFILE 12 DATAFILE 13 '/home/oracle/oradata/leonliao/system01.dbf', 14 '/home/oracle/oradata/leonliao/sysaux01.dbf', 15 '/home/oracle/oradata/leonliao/undotbs01.dbf', 16 '/home/oracle/oradata/leonliao/users01.dbf' 17 CHARACTER SET ZHS16GBK 18 ; Control file created. 8、开始恢复 SQL> recover database; ORA-00283: recovery session canceled due to errors ORA-00264: no recovery required 9、以open方式打开数据库 SQL> alter database open; Database altered. SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE |
3.3、通过备份控制文件进行重建的恢复(resetlogs方式)
1、查看数据库基本信息和数据库状态 SQL> show parameter db_name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_name string leonliao SQL> show parameter control_files NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_files string /home/oracle/oradata/leonliao/ control01.ctl, /home/oracle/or adata/leonliao/control02.ctl SQL> select * from v$logfile; GROUP# STATUS TYPE MEMBER IS_ ---------- ------- ------- -------------------------------------------------- --- 1 ONLINE /home/oracle/oradata/leonliao/redo01.log NO 3 ONLINE /home/oracle/oradata/leonliao/redo03.log NO 2 ONLINE /home/oracle/oradata/leonliao/redo02.log NO SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE 2、备份控制文件 RMAN> backup current controlfile; 3、数据库在线时删除所有控制文件和redo文件 [oracle@leon1 leonliao]$ rm -rf control0*ctl [oracle@leon1 leonliao]$ rm -rf redo0*log [oracle@leon1 leonliao]$ pwd /home/oracle/oradata/leonliao 4、无法正常关闭数据库只能shutdown abort SQL> shutdown immediate Database closed. ORA-00210: cannot open the specified control file ORA-00202: control file: '/home/oracle/oradata/leonliao/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> shutdown abort ORACLE instance shut down. SQL> 5、启动数据库到nomount状态并还原备份的控制文件 SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes RMAN> restore controlfile from '/u01/app/oracle/dbs/01qvmtbj_1_1'; 6、将数据库启动到mount状态并生成创建控制文件的脚本 SQL> alter database mount; Database altered. SQL> alter database backup controlfile to trace; Database altered. 7、shutdown immediate并启动到startup nomount状态创建resetlogs的控制文件 SQL> shutdown immediate ORA-01109: database not open Database dismounted. ORACLE instance shut down. SQL> startup nomount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes SQL> CREATE CONTROLFILE REUSE DATABASE "LEONLIAO" RESETLOGS ARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/home/oracle/oradata/leonliao/redo01.log' SIZE 50M BLOCKSIZE 512, 9 GROUP 2 '/home/oracle/oradata/leonliao/redo02.log' SIZE 50M BLOCKSIZE 512, 10 GROUP 3 '/home/oracle/oradata/leonliao/redo03.log' SIZE 50M BLOCKSIZE 512 11 -- STANDBY LOGFILE 12 DATAFILE 13 '/home/oracle/oradata/leonliao/system01.dbf', 14 '/home/oracle/oradata/leonliao/sysaux01.dbf', 15 '/home/oracle/oradata/leonliao/undotbs01.dbf', 16 '/home/oracle/oradata/leonliao/users01.dbf' 17 CHARACTER SET ZHS16GBK 18 ; Control file created. 8、因为所有redo文件都删除了,无法恢复,所以会出现一致性的问题,通过设置隐含参数_allow_resetlogs_corruption为true跳过一致性检查; 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 626327552 bytes Fixed Size 2230952 bytes Variable Size 184550744 bytes Database Buffers 432013312 bytes Redo Buffers 7532544 bytes Database mounted. 9、以open resetlogs方式打开数据库 SQL> alter database open resetlogs; Database altered. SQL> select open_mode from v$database; OPEN_MODE -------------------- READ WRITE |
以上就是关于“Oracle备份恢复的方法有哪些”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注创新互联行业资讯频道。
网站名称:Oracle备份恢复的方法有哪些
当前URL:http://azwzsj.com/article/jejdpj.html