oracle控制文件生成_如何通过历史控制文件恢复Oracle数据库?

4d845b2e1f1005b85b3eb72b844d4b76.png

1.记录控制文件、数据文件头的scn

SYS@enmo>select checkpoint_change# from v$database;

CHECKPOINT_CHANGE#
------------------
          18502624

SYS@enmo>select name,checkpoint_change# from v$datafile;

NAME                                               CHECKPOINT_CHANGE#
-------------------------------------------------- ------------------
/u01/app/dbfile/enmo/system01.dbf                            18502624
/u01/app/dbfile/enmo/sysaux01.dbf                            18502624
/u01/app/dbfile/enmo/undotbs1.dbf                            18502624
/u01/app/dbfile/enmo/users01.dbf                             18502624
/u01/app/dbfile/enmo/chang01.dbf                             18502624
/u01/app/dbfile/enmo/lob_data01.dbf                          18502624
/u01/app/dbfile/enmo/oggdata.dbf                             18502624
/u01/app/dbfile/reccat.dbf                                   18502624

8 rows selected.

SYS@enmo>select name,checkpoint_change# from v$datafile_header;

NAME                                               CHECKPOINT_CHANGE#
-------------------------------------------------- ------------------
/u01/app/dbfile/enmo/system01.dbf                            18502624
/u01/app/dbfile/enmo/sysaux01.dbf                            18502624
/u01/app/dbfile/enmo/undotbs1.dbf                            18502624
/u01/app/dbfile/enmo/users01.dbf                             18502624
/u01/app/dbfile/enmo/chang01.dbf                             18502624
/u01/app/dbfile/enmo/lob_data01.dbf                          18502624
/u01/app/dbfile/enmo/oggdata.dbf                             18502624
/u01/app/dbfile/reccat.dbf                                   18502624

8 rows selected.


--正常运行时last_change#的值就是空

SYS@enmo>select name,last_change# from v$datafile;

NAME                                               LAST_CHANGE#
-------------------------------------------------- ------------
/u01/app/dbfile/enmo/system01.dbf
/u01/app/dbfile/enmo/sysaux01.dbf
/u01/app/dbfile/enmo/undotbs1.dbf
/u01/app/dbfile/enmo/users01.dbf
/u01/app/dbfile/enmo/chang01.dbf
/u01/app/dbfile/enmo/lob_data01.dbf
/u01/app/dbfile/enmo/oggdata.dbf
/u01/app/dbfile/reccat.dbf

8 rows selected.

2.关闭数据库并移动控制文件

SYS@enmo>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


[oracle@ora:enmo enmo]$mv control01.ctl control01.ctl.bak
[oracle@ora:enmo enmo]$mv control02.ctl control02.ctl.bak

3.开启数据库到nomount;

SYS@enmo>startup nomount;
ORACLE instance started.

Total System Global Area 1048576000 bytes
Fixed Size                  8628640 bytes
Variable Size             796919392 bytes
Database Buffers          234881024 bytes
Redo Buffers                8146944 bytes
SYS@enmo>select status from v$instance;

STATUS
------------------------------------
STARTED

4.使用rman恢复历史备份的控制文件

RMAN> restore controlfile from autobackup;

Starting restore at 2020-03-13 12:51:11 

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK

recovery area destination: /u01/app/fra
database name (or database unique name) used for search: ENMO
channel ORA_DISK_1: AUTOBACKUP /u01/app/fra/ENMO/autobackup/2020_03_10/o1_mf_s_1034681351_h6g2d7x3_.bkp found in the recovery area
AUTOBACKUP search with format "%F" not attempted because DBID was not set
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/fra/ENMO/autobackup/2020_03_10/o1_mf_s_1034681351_h6g2d7x3_.bkp
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/dbfile/enmo/control01.ctl
output file name=/u01/app/dbfile/enmo/control02.ctl
Finished restore at 2020-03-13 12:51:13

5.更新数据库到mount

SYS@enmo>alter database mount;

Database altered.

6.查看控制文件和数据文件中的scn号

...

✨ 接下来内容请点击【原文】进行查看~

更多数据库相关内容,可访问【墨天轮】进行浏览。

4e7fac243d6b94a531ddc520d33e5dff.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值