/var/log/journal不小心删除了我的后,我无法从后果中恢复过来。systemd-journald每次我尝试启动它时都会一遍又一遍地失败。当我运行时:
$ journalctl --verify
PASS: /run/log/journal/system.journal
Run Code Online (Sandbox Code Playgroud)
这并没有让我更接近解决它,因为它/run/log/journal/system.journal是在我/usr/lib/systemd/systemd-journald直接运行时创建的,它自己输出
$ /usr/lib/systemd/systemd-journald
Failed to open runtime journal: Invalid argument
Run Code Online (Sandbox Code Playgroud)
我已经尝试过的事情:
/var/log/journal and/run/log/journal`。/var/log/journal从另一台机器复制到两条路径,运行journalctl --verify检查它们,并再次使用--file标志。/etc/systemd/journald.conf为Storage=volatile只是禁用/var/log/journald.我有一台运行 CoreOS 的服务器,我通过 DHCP 配置的主网络接口获得了一个运营商并且可以路由,但永远不会离开configuring状态。这会导致systemd-networkd-wait-online.service失败。查看 的日志文件systemd-networkd.service,我看到接口从何处获取载体,但没有看到任何错误消息可以帮助我弄清楚为什么它卡在configuring状态中。关于如何调试这个的任何建议?
下面是一些相关的细节:
core@server ~ $ networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier configured
2 enp0s25 ether routable configuring
3 docker0 ether no-carrier configured
3 links listed.
core@server ~ $ networkctl status enp0s25
? 2: enp0s25
Link File: /usr/lib64/systemd/network/99-default.link
Network File: /usr/lib64/systemd/network/zz-default.network
Type: ether
State: routable (configuring)
Path: pci-0000:00:19.0
Driver: e1000e
Vendor: Intel Corporation
Model: Ethernet Connection (3) I218-V
HW Address: b8:ae:ed:76:f9:cd (Elitegroup Computer Systems …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Vagrant 盒子上设置一个 systemd 服务,它需要在开始之前安装 Vagrant 同步文件夹。
流浪档案
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/yakkety64"
config.vm.synced_folder ".", "/usr/local/src"
config.vm.provision "shell", path: "bootstrap/bootstrap"
end
Run Code Online (Sandbox Code Playgroud)
/etc/systemd/system/my-server.service
[Service]
ExecStart=/usr/bin/node /usr/local/src/index.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=my-server
User=ubuntu
Group=ubuntu
[Unit]
Requires=remote-fs.target
After=vboxguest.service
After=virtualbox-guest-utils.service
[Install]
WantedBy=remote-fs.target
Run Code Online (Sandbox Code Playgroud)
如果我不启用my-server服务,则同步文件夹已正确安装。但是当我尝试启用my-server服务时,该服务无法找到挂载的文件。如果我然后登录到 Vagrant 框,则不会安装该文件夹。似乎该服务尝试从该路径加载文件会干扰 Vagrant。
那么,如何在我的服务启动之前等待文件夹被挂载?
其他解决方案在各种方面都存在不足,需要人工干预才能启动服务,这是不可接受的。
我正在做一些服务器配置,我需要在安装后运行一个脚本,因为它要求系统功能齐全,包括服务。所以我不能把它放在%post我的 kickstart 文件的部分中。
相反,我创建了一个 systemd 服务,该服务在它所做的最后一件事中将自身禁用。
[Unit]
Description=Prepare the system after installation
[Service]
Type=oneshot
ExecStart=/usr/bin/prepare-system
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
问题是在第一次启动时,我进入了登录提示,甚至可以登录并开始使用系统,而“首次启动脚本”仍在运行。
这给了管理员设置系统的错觉,认为系统已经完成,而实际上并没有。
相反,我希望该服务延迟启动,最好显示一条消息,例如“系统正在准备中,请稍候……”并在那里等待,直到脚本完成。
我正在基于 Ubuntu 16.04 AMI 构建一个 AMI。
当我从我的 AMI 启动一个实例时,我想传入一个在 AMI 上启动服务之前运行的用户数据脚本。
看起来用户数据在cloud-final.service. 如果我systemctl status cloud-final或journalctl -u cloud-final我看到我的用户数据脚本的输出。
我尝试设置我的 .service 文件以在 cloud-final.service 之后启动服务
[Unit]
Description=My Service
After=network.service
After=cloud-final.service
...
Run Code Online (Sandbox Code Playgroud)
但是 cloud-final 有RemainAfterExit=yes,这意味着它永远不会完成,所以我的服务永远不会启动。
在运行用户数据脚本后,如何配置 AWS Ubuntu 以启动我的服务?
要通过名称访问网络上的其他计算机,我必须将以下两行添加到我的/etc/resolv.conf:
search foo.local
nameserver 192.168.X.Y
Run Code Online (Sandbox Code Playgroud)
但我所做的任何更改在重新启动后都不会保留。
这是 my 的内容/etc/resolv.conf,它实际上是以下符号链接/run/systemd/resolve/stub-resolv.conf:
$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must …Run Code Online (Sandbox Code Playgroud) 在 Debian 10 上,service rabbitmq-server start需要 10 秒;service rabbitmq-server stop需要 5 秒。
这适用于负载极低且启动/停止速度比 RabbitMQ 性能或可靠性更重要的 Docker 开发环境。因此,停止并重新启动容器需要 15 秒。
我怎样才能让它更快?我添加log.default.level = debug了rabbitmq.conf以防万一它会告诉我它在启动过程中正在做什么,但它没有给我任何有用的东西。
从systemctl status foo。我有 afoo.service和 a foo.timer:
Active: activating (auto-restart) (thawing) since Fri 2020-10-09 21:32:56 UTC; 3min 1s ago
Run Code Online (Sandbox Code Playgroud)
我在文档中找不到“解冻”这个词。这是 systemd 246.6。
如果 /etc/fstab 中的 x-systemd.automount 条目被修改,我如何让 systemd 重新解析这些条目?
当我手动运行该服务时,它会在启动时记录一些内容。
但当它作为 systemd 进程启动时,我无法在任何地方找到该日志。
journalctl -u <service>只显示服务启动和停止的记录,不显示实际的服务输出。
我尝试将配置添加到/etc/systemd/system/<service>.service文件中:
StandardOutput=append:/var/opt/<service>/stdout.log
StandardError=append:/var/opt/<service>/stderr.log
Run Code Online (Sandbox Code Playgroud)
但这也没有帮助 - 文件是在守护进程和服务重新启动后创建的,但它们是空的。
我缺少什么?
感谢您的任何建议,我没有想法。
systemd ×10
networking ×2
automount ×1
centos ×1
centos7 ×1
debian ×1
internal-dns ×1
journalctl ×1
journald ×1
logging ×1
rabbitmq ×1
redhat ×1
stdout ×1
ubuntu ×1
ubuntu-16.04 ×1
vagrant ×1
virtualbox ×1