[20170221]nocache工具的小測試.txt

lfree發表於2017-02-21

[20170221]nocache工具的小測試.txt

--nocache 這個小工具可以顯示檔案在快取的數量.
--其中 cachestats 有一個-v  引數可以以表格形式顯示.看看它的標識是否正確.

1.環境:
SYS@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> show parameter filesystem
NAME                 TYPE   VALUE
-------------------- ------ ------
filesystemio_options string none

SCOTT@book> select rowid,dept.* from dept ;
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAVRCAAEAAAACHAAA         10 ACCOUNTING     NEW YORK
AAAVRCAAEAAAACHAAB         20 RESEARCH       DALLAS
AAAVRCAAEAAAACHAAC         30 SALES          CHICAGO
AAAVRCAAEAAAACHAAD         40 OPERATIONS     BOSTON

SCOTT@book> @ &r/rowid AAAVRCAAEAAAACHAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     87106          4        135          0  0x1000087           4,135                alter system dump datafile 4 block 135 ;

--//在塊4,135位置.
SCOTT@book> alter system flush buffer_cache;
System altered.
--//注意要執行這個.因為我前面已經清除檔案快取,不然執行select rowid,dept.* from dept where rowid='AAAVRCAAEAAAACHAAA';因為這時在資料庫快取裡面,
--//檔案系統快取不存在.

2.測試:
$ cachedel  /mnt/ramdisk/book/users01.dbf
$ cachestats   -v /mnt/ramdisk/book/users01.dbf | head -20
/mnt/ramdisk/book/users01.dbf            pages in cache: 0/554242 (0.0%)  [filesize=2216968.0K, pagesize=4K]
cache map:
     0: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    32: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    64: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    96: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   128: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   160: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   192: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   224: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   256: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   288: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   320: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   352: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   384: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   416: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   448: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   480: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   512: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |

SCOTT@book> select rowid,dept.* from dept where rowid='AAAVRCAAEAAAACHAAA';
ROWID                  DEPTNO DNAME          LOC
------------------ ---------- -------------- -------------
AAAVRCAAEAAAACHAAA         10 ACCOUNTING     NEW YORK


$ cachestats   -v /mnt/ramdisk/book/users01.dbf | head -20
/mnt/ramdisk/book/users01.dbf            pages in cache: 16/554242 (0.0%)  [filesize=2216968.0K, pagesize=4K]

cache map:
     0: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    32: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    64: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    96: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   128: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   160: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   192: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   224: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   256: |x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x| | | | | | | | | | | | | | | | |
   288: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   320: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   352: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   384: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   416: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   448: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   480: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   512: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |

--//資料塊8k,而pagesize=4K,135*8/4=270.上面256位置顯示16個x,快取64K??重複幾次都是一樣.

3.換另外一個塊看看:
SCOTT@book> select rowid,emp.* from emp where rowid='AAAVREAAEAAAACXAAA';
ROWID                   EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
AAAVREAAEAAAACXAAA       7369 SMITH      CLERK           7902 1980-12-17 00:00:00        800                    20

SCOTT@book> @ &r/rowid AAAVREAAEAAAACXAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     87108          4        151          0  0x1000097           4,151                alter system dump datafile 4 block 151 ;

SCOTT@book> alter system flush buffer_cache;
System altered.

SCOTT@book> alter system flush buffer_cache;
System altered.

$ cachedel  /mnt/ramdisk/book/users01.dbf

SCOTT@book> select rowid,emp.* from emp where rowid='AAAVREAAEAAAACXAAA';
ROWID                   EMPNO ENAME      JOB              MGR HIREDATE                   SAL       COMM     DEPTNO
------------------ ---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
AAAVREAAEAAAACXAAA       7369 SMITH      CLERK           7902 1980-12-17 00:00:00        800                    20

$ cachestats   -v /mnt/ramdisk/book/users01.dbf | head -20
/mnt/ramdisk/book/users01.dbf            pages in cache: 16/554242 (0.0%)  [filesize=2216968.0K, pagesize=4K]

cache map:
     0: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    32: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    64: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
    96: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   128: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   160: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   192: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   224: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   256: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   288: |x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x| | | | | | | | | | | | | | | | |
   320: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   352: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   384: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   416: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   448: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   480: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
   512: | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |

--// 151*8/4=302. 讀1個塊確實快取64K,位置是正確的,具體為什麼快取64K,OS的東西我就不清楚了.^_^.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2134054/,如需轉載,請註明出處,否則將追究法律責任。

相關文章