如何访问Redis日志文件

Chr*_*fer 46 redis

在ubuntu服务器上使用ruby设置Redis,但无法弄清楚如何访问其日志文件.教程说它应该在这里:

/var/log/redis_6379.log
Run Code Online (Sandbox Code Playgroud)

但是甚至找不到/ var /文件夹

Chr*_*fer 53

找到它:

sudo tail /var/log/redis/redis-server.log -n 100
Run Code Online (Sandbox Code Playgroud)

因此,如果设置更标准应该是:

sudo tail /var/log/redis_6379.log -n 100
Run Code Online (Sandbox Code Playgroud)

这将输出文件的最后100行.

您的日志文件所在的位置在您可以访问的配置中:

redis-cli CONFIG GET *
Run Code Online (Sandbox Code Playgroud)

使用上述内容可能无法始终显示日志文件.在那种情况下使用

tail -f `less  /etc/redis/redis.conf | grep logfile|cut -d\  -f2`
Run Code Online (Sandbox Code Playgroud)

  • 使用`cat`来读取日志文件可能会非常糟糕,如果它太长(在日志文件中发生很多).使用`less`或`tail`会更安全 (6认同)
  • 这是众所周知的,但是有人可能会发现它很有用:当寻找崩溃/问题的迹象时,Redis日志可能没什么帮助......它可能只显示正常操作然后服务在线消息.因此,请检查Web服务器(apache?)错误日志,FCGI等处理程序的日志,以及proc杀死或其他警报的syslog中的日志.还要检查任何跟踪/历史资源使用情况(如Cloudlinux或newrelic图表),以便了解未来 - 例如,一个大规模的夜间MySQL备份同时发生在加速整个站点的SEO爬虫(gen all cache)导致破坏,重新发送内存等 (3认同)
  • 使用 '*' 而不是 * 因为 * 会被终端解释 (2认同)

bli*_*mer 14

您还可以登录redis-cli并使用MONITOR命令查看针对Redis的查询.


Kan*_*mar 12

vi /usr/local/etc/redis.conf
Run Code Online (Sandbox Code Playgroud)

查找目录,日志文件

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /usr/local/var/db/redis/



# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null 
logfile "redis_log"
Run Code Online (Sandbox Code Playgroud)

所以日志文件是/usr/local/var/db/redis/redis_log用名字创建的redis_log

您还可以尝试MONITOR命令 fromredis-cli查看执行的命令数。


gla*_*ain 9

日志文件将是配置文件(通常/etc/redis/redis.conf)所说的位置:)

默认情况下,logfile stdout这可能不是您要找的.如果redis正在运行daemonized,则该日志配置意味着将发送日志/dev/null,即丢弃.

摘要:logfile /path/to/my/log/file.log在您的配置中设置,redis日志将写入该文件.


Ham*_*ost 7

我推荐你使用redis-cli监控工具。简单输入以下命令:

redis-cli monitor
Run Code Online (Sandbox Code Playgroud)

它为您提供实时访问日志,帮助您解决问题并...