Installing on RPM-based Linux (RHEL, CentOS, Fedora, openSUSE) — RabbitMQ https://www.rabbitmq.com/install-rpm.html

ulimit -n

1024

Controlling System Limits on Linux

RabbitMQ installations running production workloads may need system limits and kernel parameters tuning in order to handle a decent number of concurrent connections and queues. The main setting that needs adjustment is the max number of open files, also known as ulimit -n. The default value on many operating systems is too low for a messaging broker (eg. 1024 on several Linux distributions). We recommend allowing for at least 65536 file descriptors for userrabbitmq in production environments. 4096 should be sufficient for most development workloads.

There are two limits in play: the maximum number of open files the OS kernel allows (fs.file-max) and the per-user limit (ulimit -n). The former must be higher than the latter.

With systemd (Recent Linux Distributions)

On distributions that use systemd, the OS limits are controlled via a configuration file at /etc/systemd/system/rabbitmq-server.service.d/limits.conf, for example:

[Service]
LimitNOFILE=300000

Without systemd (Older Linux Distributions)

The most straightforward way to adjust the per-user limit for RabbitMQ on distributions that do not use systemd is to edit the rabbitmq-env.conf to invoke ulimit before the service is started.

ulimit -S -n 4096

This soft limit cannot go higher than the hard limit (which defaults to 4096 in many distributions). The hard limit can be increased via /etc/security/limits.conf. This also requires enabling the pam_limits.so module and re-login or reboot.

Note that limits cannot be changed for running OS processes.

For more information about controlling fs.file-max with sysctl, please refer to the excellentRiak guide on open file limit tuning.

Verifying the Limit

RabbitMQ management UI displays the number of file descriptors available for it to use on the Overview tab.

rabbitmqctl status

includes the same value.

The following command

cat /proc/$RABBITMQ_BEAM_PROCESS_PID/limits

can be used to display effective limits of a running process. $RABBITMQ_BEAM_PROCESS_PID is the OS PID of the Erlang VM running RabbitMQ, as returned by rabbitmqctl status.

Configuration Management Tools

Configuration management tools (e.g. Chef, Puppet, BOSH) provide assistance with system limit tuning. Our developer tools guide lists relevant modules and projects.

Managing the Broker

To stop the server or check its status, etc., you can use package-specific scripts (e.g. the service tool) or invoke rabbitmqctl (as an administrator). It should be available on the path. All rabbitmqctl commands will report the node absence if no broker is running.

  • Invoke rabbitmqctl stop to stop the server.
  • Invoke rabbitmqctl status to check whether it is running.

More info on rabbitmqctl.

nginx worker_connections are not enough(错误) - CSDN博客 https://blog.csdn.net/m0_37263637/article/details/80813881

我们可以使用ulimit -a命令查看Linux相关限制 
可以看到open files (-n) 1024 
即linux 默认最大打开文件数为1024 
对于临时测试我们可以使用ulimit -n Number 修改最大文件句柄限制,但该种修改方式仅仅对当前session有效。

永久生效方案

 vi /etc/security/limits.conf
在limits.conf中添加以下参数
* soft nofile 40960
* hard nofile 65536
  • 1
  • 2
  • 3
  • 4

参数:

* 代表所有用户有效
soft:软限制,超过会报warn
hard:实际限制
nofile:文件句柄参数
number:最大文件句柄数
阿里云服务器默认配置

[root@c ~]# 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:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> 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
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> 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 files
# - 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
#
#<domain> <type> <item> <value>
#

#* 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

# End of file
* soft nofile 65535
* hard nofile 65535
[root@c ~]# cat /proc/version
Linux version 3.10.0-862.11.6.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Tue Aug 14 21:49:04 UTC 2018
[root@c ~]#

Linux上修改open files数目_Linux教程_Linux公社-Linux系统门户网站 https://www.linuxidc.com/Linux/2013-07/86954.htm

Linux上修改open files数目

[日期:2013-07-06] 来源:Linux社区  作者:Linux [字体:  ]
 

Linux系统上默认的open files数目为1024, 有时应用程序会报Too many open files的错误,是因为open files 数目不够。

用 ulimit -a 命令可以查看 系统对各种参数的限制;
 
# ulimit -a
core file size          (blocks, -c) 0
data seg size          (kbytes, -d) unlimited
scheduling priority            (-e) 0
file size              (blocks, -f) unlimited
pending signals                (-i) 257648
max locked memory      (kbytes, -l) 64
max memory size        (kbytes, -m) unlimited
open files                      (-n) 4096
pipe size            (512 bytes, -p) 8
POSIX message queues    (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) unlimited
cpu time              (seconds, -t) unlimited
max user processes              (-u) unlimited
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
由上面可以知道 open files 当前限制为 4096,ok,我们可以修改稍微大一点;
当你把open files的值增大到一定程度,你的Too many open files就不会再出现了。
 
修改方法:
(1)ulimit -HSn 102400
这只是在当前终端有效,退出之后,open files 又变为默认值。
(2)将ulimit -HSn 102400写到/etc/profile中,因为每次登录终端时,都会自动执行/etc/profile。
(3)令修改open files的数值永久生效,则必须修改配置文件:/etc/security/limits.conf. 在这个文件后加上:
* soft nofile 102400
* hard nofile 102400
这种方法需要重启机器才能生效。
(4)为了让一个程序的open files数目扩大,可以在启动脚本前面加上(1)中的命令。当程序是一个daemon时,可能这种方法无效,没有终端了。 
 
影响open files数值的还有一个内核参数file-max,这是Linuxt系统的总限制。可以通过如下文式查看:
cat /proc/sys/fs/file-max
或者
sysctl -a | grep fs.file-max
 
对于服务器可以采用如下方法修改file-max:
(1)重启机器后恢复为默认值
echo 34166 > /proc/sys/fs/file-max
或者
sysctl -w "fs.file-max=34166"
(2)修改配置文件/etc/sysctl.conf, 在最后加上一行:
fs.file-max = 34166
然后sysctl -p 生效 或者 重启机器以后永久生效。

推荐阅读:

Linux系统文件查找命令find的基本使用及其高级用法 http://www.linuxidc.com/Linux/2013-05/84991.htm

 
 
 

the max number of open files 最大打开文件数 ulimit -n RabbitMQ调优的更多相关文章

  1. ulimit open files linux打开文件数设置验证

    #include <stdio.h> #include <sys/types.h> #include <fcntl.h> #include <stdlib.h ...

  2. Maximum number of WAL files in the pg_xlog directory (2)

    Jeff Janes: Hi, As part of our monitoring work for our customers, we stumbled upon an issue with our ...

  3. Maximum number of WAL files in the pg_xlog directory (1)

      Guillaume Lelarge: Hi, As part of our monitoring work for our customers, we stumbled upon an issue ...

  4. Linux Increase The Maximum Number Of Open Files / File Descriptors (FD)

    How do I increase the maximum number of open files under CentOS Linux? How do I open more file descr ...

  5. max number of clients reached Redis测试环境报错

    现象:测试服务是去redis循环取数据,早上发现服务挂了,手动登陆redis 无法输入命令,报错:max number of clients reached Redis

  6. InnoDB: The log sequence number in ibdata files does not match

    InnoDB: The log sequence number in ibdata files does not matchInnoDB的:在ibdata文件的日志序列号不匹配 可能ibdata文件损 ...

  7. redis cluster 的ERR max number of clients reached 问题排查

    早上发现微服务连不上redis cluster了,看来下日志如下 [root@win-jrh378d7scu 7005]# bin/redis-cli -c -h 15.31.213.183 -p 7 ...

  8. 【转】redis报错“max number of clients reached"

    查看redis监控的时候看到redis的graph出现不正常的情况,截图如下: 如上面截图所展示的样子,可以看到redis 的客户端连接数很突兀的上升到10K,又突然下降到0.排除了监控本身的原因,很 ...

  9. leetcode 321 Create Max Number

    leetcode 321 Create Max Number greedy的方法,由于有两个数组,我们很自然的想到从数组1中选i个数,数组2中选k-i个数,这样我们只需要遍历max(0, k-数组2长 ...

随机推荐

  1. HDU5877 Weak Pair

    题目链接 Weak Pair 题意十分明确, 就是求出符合题意的有序点对个数. 首先对ai离散,离散之后的结果用rk[i]表示,然后进行二分预处理得到f[i],其中f[i]的意义为:其他的点和i这个节 ...

  2. C++ | class size

    c++类大小和机器还有编译器有关.64位机器指针大小为8个字节,32位机器为4个字节. 每个实例在内存中都有一个独一无二的地址,为了达到这个目的,编译器往往会给一个空类隐含的加一个字节,这样空类在实例 ...

  3. PHP如何在页面中原样输出HTML代码

    字符串与HTML之间的相互转换主要应用htmlentities()函数来完成. header("Content-Type: text/html; charset=utf-8"); ...

  4. group by与distinct效率分析及优化措施

    如何使用group by进行去重 因为mysql的distinct在结果集中,全部不同,才可以去重.所以,当我们进行去重处理的时候,需要单独对某列进行去重,可以使用group by子句进行分组去重se ...

  5. jQuery.parseHTML() 函数

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. spring与struts2整合出现常见错误

    错误信息 严重: Exception starting filter struts2 Unable to load configuration. - bean - jar:file:/F:/Strut ...

  7. 2016.6.21 maven使用cmd新建项目时,failed to execute goal org.apache.maven.plugins:maven-archetye-plugin:2.4:generate...

    在学习maven的时候,想要新建一个maven工程,在命令行执行create或generate命令. 错误如图所示: failed to execute goal org.apache.maven.p ...

  8. 2016.7.12 在navicat中用sql语句建表

    参考资料: http://jingyan.baidu.com/article/f0e83a25a8c4b022e5910116.html 即新建query,然后run. (1)点击要新建表的位置,选择 ...

  9. AngularJS取得后台Jason数据显示在页面上

    代码下载:https://files.cnblogs.com/files/xiandedanteng/angularjsAjax.rar 前台代码: <%@ page language=&quo ...

  10. 版本号控制软件:TortoiseSVN高速上手

    百度百科对于SVN的一点解释: TortoiseSVN是Subversion版本号控制系统的一个免费开源client,能够超越时间的管理文件和文件夹.文件保存在中央版本号库,除了能记住文件和文件夹的每 ...