设置调整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后必须删掉,否则即使调整属性也是无法生效的。

最新文章

  1. Spring框架IOC容器和AOP解析
  2. Android 的 DatePicker、TimePicker或NumberPicker
  3. POJ 3067 Japan(经典树状数组)
  4. HTML5画布(矩形)
  5. WPF MultiBinding后台绑定动态属性 属性改变不调用Convert的问题
  6. ExtJs4 笔记(6) Ext.MessageBox 消息对话框
  7. 为什么MVC不是一种设计模式? ---比较Backbone和Ext4.x在MVC实现上的差异
  8. 注解用法详解——@SuppressWarnings
  9. PayPal为什么从Java迁移到Node.js
  10. iOS坐标转换失败?UIKit的屠神坑
  11. 记录下直接在git里读取出差异并打包的代码
  12. 学习java23种设计模式自我总结
  13. 多线程深入:synchronized(转,有删减)
  14. 第二十三篇-ubuntu18.04怎么下载播放器以及如何设置默认播放器
  15. mac下Fiddler的安装-启动
  16. element-ui Carousel 走马灯源码分析整理笔记(十一)
  17. QT Graphics-View 3D编程例子- 3D Model Viewer
  18. 基于DirectX的半球形天空类的C++和C#实现
  19. HDU1232
  20. Tesseract-OCR 训练教程(一)

热门文章

  1. Redis的Publish/Subscribe
  2. Dozer 实现对象间属性复制
  3. MySQL远程连接:Host 'x' is not allowed to connect to this MySQL server
  4. .NET开源工作流RoadFlow-表单设计-保存与发布
  5. matlab练习程序(差异演化DE)
  6. Laravel 开源电商体验与部署
  7. LeetCode Two Sum 解题思路(python)
  8. 【洛谷5286】[HNOI2019] 鱼(计算几何)
  9. 【[POI2000]病毒】
  10. SP348 EXPEDI - Expedition