[20171206]设置db_2k_cache_size的疑问.txt
--//上午测试最小的数据文件,我想看看2k数据块能建议多小的数据文件,我的测试最小10K,但是遇到1个无法理解的问题.
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> alter system set db_2k_cache_size=1M scope=spfile;
System altered.
2.测试:
--//重启数据库:
SYS@book> startup
ORACLE instance started.
Total System Global Area 734949376 bytes
Fixed Size 2256752 bytes
Variable Size 197132432 bytes
Database Buffers 528482304 bytes
Redo Buffers 7077888 bytes
Database mounted.
Database opened.
SYS@book> show parameter db_2k
NAME TYPE VALUE
---------------- ----------- ------
db_2k_cache_size big integer 96M
SYS@book> show spparameter db_2k
SID NAME TYPE VALUE
-------- ---------------- ----------- -----
* db_2k_cache_size big integer 1M
SYS@book> show parameter sga_
NAME TYPE VALUE
------------ ----------- -----
sga_max_size big integer 704M
sga_target big integer 0
--//为什么这么大,按照我的理解至少一个Granule Size.
SYS@book> select * from v$sgainfo;
NAME BYTES RES
-------------------------------- ---------- ---
Fixed SGA Size 2256752 No
Redo Buffers 7077888 No
Buffer Cache Size 528482304 Yes
Shared Pool Size 180355072 Yes
Large Pool Size 12582912 Yes
Java Pool Size 4194304 Yes
Streams Pool Size 0 Yes
Shared IO Pool Size 0 Yes
Granule Size 4194304 No
Maximum SGA Size 734949376 No
Startup overhead in Shared Pool 133977368 No
Free SGA Memory Available 0
12 rows selected.
--//Granule Size=4194304 ,而实际db_2k_cache_size占用96M.
SYS@book> @ &r/memalloc
MIN(BASEADDR) MAX(BASEADDR) GRANULES MB GRANFLAGS COMPONENT GRANSTATE
---------------- ---------------- ---------- ---------- ---------- -------------------------------- ----------------
0000000060C00000 0000000066800000 24 96 4 DEFAULT 2K buffer cache ALLOC
0000000066C00000 0000000080000000 102 408 4 DEFAULT buffer cache ALLOC
0000000080400000 0000000080400000 1 4 4 java pool ALLOC
0000000080800000 0000000081000000 3 12 4 large pool ALLOC
0000000081400000 000000008BC00000 43 172 4 shared pool ALLOC
press enter .....
BASEADDR GRANSIZE GRANFLAGS COMPONENT GRANSTATE
---------------- ---------- ---------- -------------------------------- ----------------
0000000060C00000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000061000000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000061400000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000061800000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000061C00000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000062000000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000062400000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000062800000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000062C00000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000063000000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000063400000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000063800000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000063C00000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000064000000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000064400000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000064800000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000064C00000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000065000000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000065400000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000065800000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000065C00000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000066000000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000066400000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000066800000 4194304 4 DEFAULT 2K buffer cache ALLOC
0000000066C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000067000000 4194304 4 DEFAULT buffer cache ALLOC
0000000067400000 4194304 4 DEFAULT buffer cache ALLOC
0000000067800000 4194304 4 DEFAULT buffer cache ALLOC
0000000067C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000068000000 4194304 4 DEFAULT buffer cache ALLOC
0000000068400000 4194304 4 DEFAULT buffer cache ALLOC
0000000068800000 4194304 4 DEFAULT buffer cache ALLOC
0000000068C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000069000000 4194304 4 DEFAULT buffer cache ALLOC
0000000069400000 4194304 4 DEFAULT buffer cache ALLOC
0000000069800000 4194304 4 DEFAULT buffer cache ALLOC
0000000069C00000 4194304 4 DEFAULT buffer cache ALLOC
000000006A000000 4194304 4 DEFAULT buffer cache ALLOC
000000006A400000 4194304 4 DEFAULT buffer cache ALLOC
000000006A800000 4194304 4 DEFAULT buffer cache ALLOC
000000006AC00000 4194304 4 DEFAULT buffer cache ALLOC
000000006B000000 4194304 4 DEFAULT buffer cache ALLOC
000000006B400000 4194304 4 DEFAULT buffer cache ALLOC
000000006B800000 4194304 4 DEFAULT buffer cache ALLOC
000000006BC00000 4194304 4 DEFAULT buffer cache ALLOC
000000006C000000 4194304 4 DEFAULT buffer cache ALLOC
000000006C400000 4194304 4 DEFAULT buffer cache ALLOC
000000006C800000 4194304 4 DEFAULT buffer cache ALLOC
000000006CC00000 4194304 4 DEFAULT buffer cache ALLOC
000000006D000000 4194304 4 DEFAULT buffer cache ALLOC
000000006D400000 4194304 4 DEFAULT buffer cache ALLOC
000000006D800000 4194304 4 DEFAULT buffer cache ALLOC
000000006DC00000 4194304 4 DEFAULT buffer cache ALLOC
000000006E000000 4194304 4 DEFAULT buffer cache ALLOC
000000006E400000 4194304 4 DEFAULT buffer cache ALLOC
000000006E800000 4194304 4 DEFAULT buffer cache ALLOC
000000006EC00000 4194304 4 DEFAULT buffer cache ALLOC
000000006F000000 4194304 4 DEFAULT buffer cache ALLOC
000000006F400000 4194304 4 DEFAULT buffer cache ALLOC
000000006F800000 4194304 4 DEFAULT buffer cache ALLOC
000000006FC00000 4194304 4 DEFAULT buffer cache ALLOC
0000000070000000 4194304 4 DEFAULT buffer cache ALLOC
0000000070400000 4194304 4 DEFAULT buffer cache ALLOC
0000000070800000 4194304 4 DEFAULT buffer cache ALLOC
0000000070C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000071000000 4194304 4 DEFAULT buffer cache ALLOC
0000000071400000 4194304 4 DEFAULT buffer cache ALLOC
0000000071800000 4194304 4 DEFAULT buffer cache ALLOC
0000000071C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000072000000 4194304 4 DEFAULT buffer cache ALLOC
0000000072400000 4194304 4 DEFAULT buffer cache ALLOC
0000000072800000 4194304 4 DEFAULT buffer cache ALLOC
0000000072C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000073000000 4194304 4 DEFAULT buffer cache ALLOC
0000000073400000 4194304 4 DEFAULT buffer cache ALLOC
0000000073800000 4194304 4 DEFAULT buffer cache ALLOC
0000000073C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000074000000 4194304 4 DEFAULT buffer cache ALLOC
0000000074400000 4194304 4 DEFAULT buffer cache ALLOC
0000000074800000 4194304 4 DEFAULT buffer cache ALLOC
0000000074C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000075000000 4194304 4 DEFAULT buffer cache ALLOC
0000000075400000 4194304 4 DEFAULT buffer cache ALLOC
0000000075800000 4194304 4 DEFAULT buffer cache ALLOC
0000000075C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000076000000 4194304 4 DEFAULT buffer cache ALLOC
0000000076400000 4194304 4 DEFAULT buffer cache ALLOC
0000000076800000 4194304 4 DEFAULT buffer cache ALLOC
0000000076C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000077000000 4194304 4 DEFAULT buffer cache ALLOC
0000000077400000 4194304 4 DEFAULT buffer cache ALLOC
0000000077800000 4194304 4 DEFAULT buffer cache ALLOC
0000000077C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000078000000 4194304 4 DEFAULT buffer cache ALLOC
0000000078400000 4194304 4 DEFAULT buffer cache ALLOC
0000000078800000 4194304 4 DEFAULT buffer cache ALLOC
0000000078C00000 4194304 4 DEFAULT buffer cache ALLOC
0000000079000000 4194304 4 DEFAULT buffer cache ALLOC
0000000079400000 4194304 4 DEFAULT buffer cache ALLOC
0000000079800000 4194304 4 DEFAULT buffer cache ALLOC
0000000079C00000 4194304 4 DEFAULT buffer cache ALLOC
000000007A000000 4194304 4 DEFAULT buffer cache ALLOC
000000007A400000 4194304 4 DEFAULT buffer cache ALLOC
000000007A800000 4194304 4 DEFAULT buffer cache ALLOC
000000007AC00000 4194304 4 DEFAULT buffer cache ALLOC
000000007B000000 4194304 4 DEFAULT buffer cache ALLOC
000000007B400000 4194304 4 DEFAULT buffer cache ALLOC
000000007B800000 4194304 4 DEFAULT buffer cache ALLOC
000000007BC00000 4194304 4 DEFAULT buffer cache ALLOC
000000007C000000 4194304 4 DEFAULT buffer cache ALLOC
000000007C400000 4194304 4 DEFAULT buffer cache ALLOC
000000007C800000 4194304 4 DEFAULT buffer cache ALLOC
000000007CC00000 4194304 4 DEFAULT buffer cache ALLOC
000000007D000000 4194304 4 DEFAULT buffer cache ALLOC
000000007D400000 4194304 4 DEFAULT buffer cache ALLOC
000000007D800000 4194304 4 DEFAULT buffer cache ALLOC
000000007DC00000 4194304 4 DEFAULT buffer cache ALLOC
000000007E000000 4194304 4 DEFAULT buffer cache ALLOC
000000007E400000 4194304 4 DEFAULT buffer cache ALLOC
000000007E800000 4194304 4 DEFAULT buffer cache ALLOC
000000007EC00000 4194304 4 DEFAULT buffer cache ALLOC
000000007F000000 4194304 4 DEFAULT buffer cache ALLOC
000000007F400000 4194304 4 DEFAULT buffer cache ALLOC
000000007F800000 4194304 4 DEFAULT buffer cache ALLOC
000000007FC00000 4194304 4 DEFAULT buffer cache ALLOC
0000000080000000 4194304 4 DEFAULT buffer cache ALLOC
0000000080400000 4194304 4 java pool ALLOC
0000000080800000 4194304 4 large pool ALLOC
0000000080C00000 4194304 4 large pool ALLOC
0000000081000000 4194304 4 large pool ALLOC
0000000081400000 4194304 4 shared pool ALLOC
0000000081800000 4194304 4 shared pool ALLOC
0000000081C00000 4194304 4 shared pool ALLOC
0000000082000000 4194304 4 shared pool ALLOC
0000000082400000 4194304 4 shared pool ALLOC
0000000082800000 4194304 4 shared pool ALLOC
0000000082C00000 4194304 4 shared pool ALLOC
0000000083000000 4194304 4 shared pool ALLOC
0000000083400000 4194304 4 shared pool ALLOC
0000000083800000 4194304 4 shared pool ALLOC
0000000083C00000 4194304 4 shared pool ALLOC
0000000084000000 4194304 4 shared pool ALLOC
0000000084400000 4194304 4 shared pool ALLOC
0000000084800000 4194304 4 shared pool ALLOC
0000000084C00000 4194304 4 shared pool ALLOC
0000000085000000 4194304 4 shared pool ALLOC
0000000085400000 4194304 4 shared pool ALLOC
0000000085800000 4194304 4 shared pool ALLOC
0000000085C00000 4194304 4 shared pool ALLOC
0000000086000000 4194304 4 shared pool ALLOC
0000000086400000 4194304 4 shared pool ALLOC
0000000086800000 4194304 4 shared pool ALLOC
0000000086C00000 4194304 4 shared pool ALLOC
0000000087000000 4194304 4 shared pool ALLOC
0000000087400000 4194304 4 shared pool ALLOC
0000000087800000 4194304 4 shared pool ALLOC
0000000087C00000 4194304 4 shared pool ALLOC
0000000088000000 4194304 4 shared pool ALLOC
0000000088400000 4194304 4 shared pool ALLOC
0000000088800000 4194304 4 shared pool ALLOC
0000000088C00000 4194304 4 shared pool ALLOC
0000000089000000 4194304 4 shared pool ALLOC
0000000089400000 4194304 4 shared pool ALLOC
0000000089800000 4194304 4 shared pool ALLOC
0000000089C00000 4194304 4 shared pool ALLOC
000000008A000000 4194304 4 shared pool ALLOC
000000008A400000 4194304 4 shared pool ALLOC
000000008A800000 4194304 4 shared pool ALLOC
000000008AC00000 4194304 4 shared pool ALLOC
000000008B000000 4194304 4 shared pool ALLOC
000000008B400000 4194304 4 shared pool ALLOC
000000008B800000 4194304 4 shared pool ALLOC
000000008BC00000 4194304 4 shared pool ALLOC
173 rows selected.
--//我的测试库内存参数都是手动设置的,没有使用动态管理.你看到的分配都是连续的区域.
SYS@book> alter system reset db_2k_cache_size sid='*';
System altered.
SYS@book> drop tablespace t03 including contents and datafiles;
Tablespace dropped.
--//删除2K的数据文件.
SYS@book> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@book> startup
ORACLE instance started.
Total System Global Area 634732544 bytes
Fixed Size 2255792 bytes
Variable Size 197133392 bytes
Database Buffers 427819008 bytes
Redo Buffers 7524352 bytes
Database mounted.
SYS@book> show parameter sga_
NAME TYPE VALUE
------------ ----------- ------
sga_max_size big integer 608M
sga_target big integer 0
SYS@book> @ &r/memalloc
MIN(BASEADDR) MAX(BASEADDR) GRANULES MB GRANFLAGS COMPONENT GRANSTATE
---------------- ---------------- ---------- ---------- ---------- -------------------------------- ----------------
0000000060C00000 000000007A000000 102 408 4 DEFAULT buffer cache ALLOC
000000007A400000 000000007A400000 1 4 4 java pool ALLOC
000000007A800000 000000007B000000 3 12 4 large pool ALLOC
000000007B400000 0000000085C00000 43 172 4 shared pool ALLOC
//后面省略....
//才明白一个oracle内存分配的一个问题,我以前一直以为不同块大小的内存分配是从DEFAULT buffer cache分配的,而实际上不是,
//而是单独定义,单独使用.
//如果你对比前面show sga的输出就明白了(或者看show parameter sga_的显示).包括分配内存的基地址.
//前面sga_max_size=704M,后面sga_max_size=608M.
//704-608=96M
//至于为什么要分配这么大,我就不清楚了,那位知道???
3.附上memalloc的脚本:
col component format a32
select min(BASEADDR), max(BASEADDR), count(1) Granules, sum(a.gransize)/1048576 MB, a.GRANFLAGS, component, a.GRANSTATE
from x$ksmge a, x$kmgsct b
where a.grantype = b.grantype (+)
group by a.GRANFLAGS, component, a.GRANSTATE
order by 1,2;
pause press enter .....
select a.BASEADDR, a.gransize, a.GRANFLAGS, b.component, a.GRANSTATE
from x$ksmge a, x$kmgsct b
where a.grantype = b.grantype (+)
order by 1,2;