How to recover redis data from snapshot(rdb file) copied from another machine?

前端 未结 7 1698

I transferred my redis snapshot (dump.rdb file) using scp to a remote server. I need to run a redis server on this remote and recover the data from the

7条回答
  •  旧巷少年郎
    2021-01-30 04:35

    start redis on your second server, like so:

    $ > redis-server /path/to/my/redis/configuration/file/redis.conf
    

    when redis starts, it will find your rdb file because it will look for the name and file path in the configuration file (redis.conf) that you supply when start the redis server, as above.

    to supply the file name and path, just edit two lines in the redis.conf file template (supplied in the root directory of the redis source. Save your revised version as redis.conf in the directory location that you supplied upon starting the server.

    You will find the settings you need in the redis.conf template in the source top-level directory, at lines 127 and 137 (redis version 2.6.9).

    # The filename where to dump the DB
    dbfilename dump.rdb
    
    # The working directory
    dir ./
    

    as you can see, defaults are provided for both settings

    so just change the first of these two lines (127) to identify your rdb file and in the second (137) substitute the default "./" for the actual file path for your snapshot rdb file; save the redis.conf with your changes, and start redis passing in this new conf file.

提交回复
热议问题