Created
October 16, 2018 11:57
-
-
Save davalapar/8c3c06e21b7ad6ec5d21a0dbd1e11331 to your computer and use it in GitHub Desktop.
dump.rdb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/6004915/how-do-i-move-a-redis-database-from-one-server-to-another | |
Save a spanshot of the database into a dump.rdb by either running BGSAVE or SAVE from the command line. This will create a file named dump.rdb in the same folder as your redis server. See a list of all server commands. | |
Copy this dump.rdb to the other redis server you want to migrate to. When redis starts up, it looks for this file to initialize the database from | |
--- | |
First, create a dump on server A. | |
A$ redis-cli | |
127.0.0.1:6379> CONFIG GET dir | |
1) "dir" | |
2) "/var/lib/redis/" | |
127.0.0.1:6379> SAVE | |
OK | |
This ensures dump.rdb is completely up-to-date, and shows us where it is stored (/var/lib/redis/dump.rdb in this case). dump.rdb is also periodically written to disk automatically. | |
Next, copy it to server B: | |
A$ scp /var/lib/redis/dump.rdb myuser@B:/tmp/dump.rdb | |
Stop the Redis server on B, copy dump.rdb (ensuring permissions are the same as before), then start. | |
B$ sudo service redis-server stop | |
B$ sudo cp /tmp/dump.rdb /var/lib/redis/dump.rdb | |
B$ sudo chown redis: /var/lib/redis/dump.rdb | |
B$ sudo service redis-server start | |
The version of Redis on B must be greater or equal than that of A, or you may hit compatibility issues. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
better master-slave approach: https://redis4you.com/articles.php?id=005&name=Seamless+migration+from+one+Redis+server+to+another