docker里配了下redis的主从
配置也是很简单,slave似乎重复复制(出错了还在返回重试)
docker-compose
version: '3'
services:
redis-master:
image: redis:3.2.12-alpine
volumes:
- ./master/redis.conf:/usr/local/etc/redis/redis.conf
- ./master/data:/tmp
ports:
- 6455:6455
command: [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
redis-slave:
image: redis:3.2.12-alpine
depends_on:
- redis-master
volumes:
- ./slave/redis.conf:/usr/local/etc/redis/redis.conf
- ./slave/data:/tmp
ports:
- 6458:6458
command: [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
master/redis.conf
bind 0.0.0.0
protected-mode no
port 6455
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /tmp
appendonly yes
appendfilename "data.aof"
slave/redis.conf
bind 0.0.0.0
protected-mode no
port 6458
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 16
save 900 1
save 300 10
save 60 10000
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /tmp
appendonly yes
appendfilename "data.aof"
slaveof redis-master 6455
结果
17:C 26 Jul 08:00:11.973 * DB saved on disk
redis-master_1 | 17:C 26 Jul 08:00:11.974 * RDB: 0 MB of memory used by copy-on-write
redis-master_1 | 1:M 26 Jul 08:00:12.074 * Background saving terminated with success
redis-slave_1 | 1:S 26 Jul 08:00:12.075 * MASTER <-> SLAVE sync: receiving 77 bytes from master
redis-master_1 | 1:M 26 Jul 08:00:12.076 * Synchronization with slave 172.21.0.3:6458 succeeded
redis-slave_1 | 1:S 26 Jul 08:00:12.080 * MASTER <-> SLAVE sync: Flushing old data
redis-slave_1 | 1:S 26 Jul 08:00:12.080 * MASTER <-> SLAVE sync: Loading DB in memory
redis-slave_1 | 1:S 26 Jul 08:00:12.080 # Failed trying to load the MASTER synchronization DB from disk
redis-master_1 | 1:M 26 Jul 08:00:12.081 # Connection with slave 172.21.0.3:6458 lost.
同步失败了,Failed trying to load the MASTER synchronization DB from disk
,然后slave又不断在重试,有人遇到过嘛??
遇到了同样的问题, win10 的docker 下主从失败不停重试, 报
Failed trying to load the MASTER synchronization DB from disk
有趣的是, 当我再开一个slave 并且把rdb 路径设置和slave_1 相同时, 就特么成功了