【问题标题】:Where is the data directory in Redis?Redis的数据目录在哪里?
【发布时间】:2015-11-23 21:48:47
【问题描述】:

将一些数据写入 redis 服务器后,我可以从客户端读取数据。 但是,如何找到文件系统上的数据目录呢?

【问题讨论】:

  • /var/lib/redis/dump.rdb (Ubuntu)

标签: redis directory server


【解决方案1】:

最快的方法:使用redis-cli。

redis-cli config get dir

如果您配置了身份验证,则需要使用-a password 将“密码”替换为您的密码。

【讨论】:

  • 这对我不起作用,它返回了一个完全错误的目录。我在/usr/local/etc/redis.conf找到了我的配置。
  • 它为您提供了您连接到的实例的配置。如果没有,请提交错误。
  • 此命令将根据 redis.conf 文件或默认配置(如果您没有)而不是配置文件位置返回应用程序目录位置
  • 这会输出两个目录;哪个是正确的?
【解决方案2】:

找到你的 Redis 配置目录,可能是/etc/redis。然后查看名为redis.conf 的配置文件,找到以dir 开头的行。

它看起来类似于:

dir /etc/redis/database

如果你懒得看的话,这会慢慢地完成这项工作:-)

sudo find / -name "redis.conf" -exec grep "^dir" {} \; 2> /dev/null
dir /etc/redis

或者如果你也想要配置文件名:

sudo find / -name "redis.conf" -exec grep -H "^dir" {} \; 2> /dev/null
/private/etc/redis/redis.conf:dir /etc/redis

您可以检查的其他可能性是 Redis 是否以自定义配置文件作为其第一个参数启动,如下所示:

redis-server /path/to.custom/config-file

或在命令行上设置dir 选项,如下所示:

redis-server dir /path/to/data

使用

ps -aef | grep redis

寻找这些选项。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    • 1970-01-01
    • 1970-01-01
    • 2016-08-17
    相关资源
    最近更新 更多