[20191119]探究ipcs命令輸出2.txt--//繼續上午的測試:http://blog.itpub.net/267265/viewspace-2664758/=>[20191119]探究ipcs命令輸出.txt--//先補充ipcs 剩餘2個參數 -l -u--//-l limits--/ ...
[20191119]探究ipcs命令輸出2.txt
--//繼續上午的測試:http://blog.itpub.net/267265/viewspace-2664758/=>[20191119]探究ipcs命令輸出.txt
--//先補充ipcs 剩餘2個參數 -l -u
--//-l limits
--//-u summary
$ ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 67108864
max total shared memory (kbytes) = 17179869184
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 128
max semaphores per array = 2600
max semaphores system wide = 332800
max ops per semop call = 2600
semaphore max value = 32767
------ Messages: Limits --------
max queues system wide = 32768
max size of message (bytes) = 65536
default max size of queue (bytes) = 65536
$ ipcs -u
------ Shared Memory Status --------
segments allocated 5
pages allocated 158305
pages resident 129633
pages swapped 0
Swap performance: 0 attempts 0 successes
------ Semaphore Status --------
used arrays = 1
allocated semaphores = 204
------ Messages: Status --------
allocated queues = 0
used headers = 0
used space = 0 bytes
--//剩下kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
where
semmsl: The number of semaphores per set 每組信號量
semmns: The total number of semaphores available 可用信號量的總數
semopm: The number of operations which can be made per semaphore call 每個信號量呼叫可以執行的操作數。
semmni: The maximum number of shared memory segments available in the system 系統中可用的最大共用記憶體段數
--//(我覺得這裡是指信號量)。
1.環境:
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
SCOTT@book> show sga
Total System Global Area 643084288 bytes
Fixed Size 2255872 bytes
Variable Size 205521920 bytes
Database Buffers 427819008 bytes
Redo Buffers 7487488 bytes
SCOTT@book> show parameter processes
NAME TYPE VALUE
--------- ------- -----
processes integer 200
--//重新定義環境變數
export ORACLE_SID=book
--//順便說一下我的定義:kernel.sem = 2600 332800 2600 128
--//實際上我開始學oracle什麼都不懂,上新聞組問了這個問題,對方給我的解答.第一個參數與processes有關在此基礎上+10就可以.
--//第2個參數使用第1個參數*第4個參數 = 2600*128 = 332800.第3個參數他給我的建議等於第1個參數.
--//我當時什麼都不懂,既然對方這麼建議,按照對方建議先嘗試看看.以後也沒有在意這個參數,剩下的步驟copy and paste.
--//如果大家看我在單位安裝的伺服器,基本上這個參數都是這樣設置.經典copy and paste操作.
2.測試1:
$ ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 407011329 oracle 640 12582912 25
0x00000000 407044098 oracle 640 633339904 25
0xe8a8ec10 407076867 oracle 640 2097152 25
------ Semaphore Arrays --------
key semid owner perms nsems
0x6aa88594 328302592 oracle 640 204
------ Message Queues --------
key msqid owner perms used-bytes messages
$ ps -ef | egrep "[o]raclebook|ora_.*_boo[k]"|wc
25 201 1597
--//註意看Semaphore Arrays的nsems=204,也就是sem的數量.你可以測試如果processes增加,該數值也會增加相同的數量.
--//當然我當前設置kernel.sem的semmsl=2600,遠遠超出processes的數值,不會建立多個信號組.
$ ipcs -s -i 328302592 | awk '/semnum/,/^203/' | awk '$5>0 {print $5}' | sort | uniq -c
5 56258
1 56261
1 56263
1 56269
1 56273
1 56277
1 56279
1 56281
1 56283
1 56285
1 56287
1 56289
1 56291
1 56293
1 56295
1 56306
1 56307
1 56309
1 56311
1 56313
1 56321
1 56323
1 56325
1 56327
1 56329
1 pid
$ ipcs -s -i 328302592 | awk '/semnum/,/^203/' | awk '$5>0 '
semnum value ncount zcount pid
0 0 0 0 56258
1 2559 0 0 56258
2 19574 0 0 56258
3 1 0 0 56258
6 0 0 0 56261
7 0 1 0 56263
9 0 1 0 56269
11 0 1 0 56273
13 0 1 0 56277
14 0 1 0 56279
15 0 1 0 56281
16 0 1 0 56283
17 0 1 0 56285
18 0 1 0 56287
19 0 1 0 56289
20 0 1 0 56291
21 0 1 0 56293
22 0 1 0 56295
25 0 0 0 56307
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 0 1 0 56306
27 0 1 0 56309
28 0 1 0 56311
29 0 1 0 56313
30 0 1 0 56329
31 0 0 0 56327
32 0 0 0 56321
33 0 0 0 56323
34 0 0 0 56325
203 0 0 0 56258
--//semnum應該表示序號.pid對應進程號.其它value,ncount,zcount 表示什麼,不懂.
--//https://blog.csdn.net/macky0668/article/details/6839559
--//ncount列出等待信號量增加的進程的個數.
--//zcount列出正在等待信號量變成零的進程的個數
$ ps -fp 56307
UID PID PPID C STIME TTY TIME CMD
oracle 56307 56254 0 15:35 ? 00:00:00 oraclebook (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
--//疑問什麼情況下ncount=1,pid=56307.視乎是使用後信號量後才會增加.
$ ps -fp 56258
UID PID PPID C STIME TTY TIME CMD
$ ipcs -m -p
------ Shared Memory Creator/Last-op --------
shmid owner cpid lpid
407011329 oracle 56258 56458
407044098 oracle 56258 56458
407076867 oracle 56258 56458
--//Shared Memory Creator 的pid=56258,已經不存在.但是你可以發現Semaphore Array semid=328302592中占5行.
--//視乎前面的4行永遠不會覆蓋.也就是kernel.sem的semmsl大於processes+4才會僅僅使用Semaphore Arrays.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.sem = 100 332800 100 128
# sysctl -p
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.
$ ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
0x6aa88594 328433664 oracle 640 51
0x6aa88595 328466433 oracle 640 51
0x6aa88596 328499202 oracle 640 51
0x6aa88597 328531971 oracle 640 51
0x6aa88598 328564740 oracle 640 51
$ ipcs -u -m
------ Shared Memory Status --------
segments allocated 5
pages allocated 158305
pages resident 111201
pages swapped 0
Swap performance: 0 attempts 0 successes
--//建立了5個Semaphore Array,每個大小nsems=51.
--//為什麼不建立3個Semaphore Array,nsems=100或者70?
$ ipcs -m -p
------ Shared Memory Creator/Last-op --------
shmid owner cpid lpid
407142401 oracle 56667 56733
407175170 oracle 56667 56733
407207939 oracle 56667 56733
$ ipcs -s | awk '/0x/ {print $2}' | xargs -I {} ipcs -s -i {} | grep 56667
0 1 0 0 56667
1 2559 0 0 56667
2 19574 0 0 56667
3 1 0 0 56667
0 1 0 0 56667
1 2559 0 0 56667
2 19574 0 0 56667
3 1 0 0 56667
0 1 0 0 56667
1 2559 0 0 56667
2 19574 0 0 56667
3 1 0 0 56667
0 1 0 0 56667
1 2559 0 0 56667
2 19574 0 0 56667
3 1 0 0 56667
0 0 0 0 56667
1 2559 0 0 56667
2 19574 0 0 56667
3 1 0 0 56667
15 0 0 0 56667
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--//不知道它的具體演算法.視乎每個array前面4個都是建立pid.
--//貼一個processes=1000的情況,asm實例的processes=1320的情況
# grep "^kernel.s[eh]" /etc/sysctl.conf
kernel.shmmax = 61847529062
kernel.shmall = 15099494
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
$ ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
0x869d3e0c 163842 grid 640 165
0x869d3e0d 196611 grid 640 165
0x869d3e0e 229380 grid 640 165
0x869d3e0f 262149 grid 640 165
0x869d3e10 294918 grid 640 165
0x869d3e11 327687 grid 640 165
0x869d3e12 360456 grid 640 165
0x869d3e13 393225 grid 640 165
0x869d3e14 425994 grid 640 165
0x42dc1a48 2392075 oracle 640 250
0x42dc1a49 2424844 oracle 640 250
0x42dc1a4a 2457613 oracle 640 250
0x42dc1a4b 2490382 oracle 640 250
0x42dc1a4c 2523151 oracle 640 250
0x42dc1a4d 2555920 oracle 640 250
0x42dc1a4e 2588689 oracle 640 250
0x42dc1a4f 2621458 oracle 640 250
0x42dc1a50 2654227 oracle 640 250
$ ipcs -s -u
------ Semaphore Status --------
used arrays = 20
allocated semaphores = 3737
--//也不知道多個Semaphore Array對性能有什麼影響,視乎從來沒有人提到這樣對性能存在問題.我看了exadata的設置:
exadata# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmmax = 229982982348
kernel.shmall = 56148189
kernel.shmmni = 4096
kernel.sem = 1024 60000 1024 256
--//我個人感覺也許應該根據processes的數量適當調整,不要建立太多的Semaphore Array.
3.測試2:
--//最後測試kernel.sem的第4個參數SEMMNI.
kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
semmni: The maximum number of shared memory segments available in the system 系統中可用的最大共用記憶體段數
--//(我覺得這裡是指信號量)。
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.sem = 100 332800 100 4
# sysctl -p
SYS@book> startup
ORA-27154: post/wait create failed
ORA-27300: OS system dependent operation:semget failed with status: 28
ORA-27301: OS failure message: No space left on device
ORA-27302: failure occurred at: sskgpcreates
--//無法啟動資料庫.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.sem = 100 332800 100 5
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.
$ ipcs -a
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 407404545 oracle 640 12582912 25
0x00000000 407437314 oracle 640 633339904 25
0xe8a8ec10 407470083 oracle 640 2097152 25
------ Semaphore Arrays --------
key semid owner perms nsems
0x6aa88594 328925184 oracle 640 51
0x6aa88595 328957953 oracle 640 51
0x6aa88596 328990722 oracle 640 51
0x6aa88597 329023491 oracle 640 51
0x6aa88598 329056260 oracle 640 51
------ Message Queues --------
key msqid owner perms used-bytes messages
4.還原測試環境略.
# grep "^kernel.s[he]" /etc/sysctl.conf
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.sem = 2600 332800 2600 128
5.總結:
--//操作系統的許多東西自己還是存在許多不理解的情況,許多東西純粹自己在亂猜.畢竟不是自己的專業,需要慢慢積累學習提高.