Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching, Zero-Downtime Upgrade, GoldenGate

Oracle Exadata ,Oracle ODA, Oracle ZDLRA


当前位置: 首页 » 技术文章 » 内部原理

10g,11g,12c X$KCVFH(一)

KCVFH means Kernel Cache layer RecoVery component File Header

K    – Kernel layer
C    – Cache layer
V    – RecoVery component
FH   – File Header



Oracle Kernel System 

KA  Access Layer
KC  Cache Layer
KD  Data Layer
KG  Generic Layer
KJ  Lock Manager Layer
KK  Compilation Layer - Parse SQL, compile PL/SQL
KQ  Query Layer
KS  Services Layer
KT  Transaction Layer
KV  Kernel Variables (eg. x$KVIS and X$KVII)
KX  Execution Layer - Bind and execute SQL and PL/SQL
KZ  Security Layer - Validate privs
K2  Distributed Execution Layer - 2PC handling
NPI  Network Program Interface
ODS  Operating System Dependencies
OPI  Oracle Program Interface
RPI  Recursive Program Interface
S  Operating System Dependencies


X$KCVFH

Column Type Description
ADDR             RAW(8) Buffer Address
INDX             NUMBER Index Number
INST_ID          NUMBER Instance ID
CON_ID           NUMBER Con id
0: This value is used for rows containing data that pertain to the entire CDB.
1: This value is used for rows containing data that pertain to only the root
n: Where n is the applicable container ID for the rows containing data
This column is for 12c 
HXFIL            NUMBER File number(from control file)
HXONS            NUMBER File Status,online/offline,0 means offline
HXSTS            VARCHAR2(16) Stop Scn from Controlfile
HXERR            NUMBER NULL if the data file header read and validation were successful.
If the read failed then the rest of the columns are NULL.
If the validation failed then the rest of columns may display invalid data.
0, NULL,
1,'FIE MISSING',
2,'OFFLINE NORMAL',
3,'NOT VERIFIED',
4,'FILE NOT FOUND',
5,'CANNOT OPEN FILE',
6,'CANNOT READ HEADER',
7,'CORRUPT HEADER',
8,'WRONG FILE TYPE',
9,'WRONG DATABASE',
10,'WRONG FILE NUMBER',
11,'WRONG FILE CREATE',
12,'WRONG FILE CREATE',
16,'DELAYED OPEN',
14, 'WRONG RESETLOGS',
15,'OLD CONTROLFILE',
 'UNKNOWN ERROR'
HXVER            NUMBER File Header Version
6 - indicates Oracle Version 6
7 - indicates Oracle Version 7
8 - indicates Oracle Version 8
10 - indicates Oracle Version 10
0 - indicates the format could not be determined
(for example, the header could not be read)
FHSWV            NUMBER Software Version
FHCVN            NUMBER Compatiblility Version
FHDBI            NUMBER Database ID
FHDBN            VARCHAR2(9) Database Name
FHCSQ            NUMBER Control File Sequence)
FHFSZ            NUMBER Current data file size in bytes(file size)
FHBSZ            NUMBER Current data file size in blocks(block size)
FHFNO            NUMBER File number
FHTYP            NUMBER File type
1 control file,
2 redolog file,
3 db files(normal data,index,undo)
5 backup piece,
6 temporary file      
FHRDB            NUMBER Root DBA(root data block address,only exist in datafile 1,bootstrap$) 
FHCRS            VARCHAR2(16) Scan when the file was created
FHCRT            VARCHAR2(20) Time when the file was created
FHRLC            VARCHAR2(20) Last Resetlog time from database 
FHRLC_I          NUMBER Last Resetlog time as an number 
FHRLS            VARCHAR2(16) Last Resetlog Scn from database 
FHPRC            VARCHAR2(20) Previous Resetlog time from database 
FHPRC_I          NUMBER Previous Resetlog time as an number 
FHPRS            VARCHAR2(16) Previous Resetlog Scn from database 
FHBTI            VARCHAR2(20) hot backup time(rman backup will not record here)
FHBSC            VARCHAR2(16) hot backup scn
FHBTH            NUMBER hot backup thread
FHSTA            NUMBER Validated on 11g,12c
0 = consistent,mounted(no recovery needed)
1 = database backup mode(DB needs more recovery)
4 = online fuzzy
64 = fuzzy needs recovery
8192 = internal
8193 = database backup mode(datafile 1 only)
8196 = online fuzzy
Note:you can open database if the all the datafile header status(fhsta) is 0 except system(8192)
FHSCN            VARCHAR2(16) Scn when Checkpoint occurred
FHTIM            VARCHAR2(20) Time when Scn allocated
FHTHR            NUMBER Allocate SCN thread
FHRBA_SEQ        NUMBER SCN allocated,the sequence number(Redo log sequence)
FHRBA_BNO        NUMBER SCN allocated,the block number (Redo block number) 
FHRBA_BOF        NUMBER SCN allocated,the offset (Redo byte offset)
FHETB            RAW(132) Enabled Threads Bit(this should be related with thread,
maybe the max RAC nodes is 132)
FHCPC            NUMBER CheckPoint Count
FHRTS            VARCHAR2(20) Recovery timestamp when checkpoint occurred
FHCCC            NUMBER Controlfile Checkpoint Count,the value is
always equal FHCPC minus one
FHBCP_SCN        VARCHAR2(16) Backup Checkpoint Scn
FHBCP_TIM        VARCHAR2(20) Backup Checkpoint Time
FHBCP_THR        NUMBER Backup Checkpoint Thread allocated SCN
FHBCP_RBA_SEQ    NUMBER Backup Checkpoint Ocurred,the sequence
number(Redo log sequence)
FHBCP_RBA_BNO    NUMBER Backup Checkpoint Ocurred,the block
number (Redo block number) 
FHBCP_RBA_BOF    NUMBER Backup Checkpoint Ocurred,the offset(Redo byte offset)
FHBCP_ETB        RAW(132) Backup Enabled Threads Bit for Backup
(it should be related with thread,
maybe the max RAC nodes is 128)
FHBHZ            NUMBER File size when hot backup begins(the unit is block)
FHXCD            RAW(16) External cache id
FHTSN            NUMBER Tablespace Number
FHTNM            VARCHAR2(30) Tablespace Name
FHRFN            NUMBER Relative File Number
FHAFS            VARCHAR2(16) Absolute Fuzzy SCN(Minimum PITR SCN)
FHRFS            VARCHAR2(16) Media Recovery Fuzzy SCN
(The SCN at which the recovery of this file will be complete (no longer fuzzy).
Both above fuzzy SCNs must be zero unless a fuzzy flag is set, and must be greater than the checkpoint SCN)
FHRFT            DATE Media Recovery fuzzy time(record the media recovery time)
HXIFZ            NUMBER Fuzzy Flag(If YES,the flag is 1,if not the flag is 0)
HXNRCV           NUMBER Media Need Recovery Flag.If YES,
the flag is 1,if not the flag is 0)
HXFNM            VARCHAR2(513) File Name
FHPOFB           NUMBER Only exists in datafile 1.the value is 10.it should be the related with RDBA format
FHPNFB           NUMBER Only exists in datafile 1.the value is 10.it should be the
related with RDBA format
FHPRE10          NUMBER Check whether the datafile header is before 10
(If Yes,it's 1.If not,it's 0)
FHFIRSTUNRECSCN  VARCHAR2(16) First Unrecoverable Scn
FHFIRSTUNRECTIME VARCHAR2(20) First Unrecoverable Time
HXLMDBA          NUMBER RDBA(space header for locally managed file)
HXLMLD_SCN       VARCHAR2(16) Last Deallocated SCN(zero for system managed datafiles,
non-zero is restored from backup)
以上为10g x$kcvfh
FHFCRS           NUMBER Foreign Creation SCN
FHFCRT           DATE Foreign Creation Time
FHFCPS           NUMBER Foreign CheckPoint SCN
FHFCPT           DATE Foreign CheckPoint Time
FHPLUS           NUMBER Plugin SCN 
FHFDBI           NUMBER Foreign Database Id
FHPIDI           NUMBER Plugged Database Id
FHPIFN           NUMBER Plugged File Number
FHPRLS           NUMBER Plugin Resetlogs SCN
FHPRLT           DATE Plugin Resetlogs Time
FHPTSN           NUMBER Plugged Tablespace Number
FHBSSZ           NUMBER It should be backup section size
FHBSFMT          NUMBER It should be backup section format
FHBSEOFSCN       NUMBER It should be the scn of last backup section
FHBSMAP          RAW(32) It should be the backup section bitmap
HXUOPC_SCN       NUMBER Undo Optimization Current Scn(v$datafile_header.UNDO_OPT_CURRENT_CHANGE).
In backup undo optimization,RMAN excludes undo not needed for recovery from the
backup, that is, for transactions which have already been committed.
以上为11g x$kcvfh
FHPDBI           NUMBER PDB id
FHPDBDBI         NUMBER PDB db id
FHPDBIDN         VARCHAR2(31) PDB Identifier
FHPIN_SCN        NUMBER PDB Incarnation SCN
FHPIN_time       DATE PDB Incarnation time
FHPBR_SCN        NUMBER PDB Begin Resetlogs SCN
FHPBR_time       DATE PDB Begin Resetlogs Time
FHPER_SCN        NUMBER PDB End Resetlogs SCN
FHPER_time       DATE PDB End Resetlogs Time
FHPIC            NUMBER PDB incarnation
以上为12c x$kcvfh


GV$DATAFILE_HEADER
SQL> Select view_definition from v$fixed_view_definition a where a.VIEW_NAME='GV$DATAFILE_HEADER';

VIEW_DEFINITION
--------------------------------------------------------------------------------
select inst_id,
       hxfil,
       decode(hxons, 0, 'OFFLINE', 'ONLINE'),
       decode(hxerr,0,NULL,
              1,'FILE MISSING',
              2,'OFFLINE NORMAL',
              3,'NOT VERIFIED',
              4,'FILE NOT FOUND',
              5,'CANNOT OPEN FILE',
              6,'CANNOT READ HEADER',
              7,'CORRUPT HEADER',
              8,'WRONG FILE TYPE',
              9,'WRONG DATABASE',
              10,'WRONG FILE NUMBER',
              11,'WRONG FILE CREATE',
              12,'WRONG FILE CREATE',
              16,'DELAYED OPEN',
              14,'WRONG RESETLOGS',
              15,'OLD CONTROLFILE',
              'UNKNOWN ERROR'),
       hxver,
       decode(hxnrcv, 0, 'NO', 1, 'YES', NULL),
       decode(hxifz, 0, 'NO', 1, 'YES', NULL),
       to_number(fhcrs),
       to_date(fhcrt, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),
       fhtnm,
       fhtsn,
       fhrfn,
       to_number(fhrls),
       to_date(fhrlc, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),
       to_number(fhscn),
       to_date(fhtim, 'MM/DD/RR HH24:MI:SS', 'NLS_CALENDAR=Gregorian'),
       fhcpc,
       fhfsz * fhbsz,
       fhfsz,
       hxfnm,
       decode(hxlmdba, 0, NULL, hxlmdba),
       decode(hxlmld_scn, to_number('0'), NULL, hxlmld_scn),
       decode(hxuopc_scn, 0, NULL, hxuopc_scn),
       con_id
  from x$kcvfh
GV$DATAFILE;
SQL> Select view_definition from v$fixed_view_definition a where a.VIEW_NAME='GV$DATAFILE';


FHSTA字段含义(下面是在mount,open,shutdown abort,backup mode的测试)

0 = consistent,mounted(no recovery needed)
1 = database backup mode(DB needs more recovery)
4 = online fuzzy
64 = fuzzy needs recovery
8192 = internal(datafile 1 only)
8193 = database backup mode(datafile 1 only)
8196 = online fuzzy(datafile 1 only)
Note:you can open database if all the datafile header status(fhsta) is 0 except system(8192)


SQL> startup mount;
ORACLE instance started.
Total System Global Area  313159680 bytes
Fixed Size                  2252824 bytes
Variable Size             167776232 bytes
Database Buffers          138412032 bytes
Redo Buffers                4718592 bytes
Database mounted.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8192 1150691
         2          0 1150691
         3          0 1150691
         4          0 1150691
SQL> alter database open;
Database altered.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8196 1150694
         2          4 1150694
         3          4 1150694
         4          4 1150694
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area  313159680 bytes
Fixed Size                  2252824 bytes
Variable Size             167776232 bytes
Database Buffers          138412032 bytes
Redo Buffers                4718592 bytes
Database mounted.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8196 1150694
         2          4 1150694
         3          4 1150694
         4          4 1150694
SQL> alter database open;
Database altered.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8196 1171013
         2          4 1171013
         3          4 1171013
         4          4 1171013
SQL> alter database begin backup;
Database altered.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8193 1172118
         2          1 1172118
         3          1 1172118
         4          1 1172118
SQL> alter database end backup;
Database altered.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8196 1172118
         2          4 1172118
         3          4 1172118
         4          4 1172118
SQL> alter tablespace users begin backup;
Tablespace altered.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8196 1172118
         2          4 1172118
         3          4 1172118
         4          1 1172174
SQL> alter tablespace users end backup;
Tablespace altered.
SQL> select hxfil,fhsta,fhscn from x$kcvfh;
     HXFIL      FHSTA FHSCN
---------- ---------- ----------------
         1       8196 1172118
         2          4 1172118
         3          4 1172118
         4          4 1172174
SQL>
11gX$KCVFH新增字段是为传输表空间准备的,下面的传输表空间测试是从11g导入到12c数据库

create user c##ora identified by oracle default tablespace users;
grant resource,dba to c##ora;
CONVERT DATAFILE '/home/oracle/ttbs01.dbf' FROM PLATFORM 'Solaris[tm] OE (32-bit)' format '/oradata/cdb1/ttbs01.dbf';

[oracle@db1 ~]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Mon Mar 14 08:38:19 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CDB1 (DBID=879831934)
RMAN> CONVERT DATAFILE '/home/oracle/ttbs01.dbf' FROM PLATFORM 'Solaris[tm] OE (32-bit)' format '/oradata/cdb1/ttbs01.dbf';
Starting conversion at target at 14-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=59 device type=DISK
channel ORA_DISK_1: starting datafile conversion
input file name=/home/oracle/ttbs01.dbf
converted datafile=/oradata/cdb1/ttbs01.dbf
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Finished conversion at target at 14-MAR-16
RMAN> exit
Recovery Manager complete.

impdp system/oracle directory=dpump dumpfile=ttbs.dmp logfile=impdp.log  TRANSPORT_DATAFILES=/oradata/cdb1/ttbs01.dbf remap_schema=ttbs:c##ora

[oracle@db1 ~]$ impdp system/oracle directory=dpump dumpfile=ttbs.dmp logfile=impdp.log  TRANSPORT_DATAFILES=/oradata/cdb1/ttbs01.dbf remap_schema=ttbs:c##ora
Import: Release 12.1.0.2.0 - Production on Mon Mar 14 08:41:18 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
WARNING: Oracle Data Pump operations are not typically needed when connected to the root or seed of a container database.
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Source time zone version is 14 and target time zone version is 18.
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01":  system/******** directory=dpump dumpfile=ttbs.dmp logfile=impdp.log TRANSPORT_DATAFILES=/oradata/cdb1/ttbs01.dbf remap_schema=ttbs:c##ora 
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Mon Mar 14 08:41:29 2016 elapsed 0 00:00:06

[oracle@db1 ~]$

SQL> select FHFCRS,FHFCRT,FHFCPS,FHFCPT,FHPLUS,FHFDBI,FHPIDI,FHPIFN,FHPRLS,FHPRLT,FHPTSN from x$kcvfh;

    FHFCRS FHFCRT              FHFCPS FHFCPT              FHPLUS     FHFDBI     FHPIDI     FHPIFN     FHPRLS FHPRLT              FHPTSN
---------- --------------- ---------- --------------- ---------- ---------- ---------- ---------- ---------- --------------- ----------
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0
         0                          0                          0          0          0          0          0                          0

关键词:block 

相关文章

如何用BBED使Offline的数据文件Online
Interpret The Datafile OS Header/Block Zero
如何计算Oracle Block的校验值
10g,11g,12c X$KCVFH(一)
Top