Articles of systemctl

Elasticsearch服务经常停止或被杀死

我的web服务器运行ubuntu 14.10与elasticsearch 1.5.0和java 1.7u55 由于某种原因,elasticsearch服务经常停止,导致我的网站不再提供给我的用户(使用带有symfony的FOSElasticaBundle)。 我正在使用systemctl自动重新启动,但我宁愿一劳永逸一个很好的修复。 我觉得我所拥有的logging不够具有描述性。 对于pipe理服务器来说很新,我需要一些帮助。 有人能帮我弄清楚这个失败的原因吗? 我可以在这里输出什么正确的文件来更好地理解这个问题? 谢谢 ! 我的systemctl状态给出: elasticsearch.service – ElasticSearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled) Active: active (running) since Mon 2015-04-20 12:04:24 CEST; 1h 56min ago <————- Here it means restarted 1h56 ago. Why did it fail in the first place ? Main PID: 9120 (java) CGroup: /system.slice/elasticsearch.service └─9120 /usr/bin/java […]

在Ubuntu 16.04上使用systemd截断/丢失日志

我使用的是Ubuntu 16.04服务器,已经创build了一个基本的nodejs脚本,并将其打包在一个简单的systemd服务中。 /lib/systemd/system/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 当我用journalctl -u api.service -n -f看日志时,看起来我的一些脚本输出行没有被logging,特别是当脚本在很短的时间内产生大量的日志行时。 例如,如果nodejs脚本只是输出前3000个整数的一个简单的for循环,那么只有大约2500行似乎被logging在日志中。 /var/node/api/index.js处的index.js的内容: for (var i = 1; i <= 3000; i++) { console.log(i); } console.log("end of script"); 当用journalctl -u api.service -n -f查看日志时,我只能得到大约2500行: May 04 13:52:15 test systemd[1]: Stopping api… May 04 13:52:15 test systemd[1]: […]

木偶和systemctl麻烦

我和puppet和systemctl有一些麻烦。 我曾经加载了一个“服务”的几个参数,但它不能在centos7上工作。 这是我的错误: Error: Could not enable [ntpd ntpdate]: Error: /Stage[main]/Ntp::Service/Service[[ntpd ntpdate]]/enable: change from false to true failed: Could not enable [ntpd ntpdate]: 这是我的代码: Hiera: ntp::service::ntp_services: – "ntpd" – "ntpdate" Service.pp: class ntp::service ($ntp_services) { service {"$ntp_services": hasrestart => false, hasstatus => true, ensure => running, enable => true, } } 它在centos 6上工作得非常好,而且它曾经在centos 7上工作。 如果我像这样定义参数,它是有效的: […]

无法启动nagios.service:单位nagios.service未能加载:没有这样的文件或目录

我一直在关注这个教程 : $ sudo systemctl start nagios Failed to start nagios.service: Unit nagios.service failed to load: No such file or directory. 问题的原因是什么? 我有: $ 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 […]

无法获取属性:激活org.freedesktop.systemd1超时

在RHEL 7 linux服务器中运行systemctl status命令时出现以下错误。 # systemctl status docker.service Failed to get properties: Activation of org.freedesktop.systemd1 timed out 我看到login也很慢。 可能是什么问题呢?

Systemd导致多个主pipe进程

我有一个问题缩小问题是我的主pipeconfiguration,导致程序被复制。 我正在通过Nginx反向代理运行Python Tornado Web服务器。 不过,我认为这个问题更多的与主pipe有关。 /etc/supervisor/supervisord.conf [unix_http_server] file=/var/run/supervisor.sock chmod=0700 [supervisord] logfile=/var/log/supervisor/supervisord.log pidfile=/var/run/supervisord.pid childlogdir=/var/log/supervisor logfile_maxbytes=50MB logfile_backups=5 loglevel=error [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///var/run/supervisor.sock [include] files = /etc/supervisor/conf.d/*.conf /etc/supervisor/conf.d/tornado.conf [program:tornado] numprocs = 4 numprocs_start = 8000 process_name = %(program_name)s_%(process_num)02d directory=/home/username/webapp environment=PATH="/home/username/.virtualenvs/tornado_env/bin" command = python server.py –port=%(process_num)s user=www-data redirect_stderr=true stdout_logfile=/var/log/webapp/%(program_name)s_%(process_num)02d.log loglevel=info 正如你可以看到numprocs = 4 ,但是在刚刚重启服务器之后,我的困惑就来自于这个。 ps -aux | […]

Postfix在重启时不启动

我在CentOS 7上,据我所知,Postfix在重新启动时所需要的就是运行systemctl enable postfix.service 但是,这不适合我。 重新启动后, systemctl status postfix产生以下内容: postfix.service – Postfix Mail Transport Agent Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled) Active: inactive (dead) 在错误日志中没有logging错误,Postfix启动时工作正常,当我手动执行。 任何想法我做错了什么? 编辑:输出从cat /etc/systemd/system/multi-user.target.wants/postfix.service [Unit] Description=Postfix Mail Transport Agent After=syslog.target network.target Conflicts=sendmail.service exim.service [Service] Type=forking PIDFile=/var/spool/postfix/pid/master.pid EnvironmentFile=-/etc/sysconfig/network ExecStartPre=-/usr/libexec/postfix/aliasesdb ExecStartPre=-/usr/libexec/postfix/chroot-update ExecStart=/usr/sbin/postfix start ExecReload=/usr/sbin/postfix reload ExecStop=/usr/sbin/postfix stop [Install] WantedBy=multi-user.target

redhat 6.6 64位操作系统中的systemctl命令在哪里?

我试图通过以下命令来运行networking的状态。 sudo systemctl status network 但是系统说没有findsystemctl命令。

在systemctl中显示自定义退出状态

我想在有人运行systemctl status并且脚本失败时显示自定义消息。 Systemd似乎有一些内置的。 如果我有一个脚本运行exit 200 systemctl状态将出(code=exited, status=200/CHDIR) 如何设置自定义消息的状态? 我想能够做exit 199 ,并显示像status=199/MY_CODE

如何从systemd服务的内容输出日志到文件

那么,我有一个configurationsystemctl服务。 这是configuration文件: [Unit] Description=The description of the service (: After=network.target [Service] ExecStartPre=/bin/echo 'Starting Service' >> /var/log/node/myapp.log ExecStart=/root/.nvm/versions/node/v5.0.0/bin/node ./bin/www ExecStopPost=/bin/echo 'Stopping Service' >> /var/log/node/myapp.log Restart=always #StandardOutput=/var/log/node/myapp.log #StandardError=/var/log/node/myapp.log SyslogIdentifier=myapp Environment=NODE_ENV=production WorkingDirectory=/home/user/node-apps/theapp [Install] WantedBy=multi-user.target 我需要的?: 1) ExecStartPre和ExecStopPost可以将消息'starting service'或'stopping service'写入文件/var/log/node/myapp.log 。 使用上述configuration,不起作用,它只输出'Starting Service' >> /var/log/node/myapp.log和'Stopping Service' >> /var/log/node/myapp.log到journalctl 。 (我查了journalctl -u myapp ) 2)我需要,而不是应用程序的所有日志,输出到journalctl ,可以输出到一个文件。 例如: /var/log/node/myapp.log 。 我的意思是,如果在我的应用程序,我有一个console.log() […]