ipcs命令

ipcs provides information on the ipc facilities for which the calling process has read access.

ipcs: 主要提供调用进程读取访问一些ipc设备信息.如:共享内存,信号量,消息队列

ipcs [ -asmq ] [ -tclup ]

ipcs [ -smq ] -i id

-m 输出共享内存(shared memory segments)的信息

-s 输出信号量(semaphore)的信息

-q 输出消息队列(message queues)的信息

-l limits

[email protected]:log# ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0x00002af9 131072     db        664        1         
0x00002afb 163841     db        664        1         
0x00002b03 65538      db        664        1         
0x00002b05 98307      db        664        1         

------ Message Queues --------
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

[email protected]:log# ipcs -s

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0x00002af9 131072     db        664        1         
0x00002afb 163841     db        664        1         
0x00002b03 65538      db        664        1         
0x00002b05 98307      db        664        1 

[email protected]:log# ipcrm -s 131072
[email protected]:log# ipcrm -s 163841
[email protected]:log# ipcrm -s 65538
[email protected]:log# ipcrm -s 98307

[email protected]:~# ipcs 

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages    

[email protected]:~# ipcs -l

------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 32768
max total shared memory (kbytes) = 8388608
min seg size (bytes) = 1

------ Semaphore Limits --------
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767

------ Messages: Limits --------
max queues system wide = 16
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
有2种方法改变其值

1.更改/etc/sysctl.conf ,添加kernel.msgmni = 1024,生效加载配置使用sysctl -p

kernel.msgmni 该文件指定消息队列标识的最大数目,即系统范围内最大多少个消息队列。

[email protected]:~# cat /proc/sys/kernel/msgmni
16
[email protected]:~# vim /etc/sysctl.conf 
[email protected]:~# sysctl -p
kernel.msgmni = 1024
[email protected]:~# cat /proc/sys/kernel/msgmni
1024

2.在root下使用sysctl命令,直接生效.

[email protected]:~# sysctl -w kernel.msgmni=16
kernel.msgmni = 16
[email protected]:~# cat /proc/sys/kernel/msgmni
16



你可能感兴趣的:(ipcs)