这篇文章将为大家详细讲解有关rman备份发生sysaux表空间丢失该怎么办,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
今天突发奇想,想玩一下rman这个命令,自己虚拟机好久都没有备份了,所以就来个全备,果不其然给了我一个报错。
RMAN> backup Starting backup at 20-OCT-16 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=134 device type=DISK RMAN-06169: could not read file header for datafile 2 error reason 1 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup command at 10/20/2016 05:19:19 RMAN-06056: could not access datafile 2
然后进入数据库开始查询为什么不能备份
SQL> select file#,name from v$datafile; FILE# ---------- NAME -------------------------------------------------------------------------------- 1 /u01/oracle/product/oradata/wrc/system01.dbf 2 /u01/oracle/product/11.2.0/db_1/dbs/MISSING00002 3 /u01/oracle/product/oradata/wrc/undotbs01.dbf FILE# ---------- NAME -------------------------------------------------------------------------------- 4 /u01/oracle/product/oradata/wrc/users01.dbf 5 /u01/oracle/product/11.2.0/db_1/dbs/MISSING00005 6 /u01/oracle/product/11.2.0/db_1/dbs/MISSING00006 6 rows selected. SQL> select TS#,name from v$tablespace; TS# NAME ---------- ------------------------------ 0 SYSTEM 2 UNDOTBS1 4 USERS 1 SYSAUX 3 TEMP 6 EXAMPLE 7 RMAN
发现这两个命令不能告诉我到底哪个表空间丢失了,后来上网查资料
SQL> select a.file#,a.name,b.name from v$datafile a,v$tablespace b where a.ts#=b.ts# 2 ; FILE# NAME NAME ---------- ------------------------------ ------------------------------ 1 /u01/oracle/product/oradata/wr SYSTEM c/system01.dbf 2 /u01/oracle/product/11.2.0/db_ SYSAUX 1/dbs/MISSING00002 3 /u01/oracle/product/oradata/wr UNDOTBS1 c/undotbs01.dbf 4 /u01/oracle/product/oradata/wr USERS c/users01.dbf FILE# NAME NAME ---------- ------------------------------ ------------------------------ 5 /u01/oracle/product/11.2.0/db_ EXAMPLE 1/dbs/MISSING00005 6 /u01/oracle/product/11.2.0/db_ RMAN 1/dbs/MISSING00006 6 rows selected.
一查询丢失三个文件,然后就开始想办法解决
rman这个表空间是最好删的,但是不要忘记删的时候要
including contents and datafiles
然后后来开始删除example这个表空间,这个显示有index以及关系所以不能删除,当时找了下确实有对象,删除所有对象再删除这个表空间应该也是可以的,最后到了sysaux这个表空间,sysaux这个表空间虽然是系统表空间,system表空间的辅助表空间,例如存放一些报告信息等,基本不会对性能有啥影像。
第一种方式
SQL> drop tablespace sysaux including contents and datafiles; drop tablespace sysaux including contents and datafiles * ERROR at line 1: ORA-13501: Cannot drop SYSAUX tablespace
第二种方式
SQL> alter database datafile 2 offline drop 2 ; Database altered. SQL> select a.file#,a.name,b.name from v$datafile a,v$tablespace b where a.ts#=b.ts#; FILE# ---------- NAME -------------------------------------------------------------------------------- NAME ------------------------------ 1 /u01/oracle/product/oradata/orcl/system01.dbf SYSTEM 2 /u01/oracle/product/oradata/orcl/sysaux01.dbf SYSAUX FILE# ---------- NAME -------------------------------------------------------------------------------- NAME ------------------------------ 3 /u01/oracle/product/oradata/orcl/undotbs01.dbf UNDOTBS1 4 /u01/oracle/product/oradata/orcl/users01.dbf FILE# ---------- NAME -------------------------------------------------------------------------------- NAME ------------------------------ USERS 5 /u01/oracle/product/oradata/orcl/example01.dbf EXAMPLE
可以看出来明显都是没有删掉的,这个时候开始思考这个sysaux是不是写入控制文件,所以你不管怎么删都是删不掉,后来就开始想通过初始化控制文件,看能不能成功。
先创建脚本
SELECT d.VALUE || '/' || LOWER (RTRIM (i.INSTANCE, CHR (0))) || '_ora_' || p.spid || '.trc' trace_file_name FROM (SELECT p.spid FROM v$mystat m, v$session s, v$process p WHERE m.statistic# = 1 AND s.SID = m.SID AND p.addr = s.paddr) p, (SELECT t.INSTANCE FROM v$thread t, v$parameter v WHERE v.NAME = 'thread' AND (v.VALUE = 0 OR t.thread# = TO_NUMBER (v.VALUE))) i, (SELECT VALUE FROM v$parameter WHERE NAME = 'user_dump_dest') d /
在Linux下执行该脚本
SQL> @gettrcname TRACE_FILE_NAME --------------------------------------------------------------------------------------------------- /opt/oracle/admin/eygle/udump/eygle_ora_8415.trc alter database backup controlfile to trace;
通过看这个eygle_ora_8415.trc文件,编辑重新创建控制文件
STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS noARCHIVELOG MAXLOGFILES 5 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 1 MAXLOGHISTORY 1168 LOGFILE GROUP 1 '/u01/oracle/product/oradata/wrc/redo01.log' SIZE 50M BLOCKSIZE 512, GROUP 2 '/u01/oracle/product/oradata/wrc/redo02.log' SIZE 50M BLOCKSIZE 512, GROUP 3 '/u01/oracle/product/oradata/wrc/redo03.log' SIZE 50M BLOCKSIZE 512, GROUP 4 '/u01/oracle/product/oradata/wrc/redo04.rdo' SIZE 50M BLOCKSIZE 512 -- STANDBY LOGFILE DATAFILE '/u01/oracle/product/oradata/wrc/system01.dbf', '/u01/oracle/product/11.2.0/db_1/dbs/sysaux02.dbf', '/u01/oracle/product/oradata/wrc/undotbs01.dbf', '/u01/oracle/product/oradata/wrc/users01.dbf', '/u01/oracle/product/11.2.0/db_1/dbs/sysaux03.dbf', '/u01/oracle/product/11.2.0/db_1/dbs/sysaux04.dbf' CHARACTER SET ZHS16GBK ;
进入sqlplus跑这个脚本,然后开始进行数据库的恢复,突然发现又来个错误
SQL> RECOVER DATABASE ORA-00283: recovery session canceled due to errors ORA-01610: recovery using the BACKUP CONTROLFILE option must be done SQL> alter database archivelog; Database altered.
1. recover database using backup controlfile
如果丢失当前控制文件,用冷备份的控制文件恢复的时候,用来告诉oracle,不要以controlfile中的scn作为恢复的终点;
2. recover database until cancel
如果丢失current/active redo的时候,手动指定终点。
3. recover database using backup controlfile until cancel;
如果丢失当前controlfile并且current/active redo都丢失,会先去自动应用归档日志,可以实现最大的恢复;
4. recover database until cancel using backup controlfile;
结果如下:
如果控制文件丢失,restore备份的控制文件后,则必须使用using backup controlfile选项。而until cancel则是不完全恢复,即current/active redo丢失,或者从restore数据库后某个归档文件缺失,则终止。
结论:
1、适用于restore旧的控制文件,且归档日志和cuurrent/active redo都没有丢失情况。如果一切归档日志和在线日志完好,可以不丢失数据。类似于recover database
2、当前控制文件未丢失(不需要restore旧的控制文件),此时有归档日志或者current/active log有丢失情况下,则终止。最大可能恢复数据
3、4:我在oracle 10.2.0.4环境下测试效果是相同的,即适用于restore旧的控制文件,在恢复到控制文件备份那刻后,系统会提示应用控制文件备份后的归档日志,如果没有则停止。也是最大可能的恢复数据。
SQL> alter database archivelog; Database altered. SQL> recover database using backup controlfile until cancel; ORA-00279: change 1995899 generated at 10/20/2016 07:46:55 needed for thread 1 ORA-00289: suggestion : /u01/oracle/product/flash_recovery_area/ORCL/archivelog/2016_10_20/o1_mf_1_47_%u _.arc ORA-00280: change 1995899 for thread 1 is in sequence #47 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} /u01/oracle/product/oradata/wrc/redo04.rdo ORA-00310: archived log contains sequence 45; sequence 47 required ORA-00334: archived log: '/u01/oracle/product/oradata/wrc/redo04.rdo' SQL> /u01/oracle/product/oradata/wrc/redo04.rdo SP2-0734: unknown command beginning "/u01/oracl..." - rest of line ignored. SQL> recover database using backup controlfile until cancel; ORA-00279: change 1995899 generated at 10/20/2016 07:46:55 needed for thread 1 ORA-00289: suggestion : /u01/oracle/product/flash_recovery_area/ORCL/archivelog/2016_10_20/o1_mf_1_47_%u _.arc ORA-00280: change 1995899 for thread 1 is in sequence #47 Specify log: {<RET>=suggested | filename | AUTO | CANCEL} /u01/oracle/product/oradata/wrc/redo03.log Log applied. Media recovery complete.
发现control file里面找不到sequence#47,然后只能一个一个redo日志的位置来试,最后成功了
SQL> alter database open; alter database open * ERROR at line 1: ORA-01589: must use RESETLOGS or NORESETLOGS option for database open SQL> alter database open resetlogs; Database altered.
最后开启数据库,需要制定是resetlogs还是noresetlogs模式下,但是发现还是不行,sysaux还是依旧存在,说明sysaux丢失是不能挽救的,需要重新创库。
关于rman备份发生sysaux表空间丢失该怎么办就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/203840.html