Set linux mq_queue size for user
2018-06-17 21:45:16来源:未知 阅读 ()
设置调整mq_queue的size*num如果大于默认(POSIX message queues),则需要调整系统限制和用户限制,不然在mq_open是会报"Too many open files"的错误
1. man mq_overview命令可以了解到mq可以设置msg_max和msgsize_max的路径,默认是10与8192.这个限制是系统限制
/proc/sys/fs/mqueue/msg_max
This file can be used to view and change the ceiling value for
the maximum number of messages in a queue. This value acts as a
ceiling on the attr->mq_maxmsg argument given to mq_open(3).
The default value for msg_max is 10. The minimum value is 1 (10
in kernels before 2.6.28). The upper limit is HARD_MSGMAX. The
msg_max limit is ignored for privileged processes
(CAP_SYS_RESOURCE), but the HARD_MSGMAX ceiling is nevertheless
imposed.
The definition of HARD_MSGMAX has changed across kernel ver‐
sions:
* Up to Linux 2.6.32: 131072 / sizeof(void *)
* Linux 2.6.33 to 3.4: (32768 * sizeof(void *) / 4)
* Since Linux 3.5: 65,536
/proc/sys/fs/mqueue/msgsize_max
This file can be used to view and change the ceiling on the max‐
imum message size. This value acts as a ceiling on the
attr->mq_msgsize argument given to mq_open(3). The default
value for msgsize_max is 8192 bytes. The minimum value is 128
(8192 in kernels before 2.6.28). The upper limit for msg‐
size_max has varied across kernel versions:
* Before Linux 2.6.28, the upper limit is INT_MAX.
* From Linux 2.6.28 to 3.4, the limit is 1,048,576.
* Since Linux 3.5, the limit is 16,777,216 (HARD_MSGSIZEMAX).
The msgsize_max limit is ignored for privileged process
(CAP_SYS_RESOURCE), but, since Linux 3.5, the HARD_MSGSIZEMAX
ceiling is enforced for privileged processes.
2. ulimit -a命令可以显示POSIX message queues (bytes, -q) 819200, ulimit -q xxx对于普通用户无法进行调整
一般用户调整该项设置会提示权限问题,或者无法看到该项显示。
这样就需要root权限或者sudo修改/etc/security/limits.conf, 比如调整为* - msgqueue 921600
明确在/etc/pam.d/login加载中生效, 有这项纪录session required pam_limits.so即表明会加载,但需要重启系统进行加载,加载成功后,一般用户的该值就会被设置为新限制。
注:mq_name需要注意,open后必须删掉,否则即使调整属性也是无法生效的。
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- Building & Debugging chromium on CLion for Linu 2020-05-19
- STL之set 2020-04-28
- STL之queue 2020-04-08
- 非常详细的 Linux C/C++ 学习路线总结!已拿腾讯offer 2020-03-29
- linux环境下的时间编程 2020-03-27
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash