二、主从复制
https://blog.csdn.net/qq_38270106/article/details/84026299
-
复制6379的挂载目录文件作为6380的挂载文件
cp -r redis6.0.5 redis6.0.5_slave
-
删除redis6.0.5_slave/data目录下的所有文件
-
查看主服务器6379的容器内的地址
docker inpect redis6
-
将conf/redis.conf文件内容为6379的设置为6380
protected-mode no port 6380 daemonize no logfile "6380.log" dir ./ dbfilename dump-6380.rdb rdbcompression yes rdbchecksum yes save 10 2 appendonly yes appendfsync everysec appendfilename "appendonly-6380.aof" slaveof 172.17.0.2 6379
-
启动6380
docker run --name redis6380 -p 6380:6380 \ -v /data/redis6.0.5_slave/conf/redis.conf:/usr/local/etc/redis/redis.conf \ -v /data/redis6.0.5_slave/data:/data \ -d redis:6.0.5 redis-server /usr/local/etc/redis/redis.conf docker run --name redis6381 -p 6381:6381 \ -v /data/redis6.0.5_slave1/conf/redis.conf:/usr/local/etc/redis/redis.conf \ -v /data/redis6.0.5_slave1/data:/data \ -d redis:6.0.5 redis-server /usr/local/etc/redis/redis.conf
-
进去6380容器内,并打开客户端
docker exec -it redis6380 /bin/bash redis-cli -p 6380
-
查看该服务器的信息
info replication
-
测试主从复制