Linux操作系统ipcs命令
ipcs: 主要提供调用进程读取访问一些ipc设备信息.如:共享内存,信号量,消息队列
ipcs [ -asmq ] [ -tclup ]
ipcs [ -smq ] -i id
-m 输出共享内存(shared memory segments)的信息
-s 输出信号量(semaphore)的信息
-q 输出消息队列(message queues)的信息
-l limits
01
root@10.1.1.45:log# ipcs
02
03
------ Shared Memory Segments --------
04
key shmid owner perms bytes nattch status
05
06
------ Semaphore Arrays --------
07
key semid owner perms nsems
08
0x00002af9 131072 db 664 1
09
0x00002afb 163841 db 664 1
10
0x00002b03 65538 db 664 1
11
0x00002b05 98307 db 664 1
12
13
------ Message Queues --------
14
key msqid owner perms used-bytes messages
其中Key为应用程序存取资源使用的参数,id为资源条目的唯一标示号.
例如实际情况可能会遇到db用户程序是用root账户启动,这时首先root账户关掉db用户的程序,但共享内存有可能未释放,需要手动删除.这就要用到ipcrm 命令.
ipcrm - remove a message queue, semaphore set or shared memory id
ipcrm [ -M key | -m id | -Q key | -q id | -S key | -s id ]
-m shmid
-q msqid
-s semid
01
root@10.1.1.45:log# ipcs -s
02
03
------ Semaphore Arrays --------
04
key semid owner perms nsems
05
0x00002af9 131072 db 664 1
06
0x00002afb 163841 db 664 1
07
0x00002b03 65538 db 664 1
08
0x00002b05 98307 db 664 1
09
10
root@10.1.1.45:log# ipcrm -s 131072
11
root@10.1.1.45:log# ipcrm -s 163841
12
root@10.1.1.45:log# ipcrm -s 65538
13
root@10.1.1.45:log# ipcrm -s 98307
14
15
root@10.1.1.45:~# ipcs
16
17
------ Shared Memory Segments --------
18
key shmid owner perms bytes nattch status
19
20
------ Semaphore Arrays --------
21
key semid owner perms nsems
22
23
------ Message Queues --------
24
key msqid owner perms used-bytes messages
01
root@10.1.1.45:~# ipcs -l
02
03
------ Shared Memory Limits --------
04
max number of segments = 4096
05
max seg size (kbytes) = 32768
06
max total shared memory (kbytes) = 8388608
07
min seg size (bytes) = 1
08
09
------ Semaphore Limits --------
10
max number of arrays = 128
11
max semaphores per array = 250
12
max semaphores system wide = 32000
13
max ops per semop call = 32
14
semaphore max value = 32767
15
16
------ Messages: Limits --------
17
max queues system wide = 16
18
max size of message (bytes) = 8192
19
default max size of queue (bytes) = 16384
有2种方法改变其值
1.更改/etc/sysctl.conf ,添加kernel.msgmni = 1024,生效加载配置使用sysctl -p
kernel.msgmni 该文件指定消息队列标识的最大数目,即系统范围内最大多少个消息队列。
1
root@10.1.1.45:~# cat /proc/sys/kernel/msgmni
2
16
3
root@10.1.1.45:~# vim /etc/sysctl.conf
4
root@10.1.1.45:~# sysctl -p
5
kernel.msgmni = 1024
6
root@10.1.1.45:~# cat /proc/sys/kernel/msgmni
7
1024
2.在root下使用sysctl命令,直接生效.
1
root@10.1.1.45:~# sysctl -w kernel.msgmni=16
2
kernel.msgmni = 16
3
root@10.1.1.45:~# cat /proc/sys/kernel/msgmni
4
16