如何在 Centos 7 上通过 systemd 将 clamd 作为守护进程运行

如何在 Centos 7 上通过 systemd 将 clamd 作为守护进程运行
# rpm -q centos-release
centos-release-7-5.1804.el7.centos.2.x86_64

# rpm -qa clam
clamav-filesystem-0.100.0-2.el7.noarch
clamav-data-0.100.0-2.el7.noarch
clamav-lib-0.100.0-2.el7.x86_64
clamav-update-0.100.0-2.el7.x86_64
clamav-server-systemd-0.100.0-2.el7.x86_64
clamav-devel-0.100.0-2.el7.x86_64
clamav-scanner-systemd-0.100.0-2.el7.x86_64
clamd-0.100.0-2.el7.x86_64
clamav-0.100.0-2.el7.x86_64

以下[email protected]是原样。

# cat /usr/lib/systemd/system/clamd\@.service
[Unit]
Description = clamd scanner (%i) daemon
After = syslog.target nss-lookup.target network.target

[Service]
Type = forking
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/%i.conf
Restart = on-failure

我使用标准配置和默认设置

# /etc/clamd.d/mail.conf
LogSyslog yes
TCPSocket 3310
TCPAddr 127.0.0.1
User clamscan

开始

启动后无任何错误

# systemctl start clamd@mail

09:02:35 -- clamd[3644]: Limits: Global size limit set to 104857600 bytes.
09:03:39 -- clamd[3664]: Received 0 file descriptor(s) from systemd.
09:03:39 -- clamd[3664]: clamd daemon 0.100.0 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)
09:03:39 -- clamd[3664]: Running as user clamscan (UID 992, GID 989)
09:03:39 -- clamd[3664]: Log file size limited to 1048576 bytes.
09:03:39 -- clamd[3664]: Reading databases from /var/lib/clamav
09:03:39 -- clamd[3664]: Not loading PUA signatures.
09:03:39 -- clamd[3664]: Bytecode: Security mode set to "TrustSigned".
09:04:01 -- clamd[3664]: Loaded 6575820 signatures.
09:04:08 -- clamd[3664]: TCP: Bound to [127.0.0.1]:3310
09:04:08 -- clamd[3664]: TCP: Setting connection queue length to 200

地位

# systemctl status clamd@mail[email protected] - clamd scanner (rspamd) daemon
Loaded: loaded (/usr/lib/systemd/system/[email protected]; static; vendor preset: disabled)
Active: inactive (dead)

# lsof -i | grep 3310
Empty

看来该服务未作为守护进程运行。我尝试编辑,但没有得到预期的结果(它总是重新启动)/usr/lib/systemd/system/[email protected]

[Service]
Type = simple
ExecStart = /usr/sbin/clamd -c /etc/clamd.d/%i.conf --foreground=yes
Restart = on-failure

答案1

问题出在 RAM 上。使用 512Mb,将其增加到 896Mb 后问题解决。

无需使用--foreground=all即可运行服务。此参数也可以用于/etc/clamd.d/mail.conf

相关内容