歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux ipcs確定共享內存使用情況

Linux ipcs確定共享內存使用情況

日期:2017/2/28 15:59:51   编辑:Linux教程

環境:

[plain]
  1. [Oracle@ www.linuxidc.com ~]$ uname -a
  2. Linux simpleit.domain.cn 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 athlon i386 GNU/Linux
  3. [oracle@ www.linuxidc.com ~]$ cat /etc/RedHat-release
  4. CentOS release 5.5 (Final)
ipcs確定共享內存的使用情況,該命令用於輸出系統中處於active狀態的消息隊列,共享內存段以及信號量的有關消息。

[plain]
  1. DESCRIPTION
  2. The ipcs utility shall write information about active interprocess communication facili-
  3. ties.
  4. Without options, information shall be written in short format for message queues, shared
  5. memory segments, and semaphore sets that are currently active in the system. Otherwise, the
  6. information that is displayed is controlled by the options specified.
  7. -b Write information on maximum allowable size. (Maximum number of bytes in messages on
  8. queue for message queues, size of segments for shared memory, and number of
  9. semaphores in each set for semaphores.)
  10. [oracle@ www.linuxidc.com ~]$ ipcs -b
  11. ipcs: invalid option -- b
  12. usage : ipcs -asmq -tclup
  13. ipcs [-s -m -q] -i id
  14. ipcs -h for help.
  15. [oracle@ www.linuxidc.com ~]$ ipcs
  16. ------ Shared Memory Segments --------
  17. key shmid owner perms bytes nattch status
  18. 0xe9b42ad8 2228225 oracle 640 88080384 13
  19. 0x8cdf18fc 2359299 oracle 640 528482304 26
  20. ------ Semaphore Arrays --------
  21. key semid owner perms nsems
  22. 0xbbe791cc 98304 oracle 640 44
  23. 0x9d085d3c 491521 oracle 640 154
  24. ------ Message Queues --------
  25. key msqid owner perms used-bytes messages
  26. [oracle@ www.linuxidc.com ~]$ ipcs -m
  27. ------ Shared Memory Segments --------
  28. key shmid owner perms bytes nattch status
  29. 0xe9b42ad8 2228225 oracle 640 88080384 13
  30. 0x8cdf18fc 2359299 oracle 640 528482304 26
通常最好讓整個SGA處於一個單一的共享內存段,因為跟蹤一個以上的段將需要額外的開銷,在這些段來回切換也需要時間。可以增加/etc/sysctl.conf文件kernel.shmmax參數值,以增加一個單一的共享內存段的最大尺寸。
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 4294967295

使用ipcs可以查看系統的SGA是否由多個不連續的內存塊組成,如果數據庫失敗,在釋放內存時就會出現問題。使用ipcrm命令(僅僅用於在數據庫失敗之後SGA碎片沒有被釋放的情況)可以從內存中去除SGA碎片。不要在一個正在運行的數據庫中運行ipcrm命令。


ipcrm命令

[plain]
  1. DESCRIPTION
  2. The ipcrm utility shall remove zero or more message queues, semaphore sets, or shared mem-
  3. ory segments. The interprocess communication facilities to be removed are specified by the
  4. options.
  5. Only a user with appropriate privilege shall be allowed to remove an interprocess communi-
  6. cation facility that was not created by or owned by the user invoking ipcrm.
  7. -q msgid --隊列id
  8. Remove the message queue identifier msgid from the system and destroy the message
  9. queue and data structure associated with it.
  10. -m shmid --共享內存id
  11. Remove the shared memory identifier shmid from the system. The shared memory segment
  12. and data structure associated with it shall be destroyed after the last detach.
  13. -s semid --信號量id
  14. Remove the semaphore identifier semid from the system and destroy the set of
  15. semaphores and data structure associated with it.
  16. 比如 ipcrm -m 2359299
Copyright © Linux教程網 All Rights Reserved