linux – 在CentOS 7上为systemd启动的进程增加nproc

前端之家收集整理的这篇文章主要介绍了linux – 在CentOS 7上为systemd启动的进程增加nproc前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经成功地为本地用户增加了nofile和nproc值,但是我找不到systemd启动的进程的正确解决方案.将max_open_files添加到MariaDB配置没有帮助. su – mysql手动更改限制也不起作用(此帐户目前不可用).

在/etc/security/limits.conf

* soft nofile 102400
* hard nofile 102400
* soft nproc 10240
* hard nproc 10240

/etc/security/limits.d/20-nproc.conf(目录中没有其他文件)

* soft nofile 102400
* hard nofile 102400
* soft nproc 10240
* hard nproc 10240

/etc/sysctl.conf中

fs.file-max = 2097152

将/etc/pam.d/system-auth

#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth        required      pam_env.so
auth        sufficient    pam_unix.so nullok try_first_pass
auth        requisite     pam_succeed_if.so uid >= 1000 quiet_success
auth        required      pam_deny.so

account     required      pam_unix.so
account     sufficient    pam_localuser.so
account     sufficient    pam_succeed_if.so uid < 1000 quiet
account     required      pam_permit.so

password    requisite     pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
password    required      pam_deny.so

session     optional      pam_keyinit.so revoke
session     required      pam_limits.so
-session     optional      pam_systemd.so
session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session     required      pam_unix.so

/etc/pam.d/systemd-user

#%PAM-1.0

# Used by systemd when launching systemd user instances.

account include system-auth
session include system-auth
auth required pam_deny.so
password required pam_deny.so

/var/log/mariadb/mariadb.log

[Warning] Changed limits: max_open_files: 1024  max_connections: 32  table_cache: 491

的/ proc / MysqL_pid /限制

Limit                     Soft Limit           Hard Limit           Units
Max cpu time              unlimited            unlimited            seconds
Max file size             unlimited            unlimited            bytes
Max data size             unlimited            unlimited            bytes
Max stack size            8388608              unlimited            bytes
Max core file size        0                    unlimited            bytes
Max resident set          unlimited            unlimited            bytes
Max processes             30216                30216                processes
Max open files            1024                 4096                 files
Max locked memory         65536                65536                bytes
Max address space         unlimited            unlimited            bytes
Max file locks            unlimited            unlimited            locks
Max pending signals       30216                30216                signals
Max msgqueue size         819200               819200               bytes
Max nice priority         0                    0
Max realtime priority     0                    0
Max realtime timeout      unlimited            unlimited            us

有趣的是,不同的进程(用户)具有不同的Max打开文件号:

MysqL - 1024 4096
apache - 1024 4096
postfix - 4096 4096

解决方法

systemd完全忽略/ etc / security / limits *.如果您使用的是在更新时自动压缩其systemd服务文件的RPM,您需要提交PR以要求他们将这些文件标记为“noreplace”

您需要更新.service文件/usr/lib/systemd/system/\u0026lt;servicename\u0026gt;.service

[Unit]
Description=Some Daemon
After=syslog.target network.target

[Service]
Type=notify
LimitNOFILE=49152
ExecStart=/usr/sbin/somedaemon

[Install]
WantedBy=multi-user.target

sickill指出你也可以通过将它们添加到/etc/systemd/system/\u0026lt;servicename\u0026gt;.d/override.conf来覆盖包安装的值(在上面的文件中找到).

[Service]
LimitNOFILE=49152

这为系统特定的设置提供了额外的好处,这些设置在包更新时没有被覆盖的危险.

然后发出命令:systemctl daemon-reload

原文链接:https://www.f2er.com/linux/402912.html

猜你在找的Linux相关文章