所以我创build了我的第一个systemd服务来运行一个python进程。 为此我build立了以下test.service : [Unit] Description=A Simple Test After=multi-user.target [Service] Type=idle ExecStart=/root/testApp/bin/python /root/testApp/run.py [Install] WantedBy=multi-user.target 我把这个文件放在/etc/systemd/system ,启用后它工作正常。 该应用程序正在运行,我可以status 。 但是, top告诉我,它正在运行我的testApp 3次。 为什么? 系统状态输出也显示如下: service test status ● test.service – A Simple Test Loaded: loaded (/etc/systemd/system/test.service; enabled) Active: active (running) since Wed 2017-06-28 21:48:54 CEST; 6min ago Main PID: 2051 (python) CGroup: /system.slice/test.service ├─2051 /root/testApp/bin/python /root/testApp/run.py […]
如何使一个systemd服务,例如nginx,在名称parsing成功后启动? 2017/06/30 08:39:12 [emerg] 737#0: host not found in upstream "upstream.example.com" in /etc/nginx/nginx.conf:109 我试图添加一个插件文件/etc/systemd/system/nginx.service.d/nss-depency.conf [Unit] After=nss-lookup.target 然而,这并没有帮助,这应该是显而易见的,因为/usr/lib/systemd/system/nginx.service已经有了After=network.target remote-fs.target nss-lookup.target在里面。 我有一个与rpc-gssd类似的问题。
为什么? 我的服务是通过正确的单元文件或init脚本启动的。 我不需要普通用户在我的服务器上做任何特殊的事情。 我专门寻找一种方法来完全closurespolkit,而不必在重新启动其他服务时自行启动它。 我预见到一个问题也会在我们的PCI环境中向审计人员解释。 我们必须描述每个服务的目的。 在PCI环境中,我们没有合法的polkit使用案例。 附加说明:我没有安装polkit。 这些服务器的安装量非常小, 大约为670MB。这是一个系统更新,似乎安装了polkit,规范显然对所有systemd托pipe服务具有依赖性。 一旦安装完成,我必须重build机器才能将其删除,就像在安装之后试图删除nss一样。 我担心的是,如果我强制执行unallall,那么可能会留下将系统假定在那里的文件。 我曾经尝试过: 创build/etc/polkit-1/rules.d/99-deny-all.rules polkit.addRule(function(action, subject) { return polkit.Result.YES; }); 然后 systemctl daemon-reload && systemctl daemon-reexec 这样做什么都不做, /usr/lib/polkit-1/polkitd –no-debug当systemd下的其他服务重新启动时, /usr/lib/polkit-1/polkitd –no-debug继续启动。 亚历山大提到,重新启动polkit将设置应用到polkit本身,这是好的,但我正在寻找一种方法来告诉polkit不启动,不会破坏其他服务。 [更新2]这实际上可能会阻止某些服务正确重新启动。 屏蔽或禁用服务: 这会导致其他服务在启动和closures时挂起,等待polkit。 编辑/usr/share/dbus-1/sstem-services/org.freedesktop.PolicyKit1.service : [snip] Exec=/bin/false [snip] 然后 systemctl daemon-reload && systemctl daemon-reexec 这样做什么都不做, /usr/lib/polkit-1/polkitd –no-debug当systemd下的其他服务重新启动时, /usr/lib/polkit-1/polkitd –no-debug继续启动。 我已经阅读了几页的手册页。 这可能是一个很简单的东西,我错过了。 我的首选是在systemd软件包更新后仍然存在的方法。 我正在寻找的最终目标是在其他守护进程重新启动时(例如未绑定,绑定,dhcp等)polkit.service不启动。
对于dpkg -L application显示,我已经安装了几个init脚本的dpkg -L application 。 例如: /etc/init/application.conf /etc/init.d/application /usr/systemd/applaication.service 但我只使用service application start启动? 如何确定哪个脚本应该用于启动应用程序? 据我所知在Ubuntu 12.04默认使用新贵,所以它是/etc/init/application.conf脚本,但是当我做update-rc.d它创build/etc/rc*.d目录符号链接到/etc/init.d/application所以它使用SysV初始化脚本,而不是新贵,而新贵是在Ubuntu默认的初始化。 我很困惑。
在CentOS 7.2服务器上,我试图使用echo t> / proc / sysrq-trigger来转储内核堆栈跟踪。 一些堆栈跟踪没有被logging。 我在/ var / log / messages中看到以下错误。 7月5日13:54:51 glusterfs1日志:错过了14295内核消息 看来,一些条目正在迷失。 我需要从这个服务器find适用的堆栈跟踪。 请build议需要做什么不要错过内核消息。
我已经通过APT安装了knockd,将其configuration在/etc/knockd.conf中 ,并在/ etc / default / knockd中启用 。 但是,当我重新启动系统时,它不会启动。 手动启动工作得很好。 我试图启用它: # systemctl enable knockd.service 但是它失败了,因为knockd.service缺less[Install]部分。 通过简单地将该部分添加到服务文件来让systemd开始敲定是否安全? 这是否意味着以这种方式开始? 在Arch Linux上,knockd附带了服务文件中的[Install]部分。
我正在尝试在安装了OpenJDK 1.8.0_131的Ubuntu Server 16.04 LTS上将Metabase(v0.24.2)jar文件作为systemd服务运行 运行java -jar metabase.jar完美的工作,但我似乎无法得到它作为一个systemd服务。 这是我有的metabase.service文件: [Unit] Description=Metabase server After=syslog.target After=network.target [Service] ExecStart=/usr/bin/java -jar /var/metabase.jar User=administrator Type=simple StandardOutput=syslog StandardError=syslog SyslogIdentifier=metabase Restart=always [Install] WantedBy=multi-user.target 当我开始服务时,我得到: Metabase Initialization FAILED: Assert failed: Unable to connect to Metabase h2 DB 我认为这个问题是不正确的在服务文件中configuration..任何想法? 谢谢!
我有一个systemd单元旨在build立两个服务器之间的SSH隧道。 具有该单元的服务器运行Debian 9.这就是.service文件的样子,除了一些Documentation指令(为了简洁起见我省略了它们(它们不是问题,而且systemd可以parsing它们): # cat /etc/systemd/system/ssh-tunnel-remote1.service [Unit] Description=SSH tunnel for services on remote1 After=network-online.target [Install] WantedBy=networking.target [Service] Type=simple User=ssh-remote1 Group=ssh-remote1 Environment=AUTOSSH_POLL=90 ExecStart=/usr/bin/autossh -M 0 -q -N -p 15539 -o "PubkeyAuthentication yes" -o "PreferredAuthentications publickey" -o "IdentityFile /home/ssh-remote1/.ssh/id_rsa" -L 9999:127.0.0.1:X [email protected] Restart=always PrivateTmp=true # (注意: -L的X是一个真实的端口号。) 在运行此服务的服务器上, /usr/bin处于/ ,因此,启动服务时不会挂载文件系统。 After=network-online.target应该足够使DNS可用,即使是这样的问题,你会认为systemd在失败时会重启服务。 服务本身看起来像启用: # find /etc/systemd -name ssh-tunnel-remote1\* […]
我有一套由systemd-nspawnpipe理的容器。 容器应该与外部networking(半)隔离,但同时应该能够访问主机上运行的非集装箱服务,如DBMS(见图)。 networking由systemd-networkd两端pipe理。 我已经尝试了systemd-nspawn的以下最常见的专用networking模式: 虚拟以太网 -n, –network-veth为每个容器创build一对连接的虚拟以太网适配器,一个在主机端,另一个在容器内。 看起来好像没什么用处,因为不清楚DBMS应该监听哪个地址以及容器应该连接到哪个地址。 桥 –network-bridge=大致相同,但将虚拟适配器添加到指定的桥接器。 桥应该已经安装并分配了一个IP: # /etc/systemd/network/br0.netdev [NetDev] Name=br0 Kind=bridge # /etc/systemd/network/br0.network [Match] Name=br0 [Network] Address=169.254.1.1/16 这个configuration已经被certificate是可行的,但是需要额外的网桥configuration,并且在涉及容器的外部networking访问时通常是有问题的。 区 –network-zone=相同,但自动pipe理网桥接口。 以下是我们在桥上默认获得的内容: [root@host ~]# ip addr show vz-containers 26: vz-containers: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 inet 169.254.120.107/16 brd 169.254.255.255 scope link vz-containers valid_lft forever preferred_lft […]
在Arch linux上我有OpenVpn服务器。 它运作良好。 但是,当我把它添加到它的configuration: script-security 2 duplicate-cn up /etc/openvpn/server/script1.sh client-connect /etc/server/openvpn/script1.sh client-disconnect /etc/server/openvpn/script1.sh 它不会再启动了,不清楚错误是什么。 我是存在/etc/server/openvpn/script1.sh文件。 $ sudo systemctl restart [email protected] Job for [email protected] failed because the control process exited with error code. See "systemctl status [email protected]" and "journalctl -xe" for details. 并在systemctl status [email protected] : systemd[1]: Stopped OpenVPN service for server123. systemd[1]: Starting OpenVPN service […]