the max number of open files 最大打开文件数 ulimit -n RabbitMQ调优
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调优的更多相关文章
- ulimit open files linux打开文件数设置验证
#include <stdio.h> #include <sys/types.h> #include <fcntl.h> #include <stdlib.h ...
- 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 ...
- 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 ...
- 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 ...
- max number of clients reached Redis测试环境报错
现象:测试服务是去redis循环取数据,早上发现服务挂了,手动登陆redis 无法输入命令,报错:max number of clients reached Redis
- InnoDB: The log sequence number in ibdata files does not match
InnoDB: The log sequence number in ibdata files does not matchInnoDB的:在ibdata文件的日志序列号不匹配 可能ibdata文件损 ...
- 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 ...
- 【转】redis报错“max number of clients reached"
查看redis监控的时候看到redis的graph出现不正常的情况,截图如下: 如上面截图所展示的样子,可以看到redis 的客户端连接数很突兀的上升到10K,又突然下降到0.排除了监控本身的原因,很 ...
- leetcode 321 Create Max Number
leetcode 321 Create Max Number greedy的方法,由于有两个数组,我们很自然的想到从数组1中选i个数,数组2中选k-i个数,这样我们只需要遍历max(0, k-数组2长 ...
随机推荐
- 洛谷 P1464 Function【动态规划(递推)/记忆化搜索(递归)】
题目描述 对于一个递归函数w(a,b,c) 如果a<=0 or b<=0 or c<=0就返回值1. 如果a>20 or b>20 or c>20就返回w(20,2 ...
- 分布式定时任务调度系统技术解决方案(xxl-job、Elastic-job、Saturn)
1.业务场景 保险人管系统每月工资结算,平安有150万代理人,如何快速的进行工资结算(数据运算型) 保险短信开门红/电商双十一 1000w+短信发送(短时汇聚型) 工作中业务场景非常多,所涉及到的场景 ...
- Product of Array Except Self - LeetCode
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...
- Jave工具——servlet+jsp编程中mysql数据库连接及操作通用工具类
该工具类是在JavaWeb中连接mysql所用到的通用工具类 该类用于Java+Servlet的编程中,方便数据库的操作,连接,获取其列表值.下面是这个数据库操作类的通用方法,基本上能够用于类里面只含 ...
- shell实践--shell内嵌指令实现查看上线时间
实践小点子: 1. 做一个shell 内嵌指令例如:ls,cd,pwd这样 就实现查看上线多久: 解决办法有两种: 1) 利用脚本,如新指令为look;利用别名的方法,将look.sh脚本 ...
- PHP使用frameset制作后台界面时,怎样实现通过操作左边框架,使右边框架中的页面跳转?
左框架的链接,不仅要指定链接的文件名,还需要通过 target 属性指定要打开的目标框架名(即楼主要求的右框架名). 例:假设右框架为 <frame scr="lx1.htm" ...
- C#是唯一能挑战Java的编程语言?
几乎所有新近成长的Visual Studio代码开发人员都选择使用C#,而不是VB.NET或C++,这也使得C#已经成长为微软的第一大语言.根据本月的Tiobe编程语言排行榜,C#再次取得了突破性进展 ...
- nginx phase handler的原理和选择
nginx phase handler的原理和选择 PHASE HANDLER的种类 nginx在接收并解析完请求行.请求头之后.就会依次调用各个phase handler. phase handle ...
- [转]MySQL的简单使用和JDBC示例
MySql简单操作 //启动mysql net start mysql //登陆 mysql -u root -p //创建建数据库 create database mydb; create data ...
- HTML5 Canvas 绘制六叶草
注意: context.arc(横坐标,纵坐标,弧半径,起始角度,终止角度,逆顺时针);这个函数挺难用,主要原因是最后参数和角度的关系.不管文档怎么说,按我的实际经验,逆顺时针=false时,是逆时针 ...