本文的环境:Oracle Databae 12.1.0.2, rhel5.9 x86-64bit
[oracle@rhel59 orcl]$ pwd /u01/app/oracle/oradata/orcl [oracle@rhel59 orcl]$ ls -lrt total 2386544 drwxr-x--- 2 oracle oinstall 4096 Dec 26 2014 pdbseed drwxr-x--- 2 oracle oinstall 4096 Dec 26 2014 PN1 drwxr-x--- 2 oracle oinstall 4096 Dec 26 2014 PN2 -rw-r----- 1 oracle oinstall 5251072 Jul 31 13:26 users01.dbf -rw-r----- 1 oracle oinstall 52429312 Jul 31 13:26 redo03.log -rw-r----- 1 oracle oinstall 52429312 Jul 31 13:26 redo01.log -rw-r----- 1 oracle oinstall 74457088 Jul 31 20:01 temp01.dbf -rw-r----- 1 oracle oinstall 602939392 Jul 31 20:25 undotbs01.dbf -rw-r----- 1 oracle oinstall 870326272 Jul 31 20:25 system01.dbf -rw-r----- 1 oracle oinstall 765468672 Jul 31 20:25 sysaux01.dbf -rw-r----- 1 oracle oinstall 52429312 Jul 31 20:26 redo02.log -rw-r----- 1 oracle oinstall 17973248 Jul 31 20:26 control01.ctl [oracle@rhel59 orcl]$ dd if=/u01/app/oracle/oradata/orcl/system01.dbf bs=512 count=1 | od -x 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.027559 seconds, 18.6 kB/s 0000000 a200 0000 0000 ffc0 0000 0000 0000 0000 0000020 6567 0000 2000 0000 9f00 0001 7c7d 7a7b 0000040 81a0 0000 0000 0000 0000 0000 0000 0000 0000060 0000 0000 0000 0000 0000 0000 0000 0000 * 0001000 [oracle@rhel59 orcl]$ dd if=/u01/app/oracle/oradata/orcl/system01.dbf bs=512 count=1 | od -i 1+0 records in 1+0 records out 512 bytes (512 B) copied, 2.9e-05 seconds, 17.7 MB/s 0000000 41472 -4194304 0 0 0000020 25959 8192 106240 2054913149 0000040 33184 0 0 0 0000060 0 0 0 0 * 0001000 [oracle@rhel59 orcl]$ [oracle@rhel59 orcl]$ [oracle@rhel59 orcl]$ ls -lrt 8192*106240=870318080 而 ls -lrt的结果中显示system01.dbf的大小为:870326272 870326272-870318080=8192,这多出的一个就是datafile中的os header, 參见文章: How to Detect and Fix a Corruption in the Datafile OS Header/Block Zero - ORA-27047 DBV-107 ORA-1157/ORA-27048 (文档 ID 360032.1)
8192手工计算过程;
2000 0000 翻转后:00002000,换算成十进制,就是8192
106240手工计算过程:
9f00 0001 翻转后:00019f00, 换算成十进制,就是106240
參考文章:
HOW TO GET DATAFILE SIZE THROUGH DD (文档 ID 274445.1)
注:该文章只能提供计算的思路,事实上里边的db block 的数量的换算过程是错误的。