1、简单方式:利用Docker完成Redis主从备份
1、先搭建reids-master实例
docker run -d --name redis-master -p 6379:6379 redis:4.0.9
2、在搭建redis-slave实例
docker run -d --name redis-slave -p 6379:6379 redis:4.0.9 redis-server --slaveof (主)redisIp地址 6379(IP)
#查看容器的ip
docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' redis-slave
3、校验是否搭建成功
# 进入到容器实例
docker exec -it redis-slave redis-cli
# 查看redis的实例信息
info replication
# 结果:
# Replication
role:slave
master_host:172.16.*****
master_port:6379
master_link_status:up
master_last_io_seconds_ago:5
master_sync_in_progress:0
slave_repl_offset:182
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:da0e27f7ed973c272b6beb6c29d66e7ea9137410
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:182
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:57
repl_backlog_histlen:126