I have the following redis sentinel setup: http://redis.io/topics/sentinel#example-2-basic-setup-with-three-boxes
The problem is that every time I start the redis servers and the sentinels, neither one of the servers gets set as master. Out of the 3 boxes, box 1 should be the master.
This is the config file for the master server:
daemonize yes
pidfile /var/run/redis/master/redis_master.pid
port 6379
slaveof no one
timeout 0
tcp-keepalive 0
loglevel notice
syslog-enabled yes
syslog-ident redis-master
syslog-facility local0
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
dbfilename dump-master.rdb
dir /var/lib/redis
slave-serve-stale-data yes
repl-ping-slave-period 10
repl-timeout 60
maxclients 10000
appendonly no
appendfilename appendonly-master.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 1024
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
The original config for the master that I've been using, did not have the slaveof line at all. I've added "slaveof no on" in an attempt to explore alternatives, but this hasn't worked either.
The slaves use the exact same config as the master. The only difference is the slaveof line, which in the case of slaves looks like this:
slaveof master_ip master_port
Whereas master_ip and master_port are the actual ip and port of the master.
When I start the master with the above mentioned config, I run redis-cli and check the replication details with the "info" command:
# Replication
role:slave
master_host:no
master_port:0
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_in_progress:0
slave_repl_offset:1
master_link_down_since_seconds:1438348112
slave_priority:100
slave_read_only:1
connected_slaves:0
This is what it looks like after I've started the master server. If I enter the same command that's in the config, "slaveof no on", the replication details show the following:
# Replication
role:master
connected_slaves:2
slave0:ip=10.208.88.84,port=6379,state=online,offset=501,lag=0
slave2:ip=10.208.91.86,port=6379,state=online,offset=501,lag=1
master_repl_offset:501
Which is exactly how it should look at startup as well.
The main issue is the fact that if the master were to fail, the sentinels would switch to one of the slaves as a new master, but when the original master comes back up, it would be a slave connected to no master, and would become useless.