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号
...
✨ 接下来内容请点击【原文】进行查看~
更多数据库相关内容,可访问【墨天轮】进行浏览。