[20191119]探究ipcs命令输出2.txt
[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.总结:
--//操作系统的许多东西自己还是存在许多不理解的情况,许多东西纯粹自己在乱猜.毕竟不是自己的专业,需要慢慢积累学习提高.
以上是 [20191119]探究ipcs命令输出2.txt 的全部内容, 来源链接: utcz.com/z/531428.html