在linux下查看有哪些操作系统进程正在使用某一个共享内存段

[root@abc log]# ipcs -m
------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x0052e2c1 0          highgo432  600        56         5                       
0x00000000 65537      oracle     640        12582912   26                      
0x00000000 98306      oracle     640        511705088  26                      
0x0447bbc8 131075     oracle     640        2097152    26                 
说明:shmid是65537的共享内存段的nattch值为26,也就是说此时有26个操作系统进程attach到本共享内存段中,
那怎么找到是哪26个进程呢?使用如下命令即可:
[root@abc log]# lsof | egrep "65537"
oracle     3174    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3176    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3178    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3182    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3184    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3186    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3188    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3190    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3192    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3194    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3196    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3198    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3200    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3202    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3204    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3206    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3208    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3214    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3222    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3231    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3235    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3240    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle     3282    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle    10227    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle    10229    oracle  DEL       REG                0,4                65537 /SYSV00000000
oracle    10647    oracle  DEL       REG                0,4                65537 /SYSV00000000
[root@abc log]# 
看看这些进程是什么进程:
[root@abc log]# ps -ef | grep 10227
oracle    10227      1  0 15:56 ?        00:00:00 oracleorcl (LOCAL=NO)
root      10677   8485  0 17:28 pts/1    00:00:00 grep 10227
[root@abc log]# ps -ef | grep 31
root         31      2  0 Jun05 ?        00:00:00 [events_power_ef]
root        131      2  0 Jun05 ?        00:00:00 [kstriped]
root        431      2  0 Jun05 ?        00:00:00 [scsi_eh_18]
root        444      2  0 Jun05 ?        00:00:00 [scsi_eh_31]
root       3122   2144  0 Jun05 tty1     00:00:00 -bash
root       3141   3122  0 Jun05 tty1     00:00:00 su - oracle
oracle     3142   3141  0 Jun05 tty1     00:00:00 -bash
oracle     3167      1  0 Jun05 ?        00:00:03 /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr LISTENER -inherit 
oracle     3170   3142  0 Jun05 tty1     00:00:00 sqlplus   as sysdba
oracle     3174      1  0 Jun05 ?        00:00:09 ora_pmon_orcl   ---->>>oracle后台进程
oracle     3176      1  0 Jun05 ?        00:00:17 ora_psp0_orcl   ---->>>oracle后台进程
oracle     3178      1  1 Jun05 ?        00:22:40 ora_vktm_orcl   ---->>>oracle后台进程
oracle     3182      1  0 Jun05 ?        00:00:02 ora_gen0_orcl   ---->>>oracle后台进程
oracle     3184      1  0 Jun05 ?        00:00:04 ora_diag_orcl   ---->>>oracle后台进程
oracle     3186      1  0 Jun05 ?        00:00:04 ora_dbrm_orcl   ---->>>oracle后台进程
oracle     3188      1  0 Jun05 ?        00:01:21 ora_dia0_orcl   ---->>>oracle后台进程
oracle     3190      1  0 Jun05 ?        00:00:03 ora_mman_orcl   ---->>>oracle后台进程
oracle     3192      1  0 Jun05 ?        00:00:06 ora_dbw0_orcl   ---->>>oracle后台进程
oracle     3194      1  0 Jun05 ?        00:00:04 ora_lgwr_orcl   ---->>>oracle后台进程
oracle     3196      1  0 Jun05 ?        00:00:31 ora_ckpt_orcl   ---->>>oracle后台进程
oracle     3198      1  0 Jun05 ?        00:00:04 ora_smon_orcl   ---->>>oracle后台进程
oracle     3214   3170  0 Jun05 ?        00:00:08 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle     3231      1  0 Jun05 ?        00:00:02 ora_q000_orcl
root      10680   8485  0 17:28 pts/1    00:00:00 grep 31
[root@abc log]# 
[root@abc log]# ps -ef | grep 32
root         32      2  0 Jun05 ?        00:00:00 [events_power_ef]
root        432      2  0 Jun05 ?        00:00:00 [scsi_eh_19]
root        445      2  0 Jun05 ?        00:00:00 [scsi_eh_32]
root       1332      2  0 Jun05 ?        00:00:00 [kauditd]
oracle     3200      1  0 Jun05 ?        00:00:01 ora_reco_orcl   ---->>>oracle后台进程
oracle     3202      1  0 Jun05 ?        00:00:16 ora_mmon_orcl   ---->>>oracle后台进程
oracle     3204      1  0 Jun05 ?        00:00:45 ora_mmnl_orcl   ---->>>oracle后台进程
oracle     3206      1  0 Jun05 ?        00:00:01 ora_d000_orcl   ---->>>oracle后台进程
oracle     3208      1  0 Jun05 ?        00:00:01 ora_s000_orcl   ---->>>oracle后台进程
oracle     3214   3170  0 Jun05 ?        00:00:08 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle     3222      1  0 Jun05 ?        00:00:02 ora_qmnc_orcl   ---->>>oracle后台进程
oracle     3231      1  0 Jun05 ?        00:00:02 ora_q000_orcl   ---->>>oracle后台进程
oracle     3235      1  0 Jun05 ?        00:00:00 ora_q001_orcl   ---->>>oracle后台进程
oracle     3240      1  0 Jun05 ?        00:00:11 ora_cjq0_orcl   ---->>>oracle后台进程
oracle     3282      1  0 Jun05 ?        00:00:02 ora_smco_orcl   ---->>>oracle后台进程
root      10698   8485  0 17:31 pts/1    00:00:00 grep 32
[root@abc log]# 
[root@abc log]# ps -ef | grep 10227
oracle    10227      1  0 15:56 ?        00:00:00 oracleorcl (LOCAL=NO)
root      10703   8485  0 17:32 pts/1    00:00:00 grep 10227
[root@abc log]# ps -ef | grep 10229
oracle    10229      1  0 15:56 ?        00:00:00 oracleorcl (LOCAL=NO)
root      10705   8485  0 17:32 pts/1    00:00:00 grep 10229
[root@abc log]# ps -ef | grep 10647
oracle    10647      1  0 17:22 ?        00:00:00 ora_w000_orcl
root      10707   8485  0 17:32 pts/1    00:00:00 grep 10647
[root@abc log]# 
参考自:
https://access.redhat.com/solutions/44861
How to find a process using the ipcs shared memory segment

你可能感兴趣的:(Oracle,DB,PostgreSQL,Linux,RHEL7,RHEL6,RHEL5,linux,process,使用,共享内存段)