ipcs命令

seagull76發表於2008-08-21
1.ipcs 命令解釋

用途報告程式間通訊設施狀態。

語法
ipcs [ -m] [ -q] [ -s] [ -S] [ -P] [ -l] [ -a | -b -c -o -p -t] [ -T] [ -C CoreFile] [ -N Kernel ] [ -X ]
Flags
-a 相當於使用了-b ,-c,-o,-p,-t標誌
-b
Writes the maximum number of bytes in messages on queue for message queues, the size of segments for shared
memory, and the number of semaphores in each semaphores set.
-c
Writes the login name and group name of the user that made the facility.
-o
Writes the following usage information:
* Number of messages on queue
* Total number of bytes in messages in queue for message queues
* Number of processes attached to shared memory segments
-p
Writes process number information:
* Process number of the last process to receive a message on message queues
* Process number of last process to send a message on message queues
* Process number of the creating process
* Process number of last process to attach or detach on shared memory segments
-t
Writes time information:
* Time of the last control operation that changed the access permissions for all facilities
* Time of the last msgsnd and msgrcv on message queues
* Time of the last shmat and shmdt on shared memory
* Time of the last semop on semaphore sets

描述
ipcs 命令往標準輸出寫入一些關於活動程式間通訊設施的資訊。如果沒有指定標誌,ipcs 命令用簡短格式寫入一些關於當前活動訊息佇列、共享記憶體段、訊號量、遠端佇列和本地佇列標題。

列標題和在 ipcs 命令中的列的含義列在下面。圓括號內的字母表示導致對應的報頭出現的標誌。all 設計符表示始終顯示報頭。這些標誌僅僅確定提供給每個裝置何種資訊。但它們並不確定將列出哪些裝置。

T (all)設施的型別。共有三種設施型別:
q
訊息佇列
m
共享記憶體段
s
訊號量
ID (all)設施項的標識。
KEY (all)用作 msgget 子例程、semget 子例程或者 shmget 子例程的引數的鍵構成了設施項。

注: 當刪除記憶體段時,共享記憶體段的金鑰改變為 IPC_PRIVATE,直到所有附加在段上的程式和它拆離。
MODE (all)設施訪問方式和標誌。這種方式由 11 個字元組成,解釋如下:
前兩個字元如下所示:

R
如果程式在等待 msgrcv 系統呼叫。
S
如果程式在等待 msgsnd 系統呼叫。
D
如果有關的共享記憶體段被刪除。當附加在段上的最後一個程式拆離後它就會消失。
C
當第一個附加程式執行時,如果有關的共享記憶體段被清空。
-
如果沒有設定相應的特定標誌。
接下來的九個字元作為每三個一組解釋。第一組是指擁有者有許可權;第二組是指在設施項的使用者組中其他使用者的許可權;最後一組指所有的使用者。在每組中,第一個字元表示允許讀取,第二個字元表示可以寫或者修改設施項,最後一個字元當前沒有用過。

許可權如下所示:

r
如果授予了讀許可權。
w
如果授予了寫許可權。
a
如果授予了修改許可權。
-
如果沒有授予指定的許可權。
OWNER (all)設施項所有者的登入名。
GROUP (all)擁有設施項的組名。
CREATOR (a、c)設施項建立者的登入名。
CGROUP (a、c)設施項建立者的組名。

注: 對於 OWNER、GROUP、CREATOR 和 CGROUP,顯示使用者和組的標識而不顯示登入名。
CBYTES (a、o)當前停留在相關訊息佇列中的訊息的位元組數。
QNUM (a、o)當前停留在相關訊息佇列中的訊息的位元組數。
QBYTES (a、b)停留在相關訊息佇列中訊息允許的最大位元組數。
LSPID (a、p)傳送訊息到相關佇列的最後程式的標識。如果傳送的最後一條訊息是來自節點上的程式而不是保留該節點的佇列,LSPID 是真正把訊息放進佇列的核心程式的 PID,而不是傳送程式的 PID。
LRPID (a、p)接收來自相關佇列的訊息的程式標識。如果接收的最後一條訊息來自一個節點上的程式而不是保留該佇列的節點,LRPID 是真正接收佇列上訊息的核心程式的 PID,而不是接收程式的 PID。
STIME (a、t)最後一條訊息傳送到相關佇列的時間。對於遠端佇列來說,這是伺服器時間。沒有做任何措施來補償本地時鐘和伺服器時鐘之間的時區差異。
RTIME (a、t)接受最後一條來自相關佇列的訊息的時間。對於遠端佇列來說,這是伺服器時間。沒有做任何措施來補償本地時鐘和伺服器始終之間的時區差異。
CTIME (a、t)建立和改變相關項的時間。對於遠端佇列來說,這是伺服器時間。沒有做任何措施來補償本地時鐘和伺服器始終之間的時區差異。
NATTCH (a、o)連線在關聯的共享記憶體段的程式數。
SEGSZ (a、b)關聯的共享記憶體段的大小。
CPID (a、p)共享記憶體項的建立程式的程式標識。
LPID (a、p)連線或者拆離共享記憶體段的最後一個程式的標識。
ATIME (a、t)最後一次與關聯的共享記憶體段完成連線的時間。
DTIME (a、t)最後一次與關聯的共享記憶體段完成拆離的時間。
NSEMS (a、b)在與訊號項相關聯的訊號集中的訊號量數量。
OTIME (a、t)在關聯的訊號量中完成訊號量操作的時間。
SID (S)共享記憶體段的標識。SID 可以用作 svmon -S 命令的輸入。
2.示例
# ipcs
IPC status from /dev/mem as of Thu Jan 10 11:13:27 BEIST 2008
T ID KEY MODE OWNER GROUP
Message Queues:
Shared Memory:
m 0 0x580010f7 --rw-rw-rw- root system
m 1048577 0xffffffff --rw-rw---- root system
m 1048578 0x7800000d --rw-rw-rw- root system
m 1048579 0x0d000c07 --rw-rw---- root system
m 4 0x670010a1 --rw-r--r-- root system
m 5 0x680010a1 --rw-r--r-- root system
m 6 0x700010a1 --rw------- root system
m 7 0xffffffff --rw-rw---- root haemrm
m 3145736 0xdc4c5ae4 --rw-r----- oracle oinstall
m 9 0xffffffff --rw-rw---- root system
Semaphores:
s 2097152 0x580010f7 --ra-ra-ra- root system
s 1 0x440010f7 --ra-ra-ra- root system
s 1048578 0x0100003c --ra------- root system
s 3 0x620002cc --ra-r--r-- root system
s 4 0x690010a1 --ra-ra-ra- root system
s 5 0x5800106e --ra-ra-r-- root system
s 6 0x0101c6e8 --ra-ra-ra- root system
#
# ipcs -m
IPC status from /dev/mem as of Thu Jan 10 11:13:35 BEIST 2008
T ID KEY MODE OWNER GROUP
Shared Memory:
m 0 0x580010f7 --rw-rw-rw- root system
m 1048577 0xffffffff --rw-rw---- root system
m 1048578 0x7800000d --rw-rw-rw- root system
m 1048579 0x0d000c07 --rw-rw---- root system
m 4 0x670010a1 --rw-r--r-- root system
m 5 0x680010a1 --rw-r--r-- root system
m 6 0x700010a1 --rw------- root system
m 7 0xffffffff --rw-rw---- root haemrm
m 3145736 0xdc4c5ae4 --rw-r----- oracle oinstall
m 9 0xffffffff --rw-rw---- root system
#
# ipcs -am
IPC status from /dev/mem as of Thu Jan 10 11:13:54 BEIST 2008
T ID KEY MODE OWNER GROUP CREATOR CGROUP NATTCH SEGSZ CPID LPID ATIME DTIME CTIME
Shared Memory:
m 0 0x580010f7 --rw-rw-rw- root system root system 1 134217728 184778 184778 18:12:56 no-entry 18:12:56
m 1048577 0xffffffff --rw-rw---- root system root system 1 4096 241704 241704 11:12:09 11:12:09 18:13:56
m 1048578 0x7800000d --rw-rw-rw- root system root system 2 16777216 229636 840142 13:09:59 13:11:07 18:13:46
m 1048579 0x0d000c07 --rw-rw---- root system root system 3 1440 282884 844016 11:06:48 11:06:48 18:13:38
m 4 0x670010a1 --rw-r--r-- root system root system 3 12 385454 483634 18:18:39 18:18:34 18:18:32
m 5 0x680010a1 --rw-r--r-- root system root system 3 106548 385454 483634 18:18:39 18:18:34 18:18:32
m 6 0x700010a1 --rw------- root system root system 3 3168 385454 483634 18:18:39 18:18:34 18:18:32
m 7 0xffffffff --rw-rw---- root haemrm root haemrm 1 4096 483634 483634 11:12:28 11:12:28 18:18:40
m 3145736 0xdc4c5ae4 --rw-r----- oracle oinstall oracle oinstall 112 8589955072 303200 1020402 11:07:42 11:08:42 14:08:00
m 9 0xffffffff --rw-rw---- root system root system 1 8192 241704 241704 11:13:28 11:13:28 18:21:03
#
PS:
在oracle執行過程中,會出現oracle程式突然down掉,但共享記憶體段依然存在的情況,這是一種非正常的資料庫crash,需要用ipcrm命令來清除掉系統中存在的oracle共享記憶體(即SGA)
ipcrm的命令幫助如下:
#man ipcrm
ipcrm Command
Purpose
Removes message queue, semaphore set, or shared memory identifiers.
Syntax
ipcrm [ -m SharedMemoryID ] [ -M SharedMemoryKey ] [ -q MessageID ] [ -Q MessageKey ] [ -s SemaphoreID ] [ -S
SemaphoreKey ]
ipcrm -r {-q|-m|-s} Name
ipcrm -r -u [-o Owner] [-g Group]
Description
The ipcrm command removes one or more message queues, semaphore sets, or shared memory identifiers.
Flags
-g Group
Restricts the removal to unnamed semaphores matching the group specified.
-m SharedMemory ID
Removes the shared memory identifier SharedMemoryID. The shared memory segment and data structure associated
with SharedMemoryID are also removed after the last detach operation.
-M SharedMemoryKey
Removes the shared memory identifier, created with the key SharedMemoryKey. The shared memory segment and data
structure associated with it are also removed after the last detach operation.
-o Owner
Restricts the removal to unnamed semaphores matching the owner specified.
-q MessageID
Removes the message queue identifier MessageID and the message queue and data structure associated with it.
-Q MessageKey
Removes the message queue identifier, created with the key MessageKey, and the message queue and data structure
associated with it.
-r
Removes named or unnamed real-time interprocess communication objects. The named real-time object is either a
real-time message queue (-q), a real-time shared memory (-m), or a real-time semaphore (-s) and is identified by
its Name.
-s SemaphoreID
Removes the semaphore identifier SemaphoreID and the set of semaphores and data structure associated with it.
-S SemaphoreKey
Removes the semaphore identifier, created with the key SemaphoreKey, and the set of semaphores and data
structure associated with it.
-u
Removes all real-time unnamed semaphores. Using a descriptor on a destroyed unnamed semaphore can result in
unspecified behavior.
The msgctl, shmctl, and semctl subroutines provide details of the remove operations. The identifiers and keys can be
found by using the ipcs command.
Examples
To remove the shared memory segment associated with SharedMemoryID 18602, enter:
ipcrm -m 18602
[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8861952/viewspace-1034702/,如需轉載,請註明出處,否則將追究法律責任。

相關文章