我有一个 systemd 服务,显示以下错误 service start request repeated too quickly, refusing to start
我知道该服务被配置为在失败时重新启动,并且它一次又一次地重新启动。但它究竟什么时候拒绝重启?是否有定义它的限制或数量?
此外,究竟是too quickly什么意思,它是给定时间段内重启次数的限制吗?
我无法弄清楚如何删除不再有文件的 systemd 单元。他们似乎仍然以某种方式徘徊在系统中。
我试图删除的旧损坏单元:
core@ip-172-16-32-83 ~ $ systemctl list-units --all firehose-router*
UNIT LOAD ACTIVE SUB DESCRIPTION
<E2><97><8F> firehose-router@02.service not-found failed failed firehose-router@02.service
<E2><97><8F> firehose-router@03.service not-found failed failed firehose-router@03.service
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
2 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
Run Code Online (Sandbox Code Playgroud)
这些文件不存在,但重新加载仍然有这些单位挥之不去:
core@ip-172-16-32-83 ~ $ systemctl list-unit-files …Run Code Online (Sandbox Code Playgroud) 我已经pimd通过apt. 这带有上游systemd单元文件 ( /lib/systemd/system/pimd.service)。
我希望服务在由于某种原因被杀死时重新启动,因此我希望Restart = always在单元文件中添加该行。
但是,我不想修改上游单元文件。
有什么解决方法吗?
我需要在系统服务崩溃或挂起时发送网络消息(即进入失败状态;我使用 WatchdogSec= 监视挂起)。我注意到较新的 systemd 有 FailureAction=,但后来发现这不允许任意命令,而只是重新启动/关闭。
具体来说,我需要一种方法来在 systemd 检测到程序崩溃时发送一条网络消息,并在检测到程序挂起时发送另一条网络消息。
我希望有一个比“解析日志”更好的答案,而且我需要一些具有近乎即时响应时间的东西,所以我认为轮询方法不是很好;它应该是由事件发生触发的东西。
我希望我的 systemd 服务在失败时自动重新启动。此外,我想对重新启动进行速率限制。我想在 90 秒内最多允许 3 次重启。因此我做了以下配置。
[Service]
Restart=always
StartLimitInterval=90
StartLimitBurst=3
Run Code Online (Sandbox Code Playgroud)
现在服务在失败时重新启动。在 3 次快速失败/重新启动后,它不再按预期重新启动。现在我希望 systemd 在超时 ( StartLimitInterval)后启动服务。但是 systemd 不会在超时(90 秒)后自动启动服务,如果我在超时后手动重新启动服务,它正在工作。但我希望 systemd 在StartLimitInterval. 请让我知道如何实现此功能。
我找到了这个 systemd 服务文件来启动 autossh 以保持 ssh 隧道:https : //gist.github.com/thomasfr/9707568
[Unit]
Description=Keeps a tunnel to 'remote.example.com' open
After=network.target
[Service]
User=autossh
# -p [PORT]
# -l [user]
# -M 0 --> no monitoring
# -N Just open the connection and do nothing (not interactive)
# LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM
ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -p 22 -l autossh remote.example.com -L 7474:127.0.0.1:7474 -i /home/autossh/.ssh/id_rsa
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
有没有办法将 systemd 配置为在一个服务中启动多个隧道。
我不想创建N个系统服务文件,因为我想避免复制+粘贴。
除了“remote.example.com”将替换为其他主机名之外,所有服务文件都将相同。
我大约在 1.5 年前问过这个问题。
我的想法变了。是的,这很好,你可以用 systemd …
在我的一台服务器上,我注意到 SSH 登录确实有延迟。
使用 ssh -vvv 选项连接延迟发生在 debug1: Entering interactive session.
连接摘录:
debug1: Authentication succeeded (publickey).
Authenticated to IP_REDACTED ([IP_REDACTED]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: packet_set_tos: set IP_TOS 0x10
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 1
Run Code Online (Sandbox Code Playgroud)
使用此处概述的方法,我生成了 strace 输出并注意到14:09:53.676004 ppoll([{fd=5, events=POLLIN}], 1, {24, 999645000}, NULL, 8) …
我在 ubuntu 16.04 上运行 docker 并想查看日志。但是,在我猜测是某种轮换或日志增长到一定大小后,我无法查看日志。
我没有对我的 journald.conf 做任何更改,所以我在那里使用默认值。有容器在运行,所以 docker 日志输出了相当多的数据。
我所看到的示例:
systemctl docker status 确认服务已激活:
since Thu 2016-10-13 18:56:28 UTC
Run Code Online (Sandbox Code Playgroud)
但是,当我运行类似的东西时:
journalctl -u docker.service --since "2016-10-13 22:00"
Run Code Online (Sandbox Code Playgroud)
我得到的唯一输出是:
-- Logs begin at Fri 2016-10-14 01:18:49 UTC, end at Fri 2016-10-14 16:18:25 UTC. --
Run Code Online (Sandbox Code Playgroud)
我可以按预期查看该范围内的日志。
我的问题是:为什么我不能使用 journalctl 查看旧日志,我该如何解决这个问题以便查看日志?
我已经成功地增加了本地用户的 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
Run Code Online (Sandbox Code Playgroud)
/etc/security/limits.d/20-nproc.conf(目录中没有其他文件)
* soft nofile 102400
* hard nofile 102400
* soft nproc 10240
* hard nproc 10240
Run Code Online (Sandbox Code Playgroud)
/etc/sysctl.conf
fs.file-max = 2097152
Run Code Online (Sandbox Code Playgroud)
/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 …Run Code Online (Sandbox Code Playgroud) 我们正在将服务器从非常过时的发行版更新为基于现代 Debian Jessie 的系统,包括 lightdm / xfce,当然还有 systemd(和 udisks2)。一个症结是自动挂载 USB 驱动器。我们过去常常通过一些 udev 规则来实现这一点。旧规则几乎仍然有效 - 安装点被创建并且驱动器安装正常,但几秒钟后 systemd 正在做一些破坏安装的事情,因此随后的访问尝试导致“传输端点未连接”错误。
通过命令行手动安装驱动器工作正常。让文件管理器(thunar 和 thunar-volman,反过来使用 udisks2)也是如此。但这些都不是可行的选择——这些系统大多是无头运行的,所以 thunar 通常不会运行。我们需要能够插入磁盘驱动器以进行无人值守的基于 cron 的备份。
我认为修改 udev 脚本以生成一个在执行挂载前等待几秒钟的分离作业可能会奏效,但 systemd 似乎竭尽全力防止这种情况发生 - 它仍然以某种方式等待分离作业完成之前继续。
也许让 udev 脚本以某种方式使 udisks2 发痒是正确的方法?我不知所措,所以非常感谢任何建议。