只需这10步,通过历史控制文件恢复数据库

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号

--可以看到数据文件头中记录的scn(18504054)大于控制文件中记录的scn(18261588)


SYS@enmo>set line 999
SYS@enmo>col name for a50
SYS@enmo>select status from v$instance;


STATUS
------------------------------------
MOUNTED


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


CHECKPOINT_CHANGE#
------------------
          18261588


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


NAME                                               CHECKPOINT_CHANGE#
-------------------------------------------------- ------------------
/u01/app/dbfile/enmo/system01.dbf                            18261588
/u01/app/dbfile/enmo/sysaux01.dbf           
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值