暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

linux ipcs的使用-1

小柠檬 2025-01-06
59

使用ipcs命令,不加如何参数时,会把共享内存、信号量、消息队列的信息都打印出来,如果只想显示共享内存信息,使用如下命令:

[root@dbserver ~]# ipcs -m


------ Shared Memory Segments --------

key        shmid      owner      perms      bytes      nattch     status     

0x6c6c6536 0          root       600        4096       0                       

0x00000000 131073     root       600        393216     2          dest         

0x00000000 163842     root       600        393216     2          dest         

0x00000000 196611     root       600        393216     2          dest         

0x00000000 229380     root       600        393216     2          dest         

0x00000000 262149     root       600        393216     2          dest         

0x00000000 294918     root       600        393216     2          dest         

0x00000000 327687     root       600        393216     2          dest         

0x00000000 360456     root       600        393216     2          dest         

0x00000000 393225     root       600        393216     2          dest         

0x00000000 425994     root       600        393216     2          dest         

0x00000000 458763     root       600        393216     2          dest         

0x00000000 491532     root       600        393216     2          dest         

0x00000000 851981     oracle     640        4096       0                       

0x00000000 884750     oracle     640        4096       0                       

0x29f7a5c4 917519     oracle     640        4096       0                       

0x00000000 655376     root       600        393216     2          dest         

0x00000000 688145     root       600        393216     2          dest         

0x00000000 720914     root       600        393216     2          dest         

0x00000000 753683     root       600        393216     2          dest         

0x00000000 786452     root       600        393216     2          dest


ipcs的帮助手册

[root@dbserver ~]# man ipcs

IPCS(1)                    Linux Programmer’s Manual                   IPCS(1)


NAME

       ipcs - provide information on ipc facilities


SYNOPSIS

       ipcs [-asmq] [-tclup]

       ipcs [-smq] -i id

       ipcs -h


DESCRIPTION

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


       The -i option allows a specific resource id to be specified.  Only information on this id will be printed.


       Resources may be specified as follows:


       -m     shared memory segments


       -q     message queues


       -s     semaphore arrays


       -a     all (this is the default)


       The output format may be specified as follows:


       -t     time


       -p     pid


       -c     creator


       -l     limits


       -u     summary


SEE ALSO

       ipcrm(1), ipcmk(1)


CONFORMING TO

       The  Linux  ipcs utility is not fully compatible to the POSIX ipcs utility.  The Linux version does not support

       the -b and -o options, but does support the -l and -u options not defined by POSIX.  The  portable  application

       shall not use the -a, -b, -o, -l, and -u options.


AUTHOR

       krishna balasubramanian (balasub@cis.ohio-state.edu)


AVAILABILITY

       The   ipcs   command   is   part   of   the   util-linux-ng   package  and  is  available  from  ftp://ftp.ker-

       nel.org/pub/linux/utils/util-linux-ng/.


Linux 0.99                      9 October 1993                         IPCS(1)


使用举例:

 

[root@dbserver ~]# ipcs -sa


------ Shared Memory Segments --------

key        shmid      owner      perms      bytes      nattch     status     

0x6c6c6536 0          root       600        4096       0                       

0x00000000 131073     root       600        393216     2          dest         

0x00000000 163842     root       600        393216     2          dest         

0x00000000 196611     root       600        393216     2          dest         

0x00000000 229380     root       600        393216     2          dest         

0x00000000 262149     root       600        393216     2          dest         

0x00000000 294918     root       600        393216     2          dest         

0x00000000 327687     root       600        393216     2          dest         

0x00000000 360456     root       600        393216     2          dest         

0x00000000 393225     root       600        393216     2          dest         

0x00000000 425994     root       600        393216     2          dest         

0x00000000 458763     root       600        393216     2          dest         

0x00000000 491532     root       600        393216     2          dest         

0x00000000 851981     oracle     640        4096       0                       

0x00000000 884750     oracle     640        4096       0                       

0x29f7a5c4 917519     oracle     640        4096       0                       

0x00000000 655376     root       600        393216     2          dest         

0x00000000 688145     root       600        393216     2          dest         

0x00000000 720914     root       600        393216     2          dest         

0x00000000 753683     root       600        393216     2          dest         

0x00000000 786452     root       600        393216     2          dest         


------ Semaphore Arrays --------

key        semid      owner      perms      nsems     

0x00000000 0          root       600        1         

0x00000000 65537      root       600        1         

0x7f51ec7c 360450     oracle     640        154       


------ Message Queues --------

key        msqid      owner      perms      used-bytes   messages   


参数含义:

key: 共享内存的key

shmid:表示共享内存段id

owner:表示共享内存段属于哪个用户

perms:需要注意的是默认情况下600表示除root用户外不允许其他用户查看

bytes:表示共享内存段大小

nattch:表示连接到共享内存段的进程数

status:表示共享内存段的状态,dest表示该内存段被标记为destroyed状态。 其中显示“dest”表示共享内存段已经被删除,但是还有用户在使用它,当该段内存的mode字段设置为SHM_DEST时就会显示“dest”。当用户调用shmctl的IPC_RMID时,内存先查看多少个进程与这个内存关联着,如果关联数为0,就会销毁这段共享内存,否者设置这段内存的mod的mode位为SHM_DEST,如果所有进程都不用则删除这段共享内存。







「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论