Redis:如何访问Redis日志文件

Redis:如何访问Redis日志文件,redis,Redis,在ubuntu服务器上使用ruby安装Redis,但不知道如何访问其日志文件。教程说应该在这里: /var/log/redis_6379.log 但是甚至找不到/var/文件夹找到它时使用了: sudo tail /var/log/redis/redis-server.log -n 100 因此,如果设置更标准,则应: sudo tail /var/log/redis_6379.log -n 100 这将输出文件的最后100行 日志文件位于您的配置中,您可以通过以下方式访问: redis-

在ubuntu服务器上使用ruby安装Redis,但不知道如何访问其日志文件。教程说应该在这里:

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

找到它时使用了:

sudo tail /var/log/redis/redis-server.log -n 100
因此,如果设置更标准,则应:

sudo tail /var/log/redis_6379.log -n 100
这将输出文件的最后100行

日志文件位于您的配置中,您可以通过以下方式访问:

redis-cli CONFIG GET *
日志文件可能并不总是使用上述方法显示。在这种情况下,请使用

tail -f `less  /etc/redis/redis.conf | grep logfile|cut -d\  -f2`

日志文件将位于配置文件(通常
/etc/redis/redis.conf
)显示的位置:)

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


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

检查错误日志文件,然后使用tail命令:

tail -200f /var/log/redis_6379.log


根据错误文件名..

您还可以登录到redis cli并使用命令查看针对redis的查询

vi /usr/local/etc/redis.conf
查找目录、日志文件

# 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"
因此,日志文件在
/usr/local/var/db/redis/redis\u log
处创建,名称为
redis\u log


您也可以尝试从
redis cli
中执行
MONITOR
命令来查看执行的命令数。

您能找到您的redis使用的配置文件吗?@akonsu否也不是。我可以启动和停止它,使用redis cli访问它,但不知道如何找到配置或日志文件。在redis.io或您系统上的其他任何地方都找不到任何解释它的人?你能运行哪个redis服务器来找出它的安装位置吗?@akonsu用另一种方法找到了它。仍然不知道如何“cd”我的方式,但您也可以使用:
locate*redis*log
快速查找现有安装。如果您刚刚安装了它,您可能需要首先运行
updatedb
,这可能比查看conf:)使用
cat
读取日志文件要慢,如果它太长(在日志文件中经常发生这种情况),这可能是非常糟糕的。使用
less
tail
将是一种安全策略“*”而不是*这是一个已知的术语,但有人可能会发现它很有用:当寻找崩溃/问题的迹象时,Redis日志可能帮不上多大忙…它可能只是显示正常的op然后服务在线消息。因此,请检查webserver(apache?)错误日志、FCGI等处理程序的日志以及syslog中的proc kills或其他警报。还要检查任何跟踪/历史资源使用情况(如Cloudlinux或newrelic图),以便了解未来——例如,搜索引擎优化爬虫加速整个站点(gen all cache)的同时发生的大规模夜间MySQL备份可能会导致破坏、redis出内存、,etcuser是redis,group也是redis无法运行cd/var/log/redis即使更改了
conf
文件并再次运行了redis服务器&做了一些操作,我无法在这个目录下修改日志
/usr/local/var/db/redis/
,目录仍然是空的。你救了我一天。我的用例是启动Redis docker,并从容器内部运行脚本来填充示例数据。但在后台运行docker server并注入数据后,容器就退出了。因此,在完成所有命令后,我添加了Redis CLI监视器,它工作正常。谢谢
# 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"