我试图通过以下命令运行网络状态。
sudo systemctl status network
Run Code Online (Sandbox Code Playgroud)
但是系统说找不到 systemctl 命令。
我一直在关注本教程:
$ sudo systemctl start nagios
Failed to start nagios.service: Unit nagios.service failed to load: No such file or directory.
Run Code Online (Sandbox Code Playgroud)
问题的原因是什么?
我有:
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.0.8
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2014
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 …Run Code Online (Sandbox Code Playgroud) 我有以下问题。
我刚刚安装了 DVD CenOS 7。在我启动进入系统后,我通常以 root 用户身份登录。从那里我试图在我的服务器上配置防火墙。
因为我对这一切都比较陌生,所以我只是搜索了一些关于如何启动和管理 Firewalld 的搜索,它似乎是与 CentOS 7 一起使用的预期防火墙软件。
我尝试的第一件事是打字
systemctl status firewalld
Run Code Online (Sandbox Code Playgroud)
作为输出我得到
Warning: iptables not usable, disabling IPv4 firewall.
Warning: ip6tables not usable, disabling IPv6 firewall.
FATAL ERROR: No IPv4 and IPv6 firewall.
ERROR: Raising SystemExit in run_server
Run Code Online (Sandbox Code Playgroud)
我已经尝试重新启动系统,更新它。我重新安装了 iptables 和 firewalld。尝试使用其中任何一个被屏蔽或禁用。这些都没有奏效,但也许我错过了一些东西。
我通常只想设置一个 Teamspeak 服务器供外部使用,当我向防火墙添加特定规则时,该服务器在 Windows 下工作。我想在 CentOS 7 下做同样的事情,主要是出于学习目的或完全熟悉 Linux 作为服务器。
安装后,我运行systemctl enable mysqld.service. 然后,输出是:
Failed to execute operation: Too many levels of symbolic links
Run Code Online (Sandbox Code Playgroud)
出现此错误后,我重新启动了我的服务,并检查了 mysqld.service 的状态。 systemctl status mysqld.service -l
输出是
? mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/mariadb.service.d
??migrated-from-my.cnf-settings.conf
Active: active (running) since Tue 2017-05-16 13:41:06 UTC; 8min ago
Process: 1930 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 767 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment …Run Code Online (Sandbox Code Playgroud) 我对 systemctl 的输出不满意
我有一个解析输出的脚本
systemctl list-units -t service --full --all
Run Code Online (Sandbox Code Playgroud)
输出的开头如下所示:
UNIT LOAD ACTIVE SUB JOB DESCRIPTION
after-local.service loaded inactive dead /etc/init.d/after.local Compatibility
? amavis.service not-found inactive dead amavis.service
apparmor.service loaded active exited Load AppArmor profiles
auditd.service loaded active running Security Auditing Service
Run Code Online (Sandbox Code Playgroud)
在不同的系统上,带点的列(在 amavis.service 之前)不存在。
systemctl 是否有机器/脚本可读的输出?
我,systemctl start apache2在服务已经启动的情况下运行(或其他服务)时会发生什么?
apache2服务一天启动几百次会不会有问题?(防止服务关闭)或者它会使用内存还是危险?
我正在使用 Ubuntu 16.04 服务器,创建了一个基本的 nodejs 脚本并将其打包在一个简单的 systemd 服务中。
api.service 的内容/lib/systemd/system/api.service:
[Unit]
Description=api
After=network.target
[Service]
WorkingDirectory=/var/node/api
ExecStart=/usr/bin/node index.js
Restart=always
RestartSec=5s
StartLimitInterval=60s
StartLimitBurst=5
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
当我用 看日志时journalctl -u api.service -n -f,似乎我的一些脚本输出行没有被记录,特别是当脚本在短时间内产生大量日志行时。
例如,如果 nodejs 脚本只是一个简单的 for 循环,输出前 3000 个整数,那么日志中似乎只记录了大约 2500 行。
index.js 的内容在/var/node/api/index.js:
for (var i = 1; i <= 3000; i++) {
console.log(i);
}
console.log("end of script");
Run Code Online (Sandbox Code Playgroud)
查看日志时journalctl -u api.service -n -f,我只得到大约 2500 行:
May 04 13:52:15 test systemd[1]: Stopping api...
May 04 13:52:15 …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Debian 上安装 RipRight,但似乎没有任何预先构建的软件包。我很难让 systemd 脚本开始/停止 RipRight 作为守护程序运行,因为它无法将 PID 文件写入/run.
我经历了通常的配置/制作/制作安装。我还创建了一个ripright用户/组并添加ripright到该cdrom组中。
这是我放入的 systemd 脚本/etc/systemd/system/ripright.service:
[Unit]
Description=RipRight
[Service]
Type=forking
PrivateTmp=yes
User=ripright
Group=ripright
RuntimeDirectory=ripright
RuntimeDirectoryMode=0750
ExecStart=/usr/local/bin/ripright \
--daemon \
--w32-filenames \
--require-art \
--folder-art folder.png \
--output-file "%B/%D/%C - %N %T.flac" \
"/opt/ripright/data"
PIDFile=/var/run/ripright/ripright.pid
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
我RuntimeDirectory在脚本中使用了最近添加的指令来创建一个作为所有者的/run/ripright文件夹ripright。这个目录在我运行时被创建:
# systemctl daemon-reload
# systemctl start ripright
Run Code Online (Sandbox Code Playgroud)
在单独的窗口中:
# ls -lhrt /run
...
drwxr-x--- 2 ripright ripright 40 Jan …Run Code Online (Sandbox Code Playgroud) 我最近有了一台 Ubuntu 18 服务器,至少可以说我有点困惑。
第一:如果我运行sudo service nginx start或sudo systemctl start nginx,一切似乎都有效。我的网站加载,并且都sudo service nginx status和sudo systemctl status nginx返回的所有明确的信息。
现在的问题是:当我重新启动我的服务器时,nginx不会自动启动,因为网站没有被加载。我试过sudo systemmctl enable nginx又试了一次重新启动。同样,nginx由于网站未加载而未运行。
事实上,如果我重新启动我的服务器sudo reboot然后sudo service nginx status或者sudo systemctl status nginx我收到一条错误消息。尽管有错误消息,但我可以运行sudo service nginx start或者sudo systemctl start nginx它会全部恢复工作。
我收到的错误消息如下:
(venv) user@server:/data/project$ sudo systemctl status nginx
? nginx.service - A high performance web server and a reverse proxy server
Loaded: …Run Code Online (Sandbox Code Playgroud) 我四处寻找,并竭尽全力找出为什么 systemctl 无法启动我的单元。
\n\n我正在尝试将 GCP 的 cloud-sql-proxy 作为 systemd 服务启动。这就是我的cloud-sql-proxy.service样子。
[Install]\nWantedBy=multi-user.target\n\n[Unit]\nDescription=Cloud SQL Proxy\nRequires=networking.service\nAfter=networking.service\n\n[Service]\nType=simple\nWorkingDirectory=/opt\nExecStart=/opt/cloud_sql_proxy -instances=pupa=tcp:5432 -credential_file=/etc/pupa-240309-5336639b0c06.json\nRestart=always\nStandardOutput=journal\nUser=root\nRun Code Online (Sandbox Code Playgroud)\n\n我跑sudo systemctl enable cloud-sql-proxy成功了。然后当我执行时sudo systemctl start cloud-sql-proxy.service失败并显示以下消息:
Failed to start cloud-sql-proxy.service: Unit not found.\nRun Code Online (Sandbox Code Playgroud)\n\n以下是更多信息:
\n\n$ ll -al /etc/systemd/system/cloud-sql-proxy.service\n-rw-r--r--. 1 root root 327 May 22 10:56 /etc/systemd/system/cloud-sql-proxy.service\n\n$ sudo systemctl list-unit-files\n...\ncloud-sql-proxy.service enabled\n...\n\n$ systemctl status cloud-sql-proxy\n\xe2\x97\x8f cloud-sql-proxy.service - Cloud SQL Proxy\n Loaded: loaded (/etc/systemd/system/cloud-sql-proxy.service; enabled; vendor preset: disabled)\n Active: failed (Result: resources) since Sun 2019-05-19 …Run Code Online (Sandbox Code Playgroud)