copy redis data from server A to server B
739 ワード
First, create a dump on server A.
This will ensure/var/lib/redis/dump.rdb is completely up-to-date. (This file is periodically written by Redis anyway.)
Next, copy it to server B:
Stop the Redis server on B, copy dump.rdb (ensuring permissions are the same as before), then start.
The version of Redis on B must be greater or equal than that of A, or you may hit compatibility issues.
A$ redis-cli
127.0.0.1:6379> SAVE
OK
This will ensure/var/lib/redis/dump.rdb is completely up-to-date. (This file is periodically written by Redis anyway.)
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.