linux设置posix消息队列大小,linux修改POSIX消息队列(msgqueue)的各项限制(最大内存、msg_max、msgsize_max、queues_max)...

1.进入 目录 /proc/sys/fs/mqueue/,查看各项消息队列的默认max设置:

[root@localhost ~]# ls -l /proc/sys/fs/mqueue/

total 0

-rw-r--r-- 1 root root 0 Aug 20 23:04 msg_default

-rw-r--r-- 1 root root 0 Aug 20 23:04 msg_max

-rw-r--r-- 1 root root 0 Aug 20 23:04 msgsize_default

-rw-r--r-- 1 root root 0 Aug 20 23:04 msgsize_max

-rw-r--r-- 1 root root 0 Aug 20 23:04 queues_max

[root@localhost ~]# cat /proc/sys/fs/mqueue/msg_max

10

[root@localhost ~]# cat /proc/sys/fs/mqueue/msgsize_max

8192

[root@localhost ~]# cat /proc/sys/fs/mqueue/queues_max

256

以修改msg_max为例:

[root@localhost ~]# echo "10000">/proc/sys/fs/mqueue/msg_max

[root@localhost ~]# cat /proc/sys/fs/mqueue/msg_max

10000

上述可解决mq_open时,经常遇到的errno=22:/* Invalid argument */问题,其他修改类型。

2. 解除消息队列占用内存81920的限制:

vim /etc/security/limits.conf

添加:

* soft msgqueue unlimited

* hard msgqueue unlimited

上述各列用tab分开,保存后系统重新启动后生效。使用下面命令验证:

[root@localhost ~]# ulimit -q

unlimited

附,/etc/security/limits.conf文件的说明:

[root@localhost ~]# cat /etc/security/limits.conf

# /etc/security/limits.conf

#

#This file sets the resource limits for the users logged in via PAM.

#It does not affect resource limits of the system services.

#

#Also note that configuration files in /etc/security/limits.d directory,

#which are read in alphabetical order, override the settings in this

#file in case the domain is the same or more specific.

#That means for example that setting a limit for wildcard domain here

#can be overriden with a wildcard setting in a config file in the

#subdirectory, but a user specific setting here can be overriden only

#with a user specific setting in the subdirectory.

#

#Each line describes a limit for a user in the form:

#

##

#Where:

#can be:

# - a user name

# - a group name, with @group syntax

# - the wildcard *, for default entry

# - the wildcard %, can be also used with %group syntax,

# for maxlogin limit

#

#can have the two values:

# - "soft" for enforcing the soft limits

# - "hard" for enforcing hard limits

#

#can be one of the following:

# - core - limits the core file size (KB)

# - data - max data size (KB)

# - fsize - maximum filesize (KB)

# - memlock - max locked-in-memory address space (KB)

# - nofile - max number of open file descriptors

# - rss - max resident set size (KB)

# - stack - max stack size (KB)

# - cpu - max CPU time (MIN)

# - nproc - max number of processes

# - as - address space limit (KB)

# - maxlogins - max number of logins for this user

# - maxsyslogins - max number of logins on the system

# - priority - the priority to run user process with

# - locks - max number of file locks the user can hold

# - sigpending - max number of pending signals

# - msgqueue - max memory used by POSIX message queues (bytes)

# - nice - max nice priority allowed to raise to values: [-20, 19]

# - rtprio - max realtime priority

#

##

#* soft core 0

#* hard rss 10000

#@student hard nproc 20

#@faculty soft nproc 20

#@faculty hard nproc 50

#ftp hard nproc 0

#@student - maxlogins 4

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值