master-slave replication
redis save 备份 恢复
root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt
redis-cli save
cp /var/lib/redis/dump.rdb /var/lib/redis/BEFOREdump.rdb
redis-cli flushall
./redis-server stop
cp /var/lib/redis/BEFOREdump.rdb /var/lib/redis/dump.rdb
root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt -rw-r--r-- 1 redis redis 18 May 5 07:36 /var/lib/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:59 /etc/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:55 /etc/init.d/dump.rdb -rw-rw-r-- 1 wuser wuser 18 May 4 23:58 /home/wuser/dump.rdb -rw-r--r-- 1 root root 18 May 4 23:54 /dump.rdb root@ubuntu:/etc/init.d# redis-cli 127.0.0.1:6379> keys (error) ERR wrong number of arguments for 'keys' command 127.0.0.1:6379> keys * (empty list or set) 127.0.0.1:6379> set w2 3211 OK 127.0.0.1:6379> set w2d 3211 OK 127.0.0.1:6379> save OK 127.0.0.1:6379> exit root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt -rw-r--r-- 1 redis redis 35 May 5 07:37 /var/lib/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:59 /etc/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:55 /etc/init.d/dump.rdb -rw-rw-r-- 1 wuser wuser 18 May 4 23:58 /home/wuser/dump.rdb -rw-r--r-- 1 root root 18 May 4 23:54 /dump.rdb root@ubuntu:/etc/init.d# cp /var/lib/redis/dump.rdb /var/lib/redis/BEFOREdump.rdb root@ubuntu:/etc/init.d# redis-cli 127.0.0.1:6379> KEYS * 1) "w2d" 2) "w2" 127.0.0.1:6379> flushall OK 127.0.0.1:6379> exit root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt -rw-r--r-- 1 redis redis 18 May 5 07:38 /var/lib/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:59 /etc/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:55 /etc/init.d/dump.rdb -rw-rw-r-- 1 wuser wuser 18 May 4 23:58 /home/wuser/dump.rdb -rw-r--r-- 1 root root 18 May 4 23:54 /dump.rdb root@ubuntu:/etc/init.d# redis-cli 127.0.0.1:6379> keys * (empty list or set) 127.0.0.1:6379> exit root@ubuntu:/etc/init.d# ./redis-server stop [ ok ] Stopping redis-server (via systemctl): redis-server.service. root@ubuntu:/etc/init.d# cp /var/lib/redis/BEFOREdump.rdb /var/lib/redis/dump.rdb root@ubuntu:/etc/init.d# ./redis-server start [ ok ] Starting redis-server (via systemctl): redis-server.service. root@ubuntu:/etc/init.d# redis-cli 127.0.0.1:6379> keys * 1) "w2" 2) "w2d" 127.0.0.1:6379> exit root@ubuntu:/etc/init.d# find / -name dump.rdb |xargs ls -alt -rw-r--r-- 1 redis redis 35 May 5 07:40 /var/lib/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:59 /etc/redis/dump.rdb -rw-r--r-- 1 root root 18 May 5 06:55 /etc/init.d/dump.rdb -rw-rw-r-- 1 wuser wuser 18 May 4 23:58 /home/wuser/dump.rdb -rw-r--r-- 1 root root 18 May 4 23:54 /dump.rdb root@ubuntu:/etc/init.d#
w
https://redis.io/topics/replication