Location of Redis' temp file for replication?

12,940

Solution 1

Most likely the user running the redis-server process doesn't have access to the working directory.

Check your redis.conf (in most cases /etc/redis.conf) and find the dir setting (search for "The working directory" to find it and the docs for it), make sure that the directory is writeable by the user running redis-server.

Solution 2

Actually the file generated by the master at SYNC time is a normal snapshot file (i.e. rdb file), written at the same location than any other rdb files.

This location is set in the Redis configuration file of the master instance - see the dir and dbfilename parameters.

For instance to generate dumps in /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

Of course, the user Redis is launched for must have proper access rights to this location.

Now, on slave side, the dump file read from the master is copied into a temporary file, whose name is something like temp-%d.%ld.rdb (including a timestamp and pid). The file is created in the working directory, which correspond to the dir parameter in the configuration of the slave instance. So even if RDB is not active on slave side, the dir parameter must be set correctly and point to a directory with suitable access rights.

Share:
12,940
optikfluffel
Author by

optikfluffel

freelancing full-stack coder

Updated on June 09, 2022

Comments

  • optikfluffel
    optikfluffel almost 2 years

    I tried to set up a Master-Slave sync on a debian machine. I always get that error in my logs and I can't figure out where the temp file should be =/

    [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
    

    Hope you guys can help me :)