Linux不能刪除共享內存

在VMware中,CentOS release 6.3 (Final)系統:
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux系統中,出現一個問題:
Linux不能刪除共享內存?

[root@localhost ~]# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 1835008    root       777        5242880    3          dest         
0x00000000 720898     root       777        5242880    1          dest         
0x00000000 1114115    root       777        5242880    17         dest         
0x00000000 1015812    root       777        5242880    10         dest         
0x00000000 1638405    root       777        5242880    12         dest         
0x00000000 1540102    root       777        5242880    7          dest         


執行ipcrm一直刪除,但卻始終刪除不了。
[root@localhost ~]# ipcrm -m 1835008
[root@localhost ~]# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x00000000 1835008    root       777        5242880    3          dest         
0x00000000 720898     root       777        5242880    1          dest         
0x00000000 1114115    root       777        5242880    17         dest         
0x00000000 1015812    root       777        5242880    10         dest         
0x00000000 1638405    root       777        5242880    12         dest         
0x00000000 1540102    root       777        5242880    7          dest   
結果還是一樣,刪除不了

這時候的key跟平常不一樣,key的值是0x00000000。找了很多資料,基本上只有幾個原因:1.權限問題;2.進程佔用。
我本身就是root,權限基本上是不沾邊了。
救世主命令:
[root@localhost seomanagerd]# ps -aux
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.1   2872  1428 ?        Ss   13:47   0:02 /sbin/init
root         2  0.0  0.0      0     0 ?        S    13:47   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    13:47   0:00 [migration/0]
root         4  0.0  0.0      0     0 ?        S    13:47   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S    13:47   0:00 [migration/0]
root         6  0.0  0.0      0     0 ?        S    13:47   0:00 [watchdog/0]
root         7  0.0  0.0      0     0 ?        S    13:47   0:00 [migration/1]
root         8  0.0  0.0      0     0 ?        S    13:47   0:00 [migration/1]
root         9  0.0  0.0      0     0 ?        S    13:47   0:00 [ksoftirqd/1]
root        10  0.0  0.0      0     0 ?        S    13:47   0:00 [watchdog/1]
root        11  0.0  0.0      0     0 ?        S    13:47   0:03 [events/0]
root        12  0.0  0.0      0     0 ?        S    13:47   0:02 [events/1]
root        13  0.0  0.0      0     0 ?        S    13:47   0:00 [cgroup]
root        14  0.0  0.0      0     0 ?        S    13:47   0:00 [khelper]
root        15  0.0  0.0      0     0 ?        S    13:47   0:00 [netns]
root        16  0.0  0.0      0     0 ?        S    13:47   0:00 [async/mgr]
root        17  0.0  0.0      0     0 ?        S    13:47   0:00 [pm]
root        18  0.0  0.0      0     0 ?        S    13:47   0:00 [sync_supers]
root        19  0.0  0.0      0     0 ?        S    13:47   0:00 [bdi-default]
root        20  0.0  0.0      0     0 ?        S    13:47   0:00 [kintegrityd/0]
root        21  0.0  0.0      0     0 ?        S    13:47   0:00 [kintegrityd/1]
root        22  0.0  0.0      0     0 ?        S    13:47   0:00 [kblockd/0]
root        23  0.0  0.0      0     0 ?        S    13:47   0:00 [kblockd/1]
root        24  0.0  0.0      0     0 ?        S    13:47   0:00 [kacpid]
root        25  0.0  0.0      0     0 ?        S    13:47   0:00 [kacpi_notify]
root        26  0.0  0.0      0     0 ?        S    13:47   0:00 [kacpi_hotplug]
root        27  0.0  0.0      0     0 ?        S    13:47   0:01 [ata/0]
root        28  0.0  0.0      0     0 ?        S    13:47   0:04 [ata/1]
root        29  0.0  0.0      0     0 ?        S    13:47   0:00 [ata_aux]
root        30  0.0  0.0      0     0 ?        S    13:47   0:00 [ksuspend_usbd]
root        31  0.0  0.0      0     0 ?        S    13:47   0:00 [khubd]
root        32  0.0  0.0      0     0 ?        S    13:47   0:00 [kseriod]
root        33  0.0  0.0      0     0 ?        S    13:47   0:00 [md/0]
root        34  0.0  0.0      0     0 ?        S    13:47   0:00 [md/1]
root        35  0.0  0.0      0     0 ?        S    13:47   0:00 [md_misc/0]
root        36  0.0  0.0      0     0 ?        S    13:47   0:00 [md_misc/1]
root        37  0.0  0.0      0     0 ?        S    13:47   0:00 [khungtaskd]
root        38  0.0  0.0      0     0 ?        S    13:47   0:00 [kswapd0]
root        39  0.0  0.0      0     0 ?        SN   13:47   0:00 [ksmd]
root        40  0.0  0.0      0     0 ?        S    13:47   0:00 [aio/0]
root        41  0.0  0.0      0     0 ?        S    13:47   0:00 [aio/1]
root        42  0.0  0.0      0     0 ?        S    13:47   0:00 [crypto/0]
root        43  0.0  0.0      0     0 ?        S    13:47   0:00 [crypto/1]
root        48  0.0  0.0      0     0 ?        S    13:47   0:00 [kthrotld/0]
root        49  0.0  0.0      0     0 ?        S    13:47   0:00 [kthrotld/1]
root        50  0.0  0.0      0     0 ?        S    13:47   0:00 [pciehpd]
root        52  0.0  0.0      0     0 ?        S    13:47   0:00 [kpsmoused]
root        53  0.0  0.0      0     0 ?        S    13:47   0:00 [usbhid_resumer]
root        83  0.0  0.0      0     0 ?        S    13:47   0:00 [kstriped]
root       209  0.0  0.0      0     0 ?        S    13:47   0:00 [scsi_eh_0]
root       219  0.0  0.0      0     0 ?        S    13:47   0:03 [scsi_eh_1]
root       253  0.0  0.0      0     0 ?        S    13:47   0:00 [mpt_poll_0]
root       254  0.0  0.0      0     0 ?        S    13:47   0:00 [mpt/0]
root       255  0.0  0.0      0     0 ?        S    13:47   0:00 [scsi_eh_2]
root       349  0.0  0.0      0     0 ?        S    13:47   0:00 [jbd2/sda2-8]
root       350  0.0  0.0      0     0 ?        S    13:47   0:00 [ext4-dio-unwrit]
root       351  0.0  0.0      0     0 ?        S    13:47   0:00 [ext4-dio-unwrit]
root       388  0.0  0.0      0     0 ?        S    13:47   0:00 [flush-8:0]
root       394  0.0  0.0      0     0 ?        S    13:47   0:02 [kauditd]
root       438  0.0  0.1   2892  1168 ?        S<s  13:47   0:00 /sbin/udevd -d
root       686  0.0  0.0      0     0 ?        S    13:47   0:00 [vmmemctl]
root      1054  0.0  0.1   2888  1224 ?        S<   13:47   0:00 /sbin/udevd -d
root      1112  0.0  0.0      0     0 ?        S    13:48   0:00 [jbd2/sda1-8]
root      1113  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1114  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1115  0.0  0.0      0     0 ?        S    13:48   0:00 [jbd2/sda8-8]
root      1116  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1117  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1118  0.0  0.0      0     0 ?        S    13:48   0:00 [jbd2/sda6-8]
root      1119  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1120  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1121  0.0  0.0      0     0 ?        S    13:48   0:00 [jbd2/sda3-8]
root      1122  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1123  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1124  0.0  0.0      0     0 ?        S    13:48   0:01 [jbd2/sda7-8]
root      1125  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1126  0.0  0.0      0     0 ?        S    13:48   0:00 [ext4-dio-unwrit]
root      1636  0.0  0.0  36440   816 ?        Ssl  13:48   0:00 /usr/sbin/vmware-vmblock-fuse -o subtype=vmware-vmblock,default_permissions,
root      1671  0.1  0.3  26984  3564 ?        S    13:48   0:17 /usr/sbin/vmtoolsd
root      1784  0.0  0.3  13056  3412 ?        Ss   13:48   0:00 cupsd -C /etc/cups/cupsd.conf
root      1808  0.0  0.0   2036   508 ?        Ss   13:48   0:00 /sbin/portreserve
root      1815  0.0  0.1  36972  1488 ?        Sl   13:48   0:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
rpc       1867  0.0  0.0   2556   812 ?        Ss   13:48   0:00 rpcbind
dbus      1883  0.0  0.1   3084  1096 ?        Ss   13:48   0:00 dbus-daemon --system
root      1905  0.0  0.4  21184  4240 ?        Ss   13:48   0:00 NetworkManager --pid-file=/var/run/NetworkManager/NetworkManager.pid
root      1913  0.0  0.2   4576  2232 ?        S    13:48   0:00 /usr/sbin/modem-manager
root      1919  0.0  0.1  12576  1396 ?        Ss   13:48   0:01 tpvmlpd2
avahi     1940  0.0  0.1   3100  1556 ?        S    13:48   0:00 avahi-daemon: running [linux.local]
avahi     1941  0.0  0.0   3100   356 ?        Ss   13:48   0:00 avahi-daemon: chroot helper
root      1963  0.0  0.0   7252   800 ?        Ss   13:48   0:00 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -B -u -f
rpcuser   1986  0.0  0.1   2820  1276 ?        Ss   13:48   0:00 rpc.statd
root      2100  0.0  0.0      0     0 ?        S    13:48   0:00 [rpciod/0]
root      2101  0.0  0.0      0     0 ?        S    13:48   0:00 [rpciod/1]
root      2105  0.0  0.0   2592   492 ?        Ss   13:48   0:00 rpc.idmapd
root      2114  0.0  0.0   2000   600 ?        Ss   13:48   0:00 /usr/sbin/acpid
68        2123  0.0  0.4   7116  4744 ?        Ss   13:48   0:00 hald
root      2124  0.0  0.1   3764  1108 ?        S    13:48   0:00 hald-runner
root      2164  0.0  0.1   3840  1140 ?        S    13:48   0:00 hald-addon-input: Listening on /dev/input/event2 /dev/input/event0
root      2165  0.0  0.1   3840  1044 ?        S    13:48   0:03 hald-addon-storage: polling /dev/sr0 (every 2 sec)
68        2175  0.0  0.1   3484  1060 ?        S    13:48   0:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
root      2197  0.0  0.1  14472  1544 ?        Ssl  13:48   0:00 pcscd
root      2213  0.0  0.1  30000  1580 ?        Ssl  13:48   0:01 automount --pid-file /var/run/autofs.pid
root      2238  0.0  0.0   8508  1012 ?        Ss   13:48   0:00 /usr/sbin/sshd
root      2275  0.0  0.1   5104  1432 ?        S    13:48   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysq
mysql     2576  0.1  2.9 343924 30860 ?        Sl   13:48   0:18 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/us
root      2688  0.0  0.2  13088  2688 ?        Ss   13:48   0:00 /usr/libexec/postfix/master
postfix   2695  0.0  0.2  13232  2680 ?        S    13:48   0:00 qmgr -l -t fifo -u
root      2712  0.0  0.0   5164   940 ?        Ss   13:48   0:00 /usr/sbin/abrtd
root      2720  0.0  0.0   5080   744 ?        Ss   13:48   0:00 abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages
root      2729  0.0  0.3  33568  3408 ?        Ss   13:48   0:01 php-fpm: master process (/etc/php-fpm.conf)
nginx     2730  0.0  0.4  38984  4728 ?        S    13:48   0:00 php-fpm: pool www
nginx     2731  0.0  0.4  38984  4220 ?        S    13:48   0:00 php-fpm: pool www
nginx     2732  0.0  0.4  38984  4728 ?        S    13:48   0:00 php-fpm: pool www
nginx     2733  0.0  0.4  38984  4356 ?        S    13:48   0:00 php-fpm: pool www
nginx     2734  0.0  0.4  38984  4728 ?        S    13:48   0:00 php-fpm: pool www
root      2746  0.0  0.1  14936  1444 ?        Ss   13:48   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx     2747  0.0  0.2  15100  2392 ?        S    13:48   0:03 nginx: worker process                   
root      2755  0.0  0.1   5912  1184 ?        Ss   13:48   0:00 crond
root      2764  0.0  0.3  22916  3260 ?        Ss   13:48   0:00 smbd -D
root      2775  0.0  0.0   2900   460 ?        Ss   13:48   0:00 /usr/sbin/atd
root      2784  0.0  0.1  22916  1444 ?        S    13:48   0:00 smbd -D
root      2796  0.0  0.5 136128  5712 ?        Sl   13:48   0:00 libvirtd --daemon
root      2828  0.0  0.1   2888  1176 ?        S<   13:48   0:00 /sbin/udevd -d
root      2875  0.0  0.0   4128   572 ?        S    13:48   0:03 /usr/sbin/cimserver
cimsrvr   2876  0.0  0.6  18620  6716 ?        Sl   13:48   0:00 cimservermain --executor-socket 3
nobody    2906  0.0  0.0   2624   556 ?        S    13:48   0:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvi
root      2944  0.0  0.0   7876   752 ?        Ss   13:48   0:00 /usr/sbin/certmonger -S -p /var/run/certmonger.pid
root      2981  0.0  0.0   1988   480 tty1     Ss+  13:48   0:00 /sbin/mingetty /dev/tty1
root      2983  0.0  0.0   1988   480 tty2     Ss+  13:48   0:00 /sbin/mingetty /dev/tty2
root      2985  0.0  0.0   1988   480 tty3     Ss+  13:48   0:00 /sbin/mingetty /dev/tty3
root      2987  0.0  0.0   1988   480 tty4     Ss+  13:48   0:00 /sbin/mingetty /dev/tty4
root      2989  0.0  0.0   1988   512 tty5     Ss+  13:48   0:00 /sbin/mingetty /dev/tty5
root      2991  0.0  0.0   1988   480 tty6     Ss+  13:48   0:00 /sbin/mingetty /dev/tty6
root      3009  0.0  0.0  12912   808 ?        S<sl 13:48   0:00 auditd
root      3028  0.0  0.3  11596  3456 ?        Rs   13:49   0:08 sshd: root@pts/0 
root      3030  0.0  0.1   5240  1776 pts/0    Ss   13:49   0:00 -bash
root      3031  0.0  0.3  11596  3444 ?        Ss   13:49   0:00 sshd: root@pts/2 
root      3048  0.0  0.3  11596  3456 ?        Ss   13:49   0:00 sshd: root@pts/1 
root      3054  0.0  0.1   5236  1708 pts/1    Ss+  13:49   0:00 -bash
root      3074  0.1  0.3  23336  4024 ?        S    13:49   0:11 smbd -D
root      3075  0.0  0.1   5240  1784 pts/2    Ss+  13:49   0:00 -bash
nginx     3359  0.0  0.4  38984  4728 ?        S    13:56   0:00 php-fpm: pool www
nginx     5249  0.0  0.4  38984  4212 ?        S    14:35   0:00 php-fpm: pool www
nginx     5747  0.0  0.4  38984  4728 ?        S    14:48   0:00 php-fpm: pool www
nginx     5754  0.0  0.3  38984  3968 ?        S    14:49   0:00 php-fpm: pool www
nginx     5763  0.0  0.3  38984  3968 ?        S    14:50   0:00 php-fpm: pool www
nginx     5771  0.0  0.3  38984  3968 ?        S    14:51   0:00 php-fpm: pool www
nginx     5777  0.0  0.3  38984  3968 ?        S    14:52   0:00 php-fpm: pool www
nginx     5782  0.0  0.4  38984  4212 ?        S    14:53   0:00 php-fpm: pool www
nginx     5789  0.0  0.4  38984  4732 ?        S    14:54   0:00 php-fpm: pool www
nginx     5797  0.0  0.4  38984  4220 ?        S    14:55   0:00 php-fpm: pool www
nginx     5871  0.0  0.4  38984  4292 ?        S    14:56   0:00 php-fpm: pool www
nginx     6535  0.0  0.4  38984  4728 ?        S    15:04   0:00 php-fpm: pool www
nginx     6654  0.0  0.4  38984  4200 ?        S    15:07   0:00 php-fpm: pool www
nginx     6663  0.0  0.4  38984  4308 ?        S    15:08   0:00 php-fpm: pool www
nginx     6671  0.0  0.4  38984  4748 ?        S    15:09   0:00 php-fpm: pool www
nginx     6747  0.0  0.4  38984  4212 ?        S    15:10   0:00 php-fpm: pool www
nginx     7144  0.0  0.3  38984  3972 ?        S    15:15   0:00 php-fpm: pool www
nginx     7150  0.0  0.3  38984  3972 ?        S    15:16   0:00 php-fpm: pool www
nginx     7169  0.0  0.3  38984  3972 ?        S    15:19   0:00 php-fpm: pool www
nginx     7178  0.0  0.3  38984  3972 ?        S    15:20   0:00 php-fpm: pool www
nginx     7185  0.0  0.3  38984  3972 ?        S    15:21   0:00 php-fpm: pool www
nginx     7192  0.0  0.3  38984  3972 ?        S    15:22   0:00 php-fpm: pool www
nginx     7199  0.0  0.4  38984  4188 ?        S    15:23   0:00 php-fpm: pool www
nginx     7207  0.0  0.4  38984  4748 ?        S    15:24   0:00 php-fpm: pool www
nginx     7214  0.0  0.4  38984  4752 ?        S    15:25   0:00 php-fpm: pool www
nginx     7221  0.0  0.4  38984  4752 ?        S    15:26   0:00 php-fpm: pool www
nginx     7228  0.0  0.4  38984  4752 ?        S    15:27   0:00 php-fpm: pool www
postfix   7232  0.0  0.2  13164  2640 ?        S    15:28   0:00 pickup -l -t fifo -u
nginx     7542  0.0  0.4  38984  4212 ?        S    15:29   0:00 php-fpm: pool www
nginx     8887  0.0  0.4  38984  4188 ?        S    15:38   0:00 php-fpm: pool www
nginx     8893  0.0  0.4  38984  4192 ?        S    15:39   0:00 php-fpm: pool www
nginx     8901  0.0  0.4  38984  4740 ?        S    15:41   0:00 php-fpm: pool www
nginx     8908  0.0  0.4  38984  4236 ?        S    15:42   0:00 php-fpm: pool www
nginx     9219  0.0  0.4  38984  4216 ?        S    15:42   0:00 php-fpm: pool www
nginx     9227  0.0  0.4  38984  4220 ?        S    15:43   0:00 php-fpm: pool www
nginx     9232  0.0  0.4  38984  4220 ?        S    15:44   0:00 php-fpm: pool www
nginx     9549  0.0  0.4  38984  4740 ?        S    15:47   0:00 php-fpm: pool www
nginx     9975  0.0  0.3  38984  3972 ?        S    15:56   0:00 php-fpm: pool www
nginx     9982  0.0  0.3  38984  3972 ?        S    15:57   0:00 php-fpm: pool www
nginx     9989  0.0  0.3  38984  3972 ?        S    15:58   0:00 php-fpm: pool www
nginx     9995  0.0  0.3  38984  3972 ?        S    15:59   0:00 php-fpm: pool www
nginx    10004  0.0  0.3  38984  3972 ?        S    16:00   0:00 php-fpm: pool www
nginx    10025  0.0  0.3  38984  3976 ?        S    16:01   0:00 php-fpm: pool www
nginx    10038  0.0  0.4  38984  4744 ?        S    16:03   0:00 php-fpm: pool www
nginx    10045  0.0  0.4  38984  4744 ?        S    16:04   0:00 php-fpm: pool www
nginx    10053  0.0  0.4  38984  4724 ?        S    16:05   0:00 php-fpm: pool www
root     11830  7.0  0.1   4912  1052 pts/0    R+   16:42   0:00 ps -aux
發現php-fpm不正常,很多php-fpm服務說明沒有退出,於是重啓php-fpm服務
[root@localhost seomanagerd]# /etc/init.d/php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]
再執行
[root@localhost seomanagerd]# ps -aux
php-fpm只剩下幾個了,這時候查看共享內存:
[root@localhost ~]# ipcs -m

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

正常,原因就是:共享內存雖然被刪除了,但進程仍然佔用着共享內存,所以纔出現key爲0x00000000的現象。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章