search
HomeDatabaseMysql TutorialOracleStudy之--IPCS管理共享内存

Oracle Study之--IPCS管理共享内存 U nix/linux下的共享内存、信号量、队列信息管理 在unix/linux下,经常有因为共享内存、信号量,队列等共享信息没有干净地清除而引起一些问题。 查看共享信息的内存的命令是:ipcs [-m|-s|-q]。 默认会列出共享内存、信号量

Oracle Study之--IPCS管理共享内存

Unix/linux下的共享内存、信号量、队列信息管理

在unix/linux下,经常有因为共享内存、信号量,队列等共享信息没有干净地清除而引起一些问题。

查看共享信息的内存的命令是:ipcs [-m|-s|-q]。

默认会列出共享内存、信号量,队列信息

-m列出共享内存

-s列出共享信号量

-q列出共享队列

清除命令是:ipcrm [-m|-s|-q] id。

-m 删除共享内存

-s删除共享信号量

-q删除共享队列

 

案例分析:

[oracle@trade_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

       共享内存段有时不能马上删除,需使用这个内存段的所有进程向OS发送detach命令时才有释放,此时可以考虑删除进程使用的信号量,帮助释放共享内存段

  

相关知识:信号量、资源释放、ipcs、ipcrm

      信号量又称为信号灯,它是用来协调不同进程间的数据对象的,而最主要的应用是共享内存方式的进程间通信。本质上,信号量是一个计数器,它用来记录对某个资源(如共享内存)的存取状况;共享内存是运行在同一台机器上的进程间通信最快的方式,因为数据不需要在不同的进程间复制。通常由一个进程创建一块共享内存区,其余进程对这块内存区进行读写。在Linux系统下常用的方式是通过shmXXX函数族来实现利用共享内存进行存储的。如Shmget,类似于 malloc函数

ipcs可用来显示当前Linux系统中的共享内存段、信号量集、消息队列等的使用情况。

命令示例:
ipcs -a或ipc 显示当前系统中共享内存段、信号量集、消息队列的使用情况;
ipcs -m 显示共享内存段的使用情况;
ipcs -s 显示信号量集的使用情况;
ipcs -q 显示消息队列的使用情况;

ipcrm可用来删除对应的共享内存段、信号量、消息队列;

命令示例:
ipcrm -s semid 删除对应的信号量集
ipcrm -m shmid 删除对应的共享内存段
ipcrm -q msqid 删除对应的消息队列
ipcrm本身只能实现单个资源的删除,利用以下命令可实现批量删除:
1.ipcs -s|grep 用户名|cut -d" " -f2|xargs -n1 ipcrm -s
2.ipcs -s|awk '/用户名/{print $2}'|xargs -n1 ipcrm -s
3.ipcs -s|awk '/用户名/{system("ipcrm -s "$2)}'
4.for i in echo `ipcs|grep 用户名|cut -d" " -f2`; do ipcrm -s $i; done


更深入的了解:

Oracle 内存段参数设定:

[root@rh6 ~]# sysctl -p

net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586

 wKiom1SqUtPQwytOAAJHLPBC0iA930.jpg


 


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does MySQL's licensing compare to other database systems?How does MySQL's licensing compare to other database systems?Apr 25, 2025 am 12:26 AM

MySQL uses a GPL license. 1) The GPL license allows the free use, modification and distribution of MySQL, but the modified distribution must comply with GPL. 2) Commercial licenses can avoid public modifications and are suitable for commercial applications that require confidentiality.

When would you choose InnoDB over MyISAM, and vice versa?When would you choose InnoDB over MyISAM, and vice versa?Apr 25, 2025 am 12:22 AM

The situations when choosing InnoDB instead of MyISAM include: 1) transaction support, 2) high concurrency environment, 3) high data consistency; conversely, the situation when choosing MyISAM includes: 1) mainly read operations, 2) no transaction support is required. InnoDB is suitable for applications that require high data consistency and transaction processing, such as e-commerce platforms, while MyISAM is suitable for read-intensive and transaction-free applications such as blog systems.

Explain the purpose of foreign keys in MySQL.Explain the purpose of foreign keys in MySQL.Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

What are the different types of indexes in MySQL?What are the different types of indexes in MySQL?Apr 25, 2025 am 12:12 AM

There are four main index types in MySQL: B-Tree index, hash index, full-text index and spatial index. 1.B-Tree index is suitable for range query, sorting and grouping, and is suitable for creation on the name column of the employees table. 2. Hash index is suitable for equivalent queries and is suitable for creation on the id column of the hash_table table of the MEMORY storage engine. 3. Full text index is used for text search, suitable for creation on the content column of the articles table. 4. Spatial index is used for geospatial query, suitable for creation on geom columns of locations table.

How do you create an index in MySQL?How do you create an index in MySQL?Apr 25, 2025 am 12:06 AM

TocreateanindexinMySQL,usetheCREATEINDEXstatement.1)Forasinglecolumn,use"CREATEINDEXidx_lastnameONemployees(lastname);"2)Foracompositeindex,use"CREATEINDEXidx_nameONemployees(lastname,firstname);"3)Forauniqueindex,use"CREATEU

How does MySQL differ from SQLite?How does MySQL differ from SQLite?Apr 24, 2025 am 12:12 AM

The main difference between MySQL and SQLite is the design concept and usage scenarios: 1. MySQL is suitable for large applications and enterprise-level solutions, supporting high performance and high concurrency; 2. SQLite is suitable for mobile applications and desktop software, lightweight and easy to embed.

What are indexes in MySQL, and how do they improve performance?What are indexes in MySQL, and how do they improve performance?Apr 24, 2025 am 12:09 AM

Indexes in MySQL are an ordered structure of one or more columns in a database table, used to speed up data retrieval. 1) Indexes improve query speed by reducing the amount of scanned data. 2) B-Tree index uses a balanced tree structure, which is suitable for range query and sorting. 3) Use CREATEINDEX statements to create indexes, such as CREATEINDEXidx_customer_idONorders(customer_id). 4) Composite indexes can optimize multi-column queries, such as CREATEINDEXidx_customer_orderONorders(customer_id,order_date). 5) Use EXPLAIN to analyze query plans and avoid

Explain how to use transactions in MySQL to ensure data consistency.Explain how to use transactions in MySQL to ensure data consistency.Apr 24, 2025 am 12:09 AM

Using transactions in MySQL ensures data consistency. 1) Start the transaction through STARTTRANSACTION, and then execute SQL operations and submit it with COMMIT or ROLLBACK. 2) Use SAVEPOINT to set a save point to allow partial rollback. 3) Performance optimization suggestions include shortening transaction time, avoiding large-scale queries and using isolation levels reasonably.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function