bashredisredis-clusterredis-server

redis cluster only using 2 nodes instead of 4


I try to setup a redis cluster on 4 nodes, each with a different ip and port.

nohup ${install_dir}/redis-stable/src/redis-server ${install_dir}/${port}/node.conf &
let "port++"

for i in $ipb $ipc $ipd; do 
 ssh -i ~/.ssh/"ssh key" "sshid"@${i} /bin/bash << EOF
 nohup ${install_dir}/redis-stable/src/redis-server ${install_dir}/${port}/node.conf &
EOF
 let "port++"
done

# setup the cluster 
$install_dir/redis-stable/src/redis-cli --cluster create $ipa:7001 $ipb:7002 $ipc:7003 $ipd:7004 --cluster-replicas 0

The "text" are here for anonymity but ssh is working fine. The problem is that the cluster only starts on node 2 (ipb), with a 2-node cluster: ipa and ipb. On ipc and ipd, the redis-server process is not even started. If I shutdown the current cluster, it will then start a 2-node cluster with ipa and ipc, then if I shutdown again it will create a 2-node cluster with ipd and ipa. then finally if I shut this one down it closes. I want the cluster to start immediately with all 4 nodes and not 2, what should I fix to get this please? the replica 0 is on purpose, I do not need replica slaves for this. Node.conf files contain the correct port, cluster-enabled yes etc exactly like in the redis official page cluster tutorial. The for loop seems to be the issue but I've used the exact same with another command inside the EOF and it worked perfectly fine. I would like to avoid the add node then reshard technique as much as possible, but if there is no other choice... Thank you for your help, feel free to indicate if you need more info. I apologize if my mistake is not redis-related but caused by my poor level in bash.

EDIT: I see I'm getting almost 60 views yet no answer, what can I do to make my question better for you guys? or is it that stupid?


Solution

  • nohup ${install_dir}/redis-stable/src/redis-server ${install_dir}/${port}/node.conf >${port}.out 2>${port}.err < /dev/null &
    

    redirecting input output and error solver the issue.