Articles of systemd

LUKS上的ZFS在启动时无法识别

我在RAID-Z2中有6个物理驱动器,我打算一个一个地转换成dm-crypt设备。 我的过程大概是: dd if=/dev/zero of=/dev/sdf 创build密钥文件/etc/crypttab.d/crypt-1.key cryptsetup luksFormat /dev/sdf 将crypt-1 <raw-disk-uuid> /etc/crypttab.d/crypt-1.key luks到/etc/crypttab cryptsetup luksOpen /dev/sdf crypt-1 zfs replace my_pool <raw-disk-uuid> /dev/mapper/crypt-1 一旦重新启动完成(其中工作正常),我重新启动机器validation设置,然后继续到其他磁盘。 然而,我发现ZFS将crypt-1标记为UNAVAIL。 ls /dev/mappervalidation了dm-crypt正确地激活了LUKS容器。 zpool online my_pool crypt-1运行zpool online my_pool crypt-1会导致ZFS开始重新同步,但是会以秒的方式完成并恢复正常运行。 我猜dm-crypt设备只是在ZFS第一次尝试访问my_pool时不加载? 这是一个加载顺序的问题,还是我需要为/etc/crypttab的LUKS设备使用不同的标识符? 如何确保ZFS在重新启动时看到这些LUKS设备? 如果有问题的话,这是一个systemd box(Arch)。 谢谢! 编辑1: 在cryptsetup创build过程中,我使用SCSI标识符(例如/dev/sdf )用LUKS初始化设备。 但是,在/etc/crypttab我通过底层物理磁盘的UUID来指定设备。 cryptsetup实用程序对于如何识别目标很敏感? 换句话说,我是否需要重新执行cryptsetup并将磁盘UUID而不是SCSI名称传递给它? 编辑2: 我看到以下ls -alsvh /dev/disk/by-id : 0 lrwxrwxrwx 1 root root […]

通过ec2(请求密码)运行systemd作为默认用户的服务

我正在尝试使用以下Ansible脚本(playbook的一部分)来通过systemd为EC2(微)实例上的rails应用程序运行独angular兽: — – name: restart unicorn command: psql -h {{ db_host }} -U {{ db_user }} -d {{ db }} -c "SELECT true FROM pg_tables WHERE tablename = 'order_cycles';" register: table_exists ignore_errors: yes sudo: yes sudo_user: "{{ unicorn_user }}" notify: restart unicorn step 2 #TODO make sure both of these things run as one handler. […]

使系统用户服务取决于系统目标

我在~/.config/systemd/user/example.service有一个用户服务,如下所示: [Unit] Description=Example service After=network.target [Service] ExecStart=/bin/bash -c 'host google.com > /var/tmp/example' [Install] WantedBy=default.target 当然,我试图控制的实际服务确实有用,并访问了networking。 这只是一个简单的例子。 该服务通过systemctl –user enable example.service来systemctl –user enable example.service ,它创build了指向~/.config/systemd/user/example.service的symlink〜 ~/.config/systemd/user/default.target.wants/example.service ~/.config/systemd/user/example.service 。 通过这个设置,以及Arch维基上描述的systemd用户会话,服务以启动时的用户身份启动。 但是,networkingbuild立后并没有真正启动, 相反,它似乎立即开始,因为/var/tmp/example包含: ;; connection timed out; no servers could be reached (而且,我试图控制的实际服务也无法到达networking,并且出现类似的名称查找错误) 这意味着该服务实际上不会在network.target之后运行。 如何在运行前等待network.target ?

OpenVPN和systemd解决

如何使用systemd-resolved通过openvpn服务器推送的DNS? 在决定升级到systemd-networkd之前。 我可以使用openvpn-resolv-conf脚本的一些变体来调用resolvconf来pipe理成功build立vpn隧道的/etc/resolv.conf中的条目。 这将允许我parsingvpn隧道远端的名字。 现在systemd-resolvedpipe理/run/systemd/resolved/resolv.conf是否可以自动添加DNS通过openvpn连接推送到名称服务器列表用于解决?

可靠的autossh系统服务

我尝试为autossh创build一个可靠的systemd服务。 该服务工作,但如果主机密钥更改,服务处于状态正常(正在运行)。 如果隧道不工作,我希望它处于“失败”的状态。 这是我目前的systemd服务文件: # Source is in srv/salt/tunnel/autossh\@.service # which is a git repo. # Don't edit /etc/systemd/system/autossh\@.service [Unit] Description=Tunnel For %i After=network.target [Service] User=autossh # https://serverfault.com/a/563401/90324 ExecStart=/usr/bin/autossh -M 0 -N -o "ExitOnForwardFailure yes" -o "ConnectTimeout=1" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 40443:installserver:40443 -R 8080:installserver:8080 tunnel@%i Restart=always [Install] WantedBy=multi-user.target 这里是systemctl status autossh@foo-work的输出 salt:/srv […]

如何重新启动由systemd在OutOfMemory错误pipe理的Java应用程序

我有作为systemd服务安装的Java应用程序(在Spring Boot框架之上)。 [Unit] Description=${module_name}-service Requires=network.target After=syslog.target [Service] User=${user_name} ExecStart=/opt/${module_name}/${module_name}-${version}.jar SuccessExitStatus=143 [Install] WantedBy=multi-user.target 如何pipe理某些情况下的服务重启,例如OutOfMemory错误后自动重启

如何让用户使用journalctl查看用户特定的系统服务日志?

我在Ubuntu 16.04 LTS中运行用户级服务。 例如,我有我的test.service位于〜/ .config / systemd / user / test.service 我能够通过做运行服务 systemctl –user start test.target 但是,当我尝试使用journalctl读取其日志时,出现了以下错误消息: journalctl –user -u test.service Hint: You are currently not seeing messages from other users and the system. Users in the 'systemd-journal' group can see all messages. Pass -q to turn off this notice. No journal files were opened […]

等待系统单机服务完成

我正在做一些服务器供应,我需要在安装后运行脚本,因为它需要系统function齐全,包括服务。 所以我不能把它放在我的kickstart文件的%post部分里面。 相反,我已经创build了一个systemd服务,禁用它自己作为最后一件事情。 [Unit] Description=Prepare the system after installation [Service] Type=oneshot ExecStart=/usr/bin/prepare-system [Install] WantedBy=multi-user.target 问题是,在第一次启动时,我到达login提示符,甚至可以login并开始使用系统,而“第一启动脚本”仍在运行。 这给pipe理员设置系统的幻觉系统完成,当它不是。 我反而希望服务延迟启动,最好显示一个消息,如“系统正在准备中,请稍候…”,并等待,直到脚本完成。

在systemd中使用CPUQuota

我正在尝试在dd命令中使用CPU使用的硬限制。 我创build了以下单元文件 [Unit] Description=Virtual Distributed Ethernet [Service] ExecStart=/usr/bin/ddcommand CPUQuota=10% [Install] WantedBy=multi-user.target 其中调用以下简单的脚本 #!/bin/sh dd if=/dev/zero of=/dev/null bs=1024k 正如我在本指南中看到的,我的dd服务的CPU使用率不应超过10%。 但是当我运行system-cgtop命令时,使用率大约是70-75%。 任何想法,我做错了什么,我该如何解决? 当我执行systemctl show dd我得到以下关于CPU的结果 CPUShares=18446744073709551615 StartupCPUShares=18446744073709551615 CPUQuotaPerSecUSec=100ms LimitCPU=18446744073709551615

systemd-journald无法在CentOS 7上启动

自从一个星期前,journald没有开始了。 启动时,它启动并logging引导消息和其他一些服务启动日志,然后在启动Switch Root时突然closures: Mar 18 05:22:56 playground1.local systemd-journal[96]: Runtime journal is using 8.0M (max allowed 391.1M, trying to leave 586.7M free of 3.8G available → current limit 391.1M). Mar 18 05:22:56 playground1.local systemd-journal[96]: Runtime journal is using 8.0M (max allowed 391.1M, trying to leave 586.7M free of 3.8G available → current limit 391.1M). Mar 18 […]