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

opt*_*fel 6 replication debian sync temp redis

我试图在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
Run Code Online (Sandbox Code Playgroud)

希望你们能帮助我:)

The*_*heo 7

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

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


Did*_*zia 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
Run Code Online (Sandbox Code Playgroud)

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

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