我的单元文件看起来像这样(已经试图像文档所说的那样将空格转义为\x20 ): [Unit] Description=My Service [Service] Type=simple WorkingDirectory=/home/cobra/my\x20service/ ExecStart=/home/cobra/my\x20service/start.sh [Install] WantedBy=multi-user.target 但试图启动时,会失败并显示以下消息: Failed at step CHDIR spawning /home/cobra/my service/start.sh: No such file or directory myservice.service: main process exited, code=exited, status=200/CHDIR 从这个错误信息给stat返回的path: File: '/home/cobra/my service/start.sh' Size: 280 Blocks: 8 IO Block: 4096 regular file Device: 903h/2307d Inode: 4718912 Links: 1 Access: (0754/-rwxr-xr–) Uid: ( 1000/ cobra) […]
我正尝试在Ubuntu 16.04 VPS上重命名networking接口,但无法这样做。 系统命名我的主要networking接口enp0s3。 我想将这个接口重命名为eth0。 根据systemd.link文档,我创build了一个名为/etc/systemd/network/10-eth0.link ,内容如下: [Match] MACAddress=08:00:27:f7:57:e5 [Link] Name=eth0 MAC地址与接口的ip a输出中给出的MAC地址相匹配。 我还将/etc/network/interfaces文件中的enp0s3条目重命名为eth0。 虽然,当我重新启动机器时,界面仍被命名为enp0s3。 dmesg输出中的以下条目对我来说很有意思: e1000 0000:00:03.0 eth0 🙁 PCI:33MHz:32位)08:00:27:f7:57:e5 e1000 0000:00:03.0 eth0:Intel(R)PRO / 1000networking连接 e1000 0000:00:03.0 enp0s3:从eth0重命名 显然,它起始于eth0,但是之后又重新命名为enp0s3。 我不知道为什么? 当我尝试debugging链接文件时,我得到以下输出: $ sudo udevadm test-builtin net_setup_link /etc/systemd/network/10-eth0.link calling: test-builtin === trie on-disk === tool version: 229 file size: 6841778 bytes header size 80 bytes […]
从一开始标准UNIX / Linux系统支持稀疏文件,这是一个文件,其中包含未使用的空间,直到需要时才分配。 通过一个C程序来生成一个文件,定位到2G,写一个字节,closures文件。 做一个ls -l显示的大小是2G ….但是ls -ls显示块的大小接近一个字节的文件。 如果你逻辑地访问该文件(即cp sparse_file xxx),结果文件xxx确实将包含一个完全分配的2G字节。 过去我已经创build了稀疏文件,作为一些应用程序的testing工具。 但是,他们的存在造成了一些问题。 重要的问题是在“转储”程序之外,备份程序和通用程序在逻辑上访问这些types的文件,因此对于1字节的稀疏文件,获得具有0数据的2G备份。 当我这样做的时候,这导致了一些不安的备份人员。 对于这种情况有什么好的解决办法?
我有通过systemd-networkd添加直接路由的问题。 我试图达到的是类似于: ip aa 192.168.0.2/32 dev enp0s3 ip ra 192.168.0.1/32 dev enp0s3 ip ra default via 192.168.0.1 这是奇怪的设置,我知道,但我不能使用通常的ip aa 192.168.0.2/24到达网关。 出于某种原因,整个/ 24子网可通过此子网中的网关到达。 所以这个默认路由不仅适用于通用路由,而且也适用于子网。 所以,我创build了/etc/systemd/network/enp0s3.network: [Match] Name=enp0s3 [Address] Address=192.168.0.2/32 [Route] Destination=192.168.0.1/32 [Route] Gateway=192.168.0.1 这个设置的问题是第二个Route块从不执行。 我做了一些debugging,这是什么ip和systemd-networkd为第一个Route块做的区别。 # ip 192.168.0.1 dev enp0s3 scope link # networkd 192.168.0.1 dev enp0s3 proto static 所以systemd-networkd不会将scope link添加到路由。 这就是为什么试图通过192.168.0.1添加默认路由失败, Network is unreachable错误。 这是可以解决的 […]
为什么timezonectl没有列出所有可用的时区? $ timedatectl ⋮ Timezone: UTC (UTC, +0000) ⋮ $ timedatectl list-timezones | grep -i utc -no output- $ timedatectl list-timezones | wc -l 417 ls /usr/share/zoneinfo包括UTC,UCT,GMT,Universal等,但是这些都不包括在列表中。 我在CentOS 7中注意到了这一点,特别是在两台不同的机器上有相同的结果。 有趣的是,Ubuntu显示“UTC”而不是“GMT”。 哪些在./zoneinfo中存在。 所以整个事情对我来说是相当混乱的。
我一直在尝试熟悉CoreOS(633.1.0),我一直在玩舰队(我在本地机器上使用推荐的Vagrant 3集群设置)。 我创build了以下非常基本的服务( [email protected] ): [Unit] Description="Dummy Apache service" After="docker.service" Requires="docker.service" [Service] TimeoutStartSec=0 TimeoutStopSec=30 ExecStartPre=-/usr/bin/docker kill apache1 ExecStartPre=-/usr/bin/docker rm apache1 ExecStartPre=/usr/bin/docker pull coreos/apache ExecStart=/usr/bin/docker run –rm –name apache1 -p 80:80 coreos/apache /usr/sbin/apache2ctl -D FOREGROUND ExecStop=/usr/bin/docker stop apache1 [X-Fleet] Conflicts=apache@*.service 当我启动它时,它只是完美的工作,但是,每当我试图阻止它,它被标记为失败。 当stop命令开始执行时,这是例如fleetctl status apache@2的输出: core@core-01 ~ $ fleetctl stop apache@2 Unit [email protected] loaded on a91e28b0…/172.17.8.101 core@core-01 […]
我知道systemd提供了一个很好的机制来覆盖包提供的单元文件来影响服务configuration/行为。 这通常通过使用下面的命令完成 sudo systemctl edit <unitfile> 创build覆盖conf文件 /etc/systemd/system/<unitfile.d>/ Systemd还提供了一个单独的机制来定义一个模板单元文件,并将其实例化为在运行时创build特定于实例的单元。 这需要将模板文件命名为 <servicename>@.service 然后将其实例化为 systemctl start <servicename>@<instancename> 现在,我有一种情况,我想将包提供的服务作为多个单元实例运行。 我想避免创build自己的模板单元文件,所以我想看看是否可以重写包提供的单元文件来创build模板单元文件。 因为根据我的理解,模板单元文件的命名约定与常规单元文件不同,所以我认为我不能用模板文件将其放在/ etc / systemd / system中来覆盖软件包提供的单元文件。 有没有什么明确的方法来实现我想要做的? 具体场景:grafana包安装一个grafana-server.service单元文件。 我想在我的机器上运行grafana的两个实例 – DEV和STG各一个。 我已经能够做到这一点: 修改grafana-server.service文件(使用%I设置文件夹位置和文件path) 将修改后的grafana-server.service重命名为grafana-server @ .service 使用以下命令启动Grafana的实例: sudo systemctl start grafana-server@dev 和 sudo systemctl start grafana-server@stg 但是,这将从Grafana提供的服务单元文件中断开连接,如果在升级时增强了服务文件,则需要重新执行此活动。 我的目标是避免这种直接的依赖,而是将其转换为重写依赖。 有什么想法吗?
我试图更新一些在RHEL机器上禁用CAD的Puppet清单。 现在我正在做systemd:masking(即链接到/ dev / null) $ctrlaltdel_process = '/usr/bin/logger -p security.info "Control-Alt-Delete pressed"' # Every version of RHEL has a different way of doing this! 🙂 case $::operatingsystemmajrelease { '4','5': { augeas { 'disable-inittab-ctrlaltdel': context => '/files/etc/inittab', lens => 'inittab.lns', incl => '/etc/inittab', changes => "set *[action = 'ctrlaltdel']/process '${ctrlaltdelprocess}'", } } '6': { file { […]
如何确保在特定系统服务停止时执行特定的订单? 我有几个systemd服务/单位,我已经运行,但使用各种装载分区上的资源。 这些分区使用自定义服务进行挂载和卸载。 正在运行的服务(例如ProgramA.service&ProgramB.service)需要在自定义安装程序停止之前按特定顺序停止。 设置启动依赖关系是相当简单的,但我还没有能够弄清楚如何确保服务在停止服务之前停止。 mountCustomPartitions.service [Unit] Description=My Custom Partition Mounting Service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/mountCustomPartitions.sh mount ExecStop=/usr/bin/mountCustomPartitions.sh unmount [Install] WantedBy=multi-user.target ProgramA.service [Unit] Description=My Generic Program A Service Wants=mountCustomPartitions.service After=mountCustomPartitions.service [Service] Type=simple ExecStart=/usr/bin/ProgramA [Install] WantedBy=multi-user.target ProgramB.service [Unit] Description=My Generic Program B Service Requires=ProgramA.service Wants=mountCustomPartitions.service After=mountCustomPartitions.service ProgramA.service [Service] Type=simple ExecStart=/usr/bin/ProgramB [Install] WantedBy=multi-user.target 在我上面的场景中,mountCustomPartitions.service必须在程序服务之前启动,但也必须在它们之后停止。 如果mountCustomPartitions.service被明确地停止,那么它应该导致其他的也停止(但是必须等待它们被停止)。 我还需要确保ProgramB在ProgramA之后启动,但也在ProgramA之前停止。 希望这不是太混乱。 […]
我有一个由systemd作为服务运行的关键应用程序。 它被设置为在失败后立即重新启动。 如果应用程序重新启动,如何发送电子邮件?