Oracleデータファイルscnの概要
1、以下はデータファイルのscn情報をビューで観察する
2、次にtraceファイルを用いてデータファイルのscn情報を観察する(ここではsystem表空間を例に挙げる)
Tablespace #0 - SYSTEM rel_fn:1 Creation at scn: 0x0000.000000008 08/21/2014 16:26:11#データファイル作成時のscn、v$datafile_header.CREATION_CHANGE#対応Backup taken at scn:0 x 0000.00000 01/01/1988 00:00:00 thread:0#データファイル最後にホットスペアを作ったときにピンが住んでいたscnと、#v$backup.CHANGE#対応reset logs count:0 x 33088679 scn:0 x 0000.00000001#最後にresetlogを使用してデータベースのscnを開き、v$datafile_header.RESETLOGS_CHANGE#はprev reset logs count:0 x 0 scn:0 x 0000に対応する.00000000 recovered at 08/22/2014 12:54:15 status:0x2004 root dba:0x00402901 chkpt cnt: 133 ctl cnt:132 begin-hot-backup file size: 0 Checkpointed at scn: 0x0000.000 e 1 cb 5 08/27/2014 18:00:00:11#データファイル現在scn、およびv$datafile_header.CHECKPOINT_CHANGE#
3、以下bbedを使用してこれらのscnを確認する(ここでは11 gにbbedをどのようにインストールするかは言わない)
select file#,name,
CREATION_CHANGE#, -- scn
RESETLOGS_CHANGE#, -- resetlog scn
CHECKPOINT_CHANGE# -- scn
from v$datafile_header;
FILE# NAME CREATION_CHANGE# RESETLOGS_CHANGE# CHECKPOINT_CHANGE#
---------- -------------------------------------------------- ---------------- ----------------- ------------------
1 /u01/app/oracle/oradata/normal/system01.dbf 8 1 924853
2 /u01/app/oracle/oradata/normal/undotbs01.dbf 5224 1 924853
3 /u01/app/oracle/oradata/normal/sysaux01.dbf 5349 1 924853
4 /u01/app/oracle/oradata/normal/users01.dbf 5826 1 924853
5 /u01/app/oracle/oradata/normal/chenhao01.dbf 7948 1 924853
6 /u01/app/oracle/oradata/normal/undotbs02.dbf 155204 1 924853
7 /u01/app/oracle/oradata/normal/system02.dbf 517792 1 924853
8 /u01/app/oracle/oradata/normal/outln01.dbf 769957 1 924853
9 /u01/app/oracle/oradata/normal/test01.dbf 818947 1 924853
select FILE#,
CHANGE# -- pin scn( begin backup )
from v$backup;
FILE# CHANGE#
---------- ----------
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
2、次にtraceファイルを用いてデータファイルのscn情報を観察する(ここではsystem表空間を例に挙げる)
SQL> alter session set events 'immediate trace name file_hdrs level 3';
Session altered.
SQL> alter session set events 'immediate trace name file_hdrs off';
Session altered.
traceファイルには、次の情報が表示されます.Tablespace #0 - SYSTEM rel_fn:1 Creation at scn: 0x0000.000000008 08/21/2014 16:26:11#データファイル作成時のscn、v$datafile_header.CREATION_CHANGE#対応Backup taken at scn:0 x 0000.00000 01/01/1988 00:00:00 thread:0#データファイル最後にホットスペアを作ったときにピンが住んでいたscnと、#v$backup.CHANGE#対応reset logs count:0 x 33088679 scn:0 x 0000.00000001#最後にresetlogを使用してデータベースのscnを開き、v$datafile_header.RESETLOGS_CHANGE#はprev reset logs count:0 x 0 scn:0 x 0000に対応する.00000000 recovered at 08/22/2014 12:54:15 status:0x2004 root dba:0x00402901 chkpt cnt: 133 ctl cnt:132 begin-hot-backup file size: 0 Checkpointed at scn: 0x0000.000 e 1 cb 5 08/27/2014 18:00:00:11#データファイル現在scn、およびv$datafile_header.CHECKPOINT_CHANGE#
3、以下bbedを使用してこれらのscnを確認する(ここでは11 gにbbedをどのようにインストールするかは言わない)
SQL> select file#||' '||name||' '||bytes from v$datafile;
FILE#||''||NAME||''||BYTES
----------------------------------------------------------
1 /u01/app/oracle/oradata/normal/system01.dbf 340787200
2 /u01/app/oracle/oradata/normal/undotbs01.dbf 209715200
3 /u01/app/oracle/oradata/normal/sysaux01.dbf 340787200
4 /u01/app/oracle/oradata/normal/users01.dbf 524288000
5 /u01/app/oracle/oradata/normal/chenhao01.dbf 104857600
6 /u01/app/oracle/oradata/normal/undotbs02.dbf 209715200
7 /u01/app/oracle/oradata/normal/system02.dbf 314572800
8 /u01/app/oracle/oradata/normal/outln01.dbf 20971520
9 /u01/app/oracle/oradata/normal/test01.dbf 10485760
[oracle@normal ~]$ cat filelist.txt
1 /u01/app/oracle/oradata/normal/system01.dbf 340787200
2 /u01/app/oracle/oradata/normal/undotbs01.dbf 209715200
3 /u01/app/oracle/oradata/normal/sysaux01.dbf 340787200
4 /u01/app/oracle/oradata/normal/users01.dbf 524288000
5 /u01/app/oracle/oradata/normal/chenhao01.dbf 104857600
6 /u01/app/oracle/oradata/normal/undotbs02.dbf 209715200
7 /u01/app/oracle/oradata/normal/system02.dbf 314572800
8 /u01/app/oracle/oradata/normal/outln01.dbf 20971520
9 /u01/app/oracle/oradata/normal/test01.dbf 10485760
[oracle@normal ~]$ cat bbed.par
blocksize=8192
listfile=/home/oracle/filelist.txt
mode=edit
[oracle@normal ~]$ bbed parfile=bbed.par
BBED> set dba 1,1
-------------------------------------------------
-- scn basescn、 wrapscn
-------------------------------------------------
-- scn, v$datafile_header.CREATION_CHANGE#
BBED> print kcvfhcrs
struct kcvfhcrs, 8 bytes @100
ub4 kscnbas @100 0x00000008
ub2 kscnwrp @104 0x0000
-- # resetlog scn, v$datafile_header.RESETLOGS_CHANGE#
BBED> print kcvfhrls
struct kcvfhrls, 8 bytes @116
ub4 kscnbas @116 0x00000001
ub2 kscnwrp @120 0x0000
-- pin scn, #v$backup.CHANGE#
BBED> print kcvfhbsc
struct kcvfhbsc, 8 bytes @128
ub4 kscnbas @128 0x00000000
ub2 kscnwrp @132 0x0000
-- scn, v$datafile_header.CHECKPOINT_CHANGE#
BBED> print kcvfhckp
struct kcvfhckp, 36 bytes @484
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 0x000e1cb5
ub2 kscnwrp @488 0x0000
-------------------------------------------------------------
-- (offset, :@100)
-- scn 。
--------------------------------------------------------------
BBED> set dba 1,1
DBA 0x00400001 (4194305 1,1)
BBED> dump offset 100 count 8
File: /u01/app/oracle/oradata/normal/system01.dbf (1)
Block: 1 Offsets: 100 to 115 Dba:0x00400001
------------------------------------------------------------------------
08000000 00000000 -- :08000000 -> 00000008
<32 bytes per line>