标签云
asm恢复 bbed bootstrap$ dul In Memory kcbzib_kcrsds_1 kccpb_sanity_check_2 kfed MySQL恢复 ORA-00312 ORA-00607 ORA-00704 ORA-01110 ORA-01555 ORA-01578 ORA-08103 ORA-600 2131 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 Oracle 恢复 ORACLE恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (102)
- 数据库 (1,671)
- DB2 (22)
- MySQL (73)
- Oracle (1,533)
- Data Guard (52)
- EXADATA (8)
- GoldenGate (21)
- ORA-xxxxx (159)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (14)
- ORACLE 21C (3)
- Oracle 23ai (7)
- Oracle ASM (65)
- Oracle Bug (8)
- Oracle RAC (52)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (28)
- Oracle备份恢复 (560)
- Oracle安装升级 (92)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (78)
- PostgreSQL (18)
- PostgreSQL恢复 (6)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (37)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (20)
-
最近发表
- Kylin Linux 安装19c
- ORA-600 krse_arc_complete.4
- Oracle 19c 202410补丁(RUs+OJVM)
- ntfs MFT损坏(ntfs文件系统故障)导致oracle异常恢复
- .mkp扩展名oracle数据文件加密恢复
- 清空redo,导致ORA-27048: skgfifi: file header information is invalid
- A_H_README_TO_RECOVER勒索恢复
- 通过alert日志分析客户自行对一个数据库恢复的来龙去脉和点评
- ORA-12514: TNS: 监听进程不能解析在连接描述符中给出的SERVICE_NAME
- ORA-01092 ORA-00604 ORA-01558故障处理
- ORA-65088: database open should be retried
- Oracle 19c异常恢复—ORA-01209/ORA-65088
- ORA-600 16703故障再现
- 数据库启动报ORA-27102 OSD-00026 O/S-Error: (OS 1455)
- .[metro777@cock.li].Elbie勒索病毒加密数据库恢复
- 应用连接错误,初始化mysql数据库恢复
- RAC默认服务配置优先节点
- Oracle 19c RAC 替换私网操作
- 监听报TNS-12541 TNS-12560 TNS-00511错误
- drop tablespace xxx including contents恢复
标签归档:WRONG FILE CREATE
数据文件的三个创建SCN一点点探讨
在给一个朋友数据库恢复的过程中语句该库大量删除表空间,然后创建表空,由于在创建控制文件的时候,列出来不正确文件,导致出现v$datafile_header.error出现WRONG FILE CREATE错误.通过试验重现了该错误,并且进一步测试如果真的需要历史数据文件,该如何狸猫换太子(本实验为了进一步理解数据文件创建scn相关信息)
创建xifenfei表空间,然后删除表空间,但不删除数据文件,然后创建重名表空间
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') today,'www.xifenfei.com' xifenfei from dual; TODAY XIFENFEI ------------------- ---------------- 2014-07-16 15:54:26 www.xifenfei.com SQL> create tablespace xifenfei datafile '/u01/app/oracle/oradata/ORCL/xifenfei_old.dbf' size 10m; Tablespace created. SQL> select file#,name from v$datafile; FILE# NAME ---------- -------------------------------------------------- 1 /u01/app/oracle/oradata/ORCL/system01.dbf 2 /u01/app/oracle/oradata/ORCL/sysaux01.dbf 3 /u01/app/oracle/oradata/ORCL/undotbs01.dbf 4 /u01/app/oracle/oradata/ORCL/users01.dbf 5 /u01/app/oracle/oradata/ORCL/xifenfei_old.dbf SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593520 2014-07-16 16:00:54 SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile_header; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593520 2014-07-16 16:00:54 SQL> drop tablespace xifenfei; Tablespace dropped. SQL> create tablespace xifenfei datafile '/u01/app/oracle/oradata/ORCL/xifenfei_new.dbf' size 10m; Tablespace created. SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593613 2014-07-16 16:02:45 SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile_header; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593613 2014-07-16 16:02:45
rename xifenfei表空间数据文件到老数据文件
SQL> alter database datafile 5 offline drop; Database altered. SQL> alter database rename file '/u01/app/oracle/oradata/ORCL/xifenfei_new.dbf' 2 to '/u01/app/oracle/oradata/ORCL/xifenfei_old.dbf'; Database altered. SQL> alter database datafile 5 online; alter database datafile 5 online * ERROR at line 1: ORA-01122: database file 5 failed verification check ORA-01110: data file 5: '/u01/app/oracle/oradata/ORCL/xifenfei_old.dbf' ORA-01203: wrong incarnation of this file - wrong creation SCN SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593613 2014-07-16 16:02:45 SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile_header; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593520 2014-07-16 16:00:54 SQL> select file#,error from v$datafile_header; FILE# ERROR ---------- ----------------------------------------------------------------- 1 2 3 4 5 WRONG FILE CREATE
至此今天数据库恢复的故障已经模拟出来,就是因为数据文件头的scn和控制文件中scn不一致,从而出现了v$datafile_header.error报WRONG FILE CREATE的现象.
因为控制文件中数据文件scn和数据文件头scn不一致,因此通过重建控制文件来实现两者scn一致
SQL> alter database backup controlfile to trace as '/tmp/ctl'; Database altered. SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> STARTUP NOMOUNT ORACLE instance started. Total System Global Area 718225408 bytes Fixed Size 2292432 bytes Variable Size 373294384 bytes Database Buffers 339738624 bytes Redo Buffers 2899968 bytes SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/u01/app/oracle/oradata/ORCL/redo01.log' SIZE 50M BLOCKSIZE 512, 9 GROUP 2 '/u01/app/oracle/oradata/ORCL/redo02.log' SIZE 50M BLOCKSIZE 512, 10 GROUP 3 '/u01/app/oracle/oradata/ORCL/redo03.log' SIZE 50M BLOCKSIZE 512 11 DATAFILE 12 '/u01/app/oracle/oradata/ORCL/system01.dbf', 13 '/u01/app/oracle/oradata/ORCL/sysaux01.dbf', 14 '/u01/app/oracle/oradata/ORCL/undotbs01.dbf', 15 '/u01/app/oracle/oradata/ORCL/users01.dbf', 16 '/u01/app/oracle/oradata/ORCL/xifenfei_old.dbf' 17 CHARACTER SET ZHS16GBK 18 ; Control file created. SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile_header; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593520 2014-07-16 16:00:54 SQL> select file#,CREATION_CHANGE#,to_char(CREATION_TIME,'yyyy-mm-dd hh24:mi:ss') CREATION_TIME from v$datafile; FILE# CREATION_CHANGE# CREATION_TIME ---------- ---------------- ------------------- 1 18 2014-07-14 21:53:05 2 2338 2014-07-14 21:53:42 3 3130 2014-07-14 21:53:51 4 15268 2014-07-14 21:54:25 5 593520 2014-07-16 16:00:54 SQL> select file#,error from v$datafile_header; FILE# ERROR ---------- ----------------------------------------------------------------- 1 2 3 4 5
通过重建控制文件消除了v$datafile_header.error报WRONG FILE CREATE错误,继续尝试online文件
SQL> recover datafile 5; Media recovery complete. SQL> alter database datafile 5 online; Database altered. SQL> select file#,name from v$datafile; FILE# NAME ---------- -------------------------------------------------- 1 /u01/app/oracle/oradata/ORCL/system01.dbf 2 /u01/app/oracle/oradata/ORCL/sysaux01.dbf 3 /u01/app/oracle/oradata/ORCL/undotbs01.dbf 4 /u01/app/oracle/oradata/ORCL/users01.dbf 5 /u01/app/oracle/oradata/ORCL/xifenfei_old.dbf SQL> alter database open; ORA-01092: ORACLE instance terminated. Disconnection forced ORA-01177: data file does not match dictionary - probably old incarnation ORA-01110: data file 5: '/u01/app/oracle/oradata/ORCL/xifenfei_old.dbf' Process ID: 7437 Session ID: 7 Serial number: 5
出现这个错误,是由于数据库中,还有file$中也记录了数据文件创建scn,而这个scn现在和数据文件头和控制文件中的scn不相等,因此无法启动数据库成功.现在需要做的就是在数据库未启动状态下修改file$中的数据文件创建scn相关值,让其和数据文件头(控制文件中记录)一致
使用第三方工具定位file$记录
1|2|89600|0|1|4194302|1280|0|18||4194306|0x004000e9|0 2|2|70400|1|2|4194302|1280|0|2338||8388610|0x004000e9|1 3|2|25600|2|3|4194302|640|0|3130||12582914|0x004000e9|2 4|2|640|4|4|4194302|160|0|15268||16777218|0x004000e9|3 5|2|1280|7|5|0|0|0|593613||20971522|0x004000e9|4 6|1|3840|||0|0|0|586295||25165826|0x004000e9|5 7|1|3840|||3932160|1280|0|587030||29360130|0x004000e9|6 对应file$结构确定每列含义,以及确定需要修改的列 每行倒数第二列为rdba地址,可以通过转换为file and block,这里对应的就是file 1 block 233 每行最后一列为该条记录在该rdba中的记录顺序
使用工具修改593613为593520,使得file$中的scn与现在控制文件和数据文件头一致,具体参考bbed修改数据内容
修改好file$中数据文件创建scn后,尝试继续操作
SQL> alter database open; alter database open * ERROR at line 1: ORA-01113: file 5 needs media recovery ORA-01110: data file 5: '/u01/app/oracle/oradata/ORCL/xifenfei_old.dbf' SQL> recover datafile 5; Media recovery complete. SQL> alter database open; Database altered. SQL> select file#,name from v$datafile; FILE# NAME ---------- -------------------------------------------------- 1 /u01/app/oracle/oradata/ORCL/system01.dbf 2 /u01/app/oracle/oradata/ORCL/sysaux01.dbf 3 /u01/app/oracle/oradata/ORCL/undotbs01.dbf 4 /u01/app/oracle/oradata/ORCL/users01.dbf 5 /u01/app/oracle/oradata/ORCL/xifenfei_old.dbf
通过这里的简单测试,发现几个问题
1.v$datafile_header.error报WRONG FILE CREATE错误 不一定就是数据文件异常,而其本质是数据文件头scn和控制文件中scn不一致
2.数据文件online需要file$,v$datafile_header,v$datafile中关于数据文件创建scn都一致
3.通过该分析,证明在一些极端情况下,考虑考虑该替换思路实现删除数据文件重新加入数据库