找回密码
 立即注册
  • QQ空间
  • 回复
  • 收藏

linux经验-日志

admin 2019-7-10 05:20 137人围观 Linux相关

linux经验-日志

可以通过日志查看进程错误


如service redis-server start启动不了,提示:

See "systemctl status redis-server.service" and "journalctl -xe" for details.

然后journalctl -xe查看

  1. redis-server.service -Advanced key-value store

  2. Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)

  3. Active: activating (start) since Tue2019-07-0921:33:32 CST;1min6s ago

  4. Docs: http://redis.io/documentation,

  5. man:redis-server(1)

  6. Process:24277ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)

  7. Process:24288ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS)

  8. Main PID:24239(code=exited, status=0/SUCCESS)

  9. Tasks:0(limit:4915)

  10. CGroup:/system.slice/redis-server.service


  11. Jul0921:33:32 iZwz9d7j6n9linrz2e3fq8Z systemd[1]:StartingAdvanced key-value store...

  12. Jul0921:33:32 iZwz9d7j6n9linrz2e3fq8Z systemd[1]: redis-server.service:Can't open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file

这上面的信息咋一看,还以为是进程文件占用,或者权限不够之类的。最后各种尝试也没解决,浪费大半天时间。

后面在网上查找资料,看到一提示,查看redis日志, less/var/log/redis/redis-server.log

  1. 24283:M 09Jul21:32:01.721# Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

  2. 24288:C 09Jul21:33:32.184# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

  3. 24288:C 09Jul21:33:32.184# Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=24288, just started

  4. 24288:C 09Jul21:33:32.184# Configuration loaded

  5. 24289:M 09Jul21:33:32.185# Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

  6. 24297:C 09Jul21:35:02.696# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

  7. 24297:C 09Jul21:35:02.696# Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=24297, just started

  8. 24297:C 09Jul21:35:02.696# Configuration loaded

  9. 24298:M 09Jul21:35:02.697# Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

  10. 24304:C 09Jul21:36:33.176# oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

  11. 24304:C 09Jul21:36:33.176# Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=24304, just started

  12. 24304:C 09Jul21:36:33.176# Configuration loaded

  13. 24305:M 09Jul21:36:33.177# Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address

这些信息才比较清晰,可能是因为ubuntu18版本ip绑定的问题

最后通过编辑redis.conf得以解决

  1. #bind 127.0.0.1 ::1

  2. bind 0.0.0.0

不管是mysql,redis等服务,还是java等应用,日志是很重要的线索,通过日志可以找到错误的源头,所以开发过程流程捕捉错误,记录到日志中去。


----------------------------------------------------------------------------------------------------------------------
我们尊重原创,也注重分享,文章来源于微信公众号:罗汉果技术栈,建议关注公众号查看原文。如若侵权请联系qter@qter.org。
----------------------------------------------------------------------------------------------------------------------

鲜花

握手

雷人

路过

鸡蛋

yafeilinux和他的朋友们微信公众号二维码

微信公众号

专注于Qt嵌入式Linux开发等。扫一扫立即关注。

Qt开源社区官方QQ群二维码

QQ交流群

欢迎加入QQ群大家庭,一起讨论学习!

我有话说......