CentOS-7 使用systemctrl 管理的服务,文件打开数上限1024要改

改要 文件 中 /etc/systemd/system.conf  以下两个值

DefaultLimitNOFILE=1024000
DefaultLimitNPROC=1024000

 

如nginx

编辑服务配置文件:/usr/lib/systemd/system/SERVICE_NAME.service,在[Service]段添加行:LimitNOFILE=65535,下面是nginx的示例:

 

vim nginx.service

[Unit]
Description=nginx – high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/opt/web_engine/nginx/run/nginx.pid
ExecStartPre=/opt/web_engine/nginx/sbin/nginx -t -c /opt/web_engine/nginx/conf/nginx.conf
ExecStart=/opt/web_engine/nginx/sbin/nginx -c /opt/web_engine/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target

Leave a Reply

Your email address will not be published. Required fields are marked *