当前位置:   article > 正文

apache,httpd服务启动报错解决方法【linux用日志排错方法】_systemctl restart httpd失败原因

systemctl restart httpd失败原因

说明

  • 我这以apache服务启动报错和etcd启动报错为列
  • 但无论是什么原因导致某服务启动失败的,不要慌,要学会看日志,日志一般都有详细提示。
  • 查看日志的方式有2种,一种是执行:journalctl -xe,另一种是查看messages的方式,两种方式不是绝对的某一种好使,下面我会分别作出说明。
  • 其实无论是哪种方式,查看到的报错内容根本都是一样的,只是这2种方式对于不同的服务会有不同的展示方式,所以2种都会的话是最好的了。

apache【httpd】启动报错【messages定位】

  • 报错如图:
    在这里插入图片描述
[root@control ~]# systemctl start httpd
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
  • 1
  • 2
  • httpd服务启动可能报错原因各有不同,但无论是什么原因导致的,不要慌,要学会看日志,日志一般都有详细提示。

解决步骤

方式一【journalctl】

  • 启动报错的时候下面会提醒你输入 systemctl status httpd.servicejournalctl -xe查看详细
    在这里插入图片描述
  • 说明
    • systemctl status httpd.service:既然服务起不来,那么看的这个状态肯定是failed的。
    • journalctl -xe:这是直接查看日志,这里面可能会有关键字
      这个呢,就注意看有没有:invalid value这个开头的关键字,如果有的话,一般后面就是报错内容了
      可以这样:journalctl -xe | grep "invalid value"过滤哦。
      但这个不适用于http,因为http配置文件太多,过滤出来看不出是哪行,所以就pass了,但日志有行号哦。

在这里插入图片描述

方式二【messages】

  • 可以用这个来过滤:cat /var/log/messages |grep "invalid value"
    但我这不用过滤,用查看动态的形式来展示吧。
  • 看日志,日志中有详细说明
    • cd /var/log
    • tail -f messages
      简单说明一下:messages是系统日志,启动报错这里会有提示,tail -f 是动态查看的意思
      在这里插入图片描述
  • 然后重新打开一个窗口,重启或启动httpd服务:systemctl restart httpd,然后回到日志窗口看最新日志
    在这里插入图片描述

报错处理【带行号】

  • 这种有说行号的处理就比较简单了
  • 上图中看到 说配置文件中 /etc/httpd/conf/httpd.conf中265行错误,所以,现在打开文件,定位到265行
    在这里插入图片描述
  • 问题定位到了,把265行注释掉,重启试试
    在这里插入图片描述
  • 启动服务:systemctl start httpd, 成功
    在这里插入图片描述
  • 说明一下,我之前以为把配置文件改了重启就会报错,然而发现配置文件不是关键,而是 mod_wsgi 服务,我把mon_wsgi卸载以后重启就报错了,把 mon_wsgi装上以后就重启正常了,这里这么做,只是 测试 如何看日志 以及 如果通过日志 处理报错问题。
    在这里插入图片描述
  • wsgi 正确路径建议指定如下图哦:
    在这里插入图片描述

etcd启动报错【journalctl定位】

  • 报错内容如下:
[root@vms160 ~]# systemctl restart etcd
Job for etcd.service failed because the control process exited with error code. See "systemctl status etcd.service" and "journalctl -xe" for details.
[root@vms160 ~]# 
  • 1
  • 2
  • 3

解决步骤

方式一【journalctl】

  • 启动报错的时候下面会提醒你输入 systemctl status httpd.servicejournalctl -xe查看详细
[root@vms160 ~]# systemctl restart etcd
Job for etcd.service failed because the control process exited with error code. See "systemctl status etcd.service" and "journalctl -xe" for details.
[root@vms160 ~]# 
  • 1
  • 2
  • 3
  • 说明
    • systemctl status httpd.service:既然服务起不来,那么看的这个状态肯定是failed的。
    • journalctl -xe:这是直接查看日志,这里面可能会有关键字
      这个呢,就注意看有没有:invalid value这个开头的关键字,如果有的话,一般后面就是报错内容了
      可以这样:journalctl -xe | grep "invalid value"过滤哦。
      这种更实用于你知道这个配置文件,且知道这行内容是啥的情况。
      如下:
[root@vms160 ~]# journalctl -xe | grep "invalid value"
713 16:44:03 etcd1 bash[2559]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:44:04 etcd1 bash[2570]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:44:04 etcd1 bash[2580]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:44:44 etcd1 bash[2604]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:44:44 etcd1 bash[2615]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:44:45 etcd1 bash[2625]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:44:45 etcd1 bash[2635]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:44:45 etcd1 bash[2646]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:45:35 vms160 bash[2707]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:45:35 vms160 bash[2722]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:45:36 vms160 bash[2733]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:45:36 vms160 bash[2744]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:45:36 vms160 bash[2755]: invalid value "http://localhost:2379,,192.168.59.160:2379" for flag -listen-client-urls: URL scheme must be http, https, unix, or unixs:
713 16:47:21 vms160 bash[2789]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:47:21 vms160 bash[2800]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:47:21 vms160 bash[2811]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:47:22 vms160 bash[2821]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:47:22 vms160 bash[2832]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:48:00 vms160 bash[2862]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:48:00 vms160 bash[2873]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:48:00 vms160 bash[2884]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:48:00 vms160 bash[2895]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:48:01 vms160 bash[2905]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:55:11 vms160 bash[2947]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:55:11 vms160 bash[2957]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:55:12 vms160 bash[2968]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:55:12 vms160 bash[2978]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:55:12 vms160 bash[2989]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:58:07 vms160 bash[3012]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:58:07 vms160 bash[3023]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:58:07 vms160 bash[3034]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:58:07 vms160 bash[3045]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 16:58:08 vms160 bash[3055]: invalid value "http://localhost:2379,192.168.59.160:2379" for flag -listen-client-urls: parse 192.168.59.160:2379: first path segment in URL cannot contain colon
713 17:25:46 vms160 bash[3244]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:25:47 vms160 bash[3254]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:25:47 vms160 bash[3265]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:25:47 vms160 bash[3275]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:25:48 vms160 bash[3286]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:37:00 vms160 bash[3310]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:37:00 vms160 bash[3320]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:37:00 vms160 bash[3330]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:37:01 vms160 bash[3341]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
713 17:37:01 vms160 bash[3352]: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
[root@vms160 ~]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 如上,上面已经告诉我:invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379是这行代码出错了

方式二【messages】

  • 可以用这个来过滤:cat /var/log/messages |grep "invalid value"
    我这就以过滤的形式来展示了
    如下
[root@vms160 log]# systemctl restart etcd
Job for etcd.service failed because the control process exited with error code. See "systemctl status etcd.service" and "journalctl -xe" for details.
[root@vms160 log]#
[root@vms160 log]# pwd
/var/log
[root@vms160 log]# cat  /var/log/messages |grep "invalid value"
Jul 13 17:42:45 vms160 bash: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
Jul 13 17:42:45 vms160 bash: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
Jul 13 17:42:46 vms160 bash: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
Jul 13 17:42:46 vms160 bash: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
Jul 13 17:42:46 vms160 bash: invalid value "http://localhost:2379,http:/192.168.59.160:2379" for flag -listen-client-urls: URL address does not have the form "host:port": http:/192.168.59.160:2379
[root@vms160 log]# 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

报错处理【不带行号】

  • 如上,方式一和方式二其实没区别。都是告诉我了这个内容,像这种不告诉我行号的情况呢,处理方法就是,直接打开配置文件【一般不会告诉你配置文件的,但报错服务的配置文件应该清楚才对,毕竟是修改出错的】,然后搜索报错内容,如下:
    在这里插入图片描述
  • 这样就会定位到报错内容了,然后到这,就应该知道是啥问题了吧?
    如上,我的是缺少一个/所以报错了【故意删的这个/,为了展示错误】
    在这里插入图片描述
  • 我把/加上以后,再次重启服务,正常了【如果继续有报错,继续用上方法查看即可了】
    在这里插入图片描述
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/155315
推荐阅读
相关标签
  

闽ICP备14008679号