一 Oracle是如何判断控制文件的新旧
1 正常情况下
如下所示:
SQL> select controlfile_type,controlfile_sequence#,controlfile_change#,checkpoint_change# from v$database;
CONTROL CONTROLFILE_SEQUENCE# CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------- --------------------- ------------------- ------------------
CURRENT 16344 2781355383 2781355383
SQL> select hxfil,fhcsq,fhscn,fhrba_seq from x$kcvfh;
hxfil :数据文件编号
fhcsq:数据文件头部记录的控制文件seq号
fhscn:数据文件头部的scn号
fhrba_seq:数据文件头部rba地址中的日志序列号
HXFIL FHCSQ FHSCN FHRBA_SEQ
---------- ---------- ---------------- ----------
1 16343 2781355383 22
2 16343 2781355383 22
3 16343 2781355383 22
4 16343 2781355383 22
5 16343 2781355383 22
6 16343 2781355383 22
7 16343 2781355383 22
8 16343 2781355383 22
11 16343 2781355383 22
12 16343 2781355383 22
13 16343 2781355383 22
11 rows selected.
推荐阅读:
Oracle用老的控制文件备份恢复新建的数据文件
2 用旧控制文件恢复后的情况如下:
RMAN> restore controlfile from '/oracle/app/db1/dbs/01nve87c_1_1';
Starting restore at 14-JAN-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=211 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/oracle/CRM2/CRM/control01.ctl
output filename=/oracle/CRM2/CRM/control02.ctl
Finished restore at 14-JAN-13
SQL> select controlfile_type,controlfile_sequence#,controlfile_change#,checkpoint_change# from v$database;
CONTROL CONTROLFILE_SEQUENCE# CONTROLFILE_CHANGE# CHECKPOINT_CHANGE#
------- --------------------- ------------------- ------------------
BACKUP 16294 2781355207 2781347284
SQL> select hxfil,fhcsq,fhscn,fhrba_seq from x$kcvfh;
HXFIL FHCSQ FHSCN FHRBA_SEQ
---------- ---------- ---------------- ----------
1 16343 2781355383 22
2 16343 2781355383 22
3 16343 2781355383 22
4 16343 2781355383 22
5 16343 2781355383 22
6 16343 2781355383 22
7 16343 2781355383 22
8 16343 2781355383 22
11 16343 2781355383 22
12 16343 2781355383 22
13 16343 2781355383 22
3 用旧备份控制文件恢复后数据库应该注意两点
a 联机日志序号倒退
SQL> select group#,archived,sequence#,status from v$log;
GROUP# ARC SEQUENCE# STATUS
---------- --- ---------- ----------------
1 YES 8 INACTIVE
2 NO 9 CURRENT
6 YES 6 INACTIVE
4 YES 7 INACTIVE
5 YES 5 INACTIVE
3 YES 4 INACTIVE
6 rows selected.
b 控制文件头部标记该控制文件为备份控制文件
DUMP OF CONTROL FILES, Seq # 16296 = 0x3fa8
V10 STYLE FILE HEADER:
Compatibility Vsn = 169869568=0xa200100
Db ID=3601019238=0xd6a33166, Db Name='CRM'
Activation ID=0=0x0
Control Seq=16296=0x3fa8, File size=450=0x1c2
File Number=0, Blksiz=16384, File Type=4 BACKUP CONTROL