Oracle study--ipcs Manage shared memory
U shared memory, semaphore, queue information management under Nix/linux
Under Unix/linux, there are often problems caused by shared memory, semaphores, queues, and other shared information that are not cleaned up cleanly.
The command to view memory for shared information is: IPCS [-m|-s|-q].
Shared memory, semaphores, queue information are listed by default
-M list shared memory
-S lists shared semaphores
-Q list shared queues
The Purge command is: IPCRM [-m|-s|-q] ID.
- M Delete Shared memory
-S Delete shared semaphore
- Q Delete a Shared Queue .
Case Analysis:
[[email protected]_as02 ~]$ ipcs -a------ Shared Memory Segments ----- ---key shmid owner perms bytes nattch status 0x30024289 32768 futures 777 528384 1 0xca2fd414 491521 oracle 640 1730150400 16 ------ semaphore Arrays --------key semid owner perms nsems 0x00028009 0 futures 666 1 0x0002800c 32769 futures 666 1 0x30024003 262146 futures 777 3 0x3002428a 294915 futures 777 2 0x3002428b 327684 futures 777 2 0x3002428c 360453 futures 777 2 0x3002428d 393222 futures 777 2 0x3002428e 425991 futures 777 2 0x52dff7d0 3964936 oracle 640 151 0x52dff7d1 3997705 oracle 640 151 0x52dff7d2 4030474 oracle 640 151 0x52dff7d3 4063243 oracle 640 151 0x52dff7d4 4096012 oracle 640 151 ------ Message Queues --------Key msqid owner perms used-bytes messages
Shared memory segments can sometimes not be deleted immediately, and all processes that use this memory segment are released when the detach command is sent to the OS, considering the amount of semaphores used by the removal process to help free up shared memory segments
Related knowledge: Signal volume, resource release, IPCS, Ipcrm
Semaphores , also known as semaphores, are used to coordinate differentProcessof data Objects, and the most important application is shared memory mode.Processcommunication between the two. Essentially, a semaphore is a counter that is used to record access to a resource (such as shared memory), and shared memory is run on the same machine .ProcessThe fastest way to communicate, because the data does not need to be in a differentProcessreplication between the two. Usually by aProcessCreate a piece of shared memory area, the restProcessRead and write to this memory area. In theLinuxsystem under, the common way is through the SHMXXX function family to realize the use of shared memory for storage. such as Shmget, similar to the malloc function
IPCS can be used to display the usage of shared memory segments, semaphore sets, message queues, and so on in the current Linux system.
command example: Ipcs-a or IPC Displays the usage of shared memory segments, semaphore sets, message queues in the current system, IPCS-M displays the usage of shared memory segments, Ipcs-s displays the usage of the semaphore set, and IPCS-Q displays the usage of the message queue;
IPCRM can be used to delete corresponding shared memory segments, semaphores, message queues;
command example: Ipcrm-s semid Delete the corresponding semaphore set ipcrm-m shmid Delete the corresponding shared memory segment Ipcrm-q msqid Delete the corresponding message queue Ipcrm itself can only implement the deletion of a single resource, using the following command to achieve bulk deletion: 1.ipcs-s |grep username |cut-d ""-f2|xargs-n1 Ipcrm-s2.ipcs-s|awk '/username/{print $} ' |xargs-n1 Ipcrm-s3.ipcs-s|awk '/user name/{system ("I Pcrm-s "$"} ' 4.for I in echo ' Ipcs|grep user name |cut-d "-F2"; Do ipcrm-s $i; Done
More in-depth understanding:
oracle memory Segment parameter setting:[[email protected] ~]# sysctl -pnet.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1error: "Net.bridge.bridge-nf-call-ip6tables" is an unknown keyerror: " Net.bridge.bridge-nf-call-iptables " is an unknown keyerror: " Net.bridge.bridge-nf-call-arptables " is an unknown keyfs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 536870912kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_ local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048586
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/28/wKiom1SqUtPQwytOAAJHLPBC0iA930.jpg "title=" 1.png " alt= "Wkiom1squtpqwytoaajhlpbc0ia930.jpg"/>
This article is from the "Tianya blog," Please make sure to keep this source http://tiany.blog.51cto.com/513694/1599364
Oracle study--ipcs Manage shared memory