启动参数
--requirepass 123456
:设置客户端连接redis的认证信息
--masterauth 123456
:设置从节点连接redis的认证信息
一主一从
docker run -d -p 6379:6379 --name redis-server redis:6.2.5 redis-server
docker run -d -p 6378:6379 --name redis-slave redis:6.2.5 redis-server --slaveof 192.168.41.128 6379
docker exec -it redis-server bash
root@2057712d5b24:/data
127.0.0.1:6379> info replication
role:master
connected_slaves:1
slave0:ip=172.17.0.1,port=6379,state=online,offset=844,lag=0
master_failover_state:no-failover
master_replid:a7c3448b15070b13848c48139b99016a67cb5b9e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:844
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:844