systemd 启动的服务, 跟系统的ulimit 没有关系.
大概的意思就是通过systemd启动的服务,不会使用ulimit中的配置,需要在systemd中或者service配置文件中定义,可以通过查看 /proc/<pid>/limits文件中的内容来确定
修改service定义,增加"LimitNOFILE=15210"
[Unit]
Description=exporter vcenter service
After=network.target
[Service]
LimitNOFILE=15210
Type=simple
PIDFile=/var/run/observer_vcenter_exporter.pid
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/qhapp/monitor/exporter_vcenter/observer_vcenter_exporter --config-file=/qhapp/monitor/config/observer/vcenter.yml
SyslogIdentifier=observer_vcenter_exporter
Restart=always
[Install]
WantedBy=multi-user.target
在查看进行的limits,可以看出"Max open files"已经修改。
cat /proc/15986/limits