[20191204]關於oracle例項是否使用hugepages問題2.txt

lfree發表於2019-12-04

[20191204]關於oracle例項是否使用hugepages問題2.txt

--//自己最近一段時間一直在關注這個問題,看到一個連結:


--//實際上掃描/proc/$pid/smaps獲得共享記憶體段大小.指令碼如下:
--//我修改一點點.他執行ps -ef | grep $pid | grep -v grep可能有錯,因為grep $pid可能查詢到無關pmon的程式.
--//另外該指令碼不能使用在AMM的環境.實際上指令碼很簡單含有KernelPageSize就是使用hugepages的段.

#! /bin/bash
total_shmsize=0
total_hugepagesize=0

for pid in `ps -ef | grep ora_pmon_|egrep -v "grep|+ASM"|  awk '{print $2}'`
do
echo
echo "-----------------------------------------------------------"
echo
# ps -ef | grep $pid | grep -v grep
ps v $pid

shmsize=`grep -A 1 '/SYSV00000000' /proc/$pid/smaps | grep "^Size:" | awk 'BEGIN{sum=0}{sum+=$2}END{print sum/1024}' |  awk -F"." '{print $1}'`
hugepagesize=`grep -B 11 'KernelPageSize:     2048 kB' /proc/$pid/smaps | grep "^Size:" | awk 'BEGIN{sum=0}{sum+=$2}END{print sum/1024}' | awk -F"." '{print $1}'`

echo "INSTANCE SGA (SMALL/HUGE page)"  : $shmsize "MB"
echo "INSTANCE SGA (HUGE PAGE)" $hugepagesize "MB"

echo "Percent Huge page :"  $(( $hugepagesize *100 / $shmsize  )) "%"

total_shmsize=$(( $shmsize + $total_shmsize ))
total_hugepagesize=$(( $total_hugepagesize + $hugepagesize ))

done

echo
echo "-----------------------------------------------------------"
echo
echo "SGA TOTAL (SMALL/HUGE page)"  : $total_shmsize "MB"
echo "SGA TOTAL (HUGE PAGE)" $total_hugepagesize "MB"
echo "Percent Huge page :"  $(( $total_hugepagesize *100 / $total_shmsize  )) "%"

--//測試看看:
# grep "^vm.nr" /etc/sysctl.conf
vm.nr_hugepages = 104
vm.nr_overcommit_hugepages = 1000

SYS@book> startup
ORACLE instance started.
Total System Global Area  643084288 bytes
Fixed Size                  2255872 bytes
Variable Size             205521920 bytes
Database Buffers          427819008 bytes
Redo Buffers                7487488 bytes
Database mounted.
Database opened.

--//alert.log:
Starting ORACLE instance (normal)
************************ Large Pages Information *******************
Per process system memlock (soft) limit = 51 GB
Total Shared Global Region in Large Pages = 208 MB (33%)
Large Pages used by this instance: 104 (208 MB)
Large Pages unused system wide = 0 (0 KB)
Large Pages configured system wide = 104 (208 MB)
Large Page size = 2048 KB

RECOMMENDATION:
  Total System Global Area size is 618 MB. For optimal performance,
  prior to the next instance restart:
  1. Increase the number of unused large pages by
 at least 205 (page size 2048 KB, total size 410 MB) system wide to
  get 100% of the System Global Area allocated with large pages
********************************************************************

--//在混合模式.
$ . huge.sh
-----------------------------------------------------------
oracle    5565     1  0 17:01 ?        00:00:00 ora_pmon_book
INSTANCE SGA (SMALL/HUGE page) : 616 MB
INSTANCE SGA (HUGE PAGE) 208 MB
Percent Huge page : 33 %
-----------------------------------------------------------
-----------------------------------------------------------
SGA TOTAL (SMALL/HUGE page) : 616 MB
SGA TOTAL (HUGE PAGE) 208 MB
Percent Huge page : 33 %

$ ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x00000000 414711809  oracle    640        12582912   25
0x00000000 414744578  oracle    640        159383552  25
0x00000000 414777347  oracle    640        33554432   25
0x00000000 414810117  oracle    640        8388608    25
0x00000000 414842886  oracle    640        4194304    25
0x00000000 414875655  oracle    640        427819008  25
0xe8a8ec10 414908424  oracle    640        2097152    25

--//key=0xe8a8ec10,大小2097152/1024/1024 = 2M.視乎這個多出2M的段比較特殊.

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

相關文章