Redis临时文件的位置是否可以复制?

时间:2012-07-31 09:52:19

标签: redis debian replication sync temp

我试图在debian机器上设置主从同步。我总是在日志中得到错误,我无法确定临时文件应该在哪里= /

[9559] 31 Jul 11:48:17 * Connecting to MASTER...
[9559] 31 Jul 11:48:17 * MASTER <-> SLAVE sync started
[9559] 31 Jul 11:48:17 * Non blocking connect for SYNC fired the event.
[9559] 31 Jul 11:48:22 # Opening the temp file needed for MASTER <-> SLAVE synchronization: Permission denied

希望你们能帮助我:)。

2 个答案:

答案 0 :(得分:7)

运行redis-server进程的用户很可能无法访问工作目录。

检查您的redis.conf(大多数情况下为/etc/redis.conf)并找到dir设置(搜索“工作目录”以查找它及其文档),确保该目录可由运行redis-server的用户写入。

答案 1 :(得分:6)

实际上,主控制器在SYNC时生成的文件是一个普通的快照文件(即rdb文件),写在与任何其他rdb文件相同的位置。

此位置在主实例的Redis配置文件中设置 - 请参阅dir和dbfilename参数。

例如,在/data/redis/dump.rdb

中生成转储
# The filename where to dump the DB
dbfilename dump.rdb

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

当然,启动用户Redis必须具有对此位置的适当访问权限。

现在,在从属端,从主服务器读取的转储文件被复制到临时文件中,其名称类似于temp-%d。%ld.rdb(包括时间戳和pid)。该文件在工作目录中创建,该目录对应于从属实例配置中的dir参数。因此,即使RDB在从属端未激活,也必须正确设置dir参数并指向具有适当访问权限的目录。