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
root@10.1.1.45: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
root@10.1.1.45: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 root@10.1.1.45:log# ipcrm -s 131072root@10.1.1.45:log# ipcrm -s 163841root@10.1.1.45:log# ipcrm -s 65538root@10.1.1.45:log# ipcrm -s 98307root@10.1.1.45:~# 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
root@10.1.1.45:~# ipcs -l------ Shared Memory Limits --------max number of segments = 4096max seg size (kbytes) = 32768max total shared memory (kbytes) = 8388608min seg size (bytes) = 1------ Semaphore Limits --------max number of arrays = 128max semaphores per array = 250max semaphores system wide = 32000max ops per semop call = 32semaphore max value = 32767------ Messages: Limits --------max queues system wide = 16max size of message (bytes) = 8192default max size of queue (bytes) = 16384有2种方法改变其值
1.更改/etc/sysctl.conf ,添加kernel.msgmni = 1024,生效加载配置使用sysctl -p
kernel.msgmni 该文件指定消息队列标识的最大数目,即系统范围内最大多少个消息队列。
root@10.1.1.45:~# cat /proc/sys/kernel/msgmni16root@10.1.1.45:~# vim /etc/sysctl.conf root@10.1.1.45:~# sysctl -pkernel.msgmni = 1024root@10.1.1.45:~# cat /proc/sys/kernel/msgmni1024
2.在root下使用sysctl命令,直接生效.
root@10.1.1.45:~# sysctl -w kernel.msgmni=16kernel.msgmni = 16root@10.1.1.45:~# cat /proc/sys/kernel/msgmni16