设置:
示例:
主
从站
设置群集的脚本
#!/bin/sh
redis_cli="redis-cli"
ping="ping"
cluster="CLUSTER"
cluster_reset="$cluster RESET"
cluster_reset_hard="$cluster_reset hard"
cluster_meet="$cluster MEET"
cluster_info="$cluster INFO"
cluster_nodes="$cluster NODES"
cat redis-cluster-hosts.txt | sed -e "s/:/ /" | while read ip port
do
echo $ip $port
retval=("$redis_cli -h $ip -p $port $ping")
$retval
echo "CLUSTER RESET"
$redis_cli -h $ip -p $port $cluster_reset
cat redis-cluster-hosts.txt | sed -e "s/:/ /" | while read ip1 port1
do
echo "MEET"
$redis_cli -h $ip -p $port $cluster_meet $ip1 $port1
done
echo "INFO"
$redis_cli -h $ip -p $port $cluster_info
$redis_cli -h $ip -p $port $cluster_nodes
done
echo "Handshake Complete"
## First Time only
## set up the solts
for i in {0..5461}; do redis-cli -h 121.244.255.107 -p 6380 cluster addslots ${i}; done
for i in {5462..10922}; do redis-cli -h 121.244.255.108 -p 6379 cluster addslots ${i}; done
for i in {10922..16383}; do redis-cli -h 121.244.255.109 -p 6379 cluster addslots ${i}; done
大师的状态:群集节点 所有大师
大师1:
NODE-ID-1 121.244.255.107:6380 myself,master - 0 0 0 connected 10922-16383
其他节点,主人或奴隶没什么
奴隶的状态:集群节点
所有奴隶 奴隶1:
NODE-ID-MASTER-3 121.244.255.109:6379 master - 0 1442046644622 0 connected 10922-16383
NODE-ID-MASTER-2 121.244.255.108:6379 master - 0 1442046645627 0 connected 5462-10921
NODE-ID-SLAVE-1 115.114.79.38:6379 slave NODE-ID-MASTER-2 0 1442046646127 3 connected
NODE-ID-SLAVE-2 115.114.79.39:6380 slave NODE-ID-MASTER-2 0 1442046645122 1 connected
NODE-ID-SLAVE-3 115.114.79.41:6379 slave NODE-ID-MASTER-1 0 1442046645122 2 connected
NODE-ID-SLAVE-4 115.114.79.40:6379 myself,slave NODE-ID-MASTER-3 0 0 4 connected
NODE-ID-MASTER-1 121.244.255.107:6380 master - 0 1442046645627 0 connected 0-5461
NODE-ID-SLAVE-5 115.114.79.37:6379 slave NODE-ID-MASTER-3 0 1442046646127 0 connected
有关其他节点,主人和奴隶的所有信息
大师的状态:集群信息
cluster_state:fail
cluster_slots_assigned:5461
cluster_slots_ok:5461
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:1
cluster_size:1
cluster_current_epoch:0
cluster_my_epoch:0
cluster_stats_messages_sent:136176
cluster_stats_messages_received:136176
MASTERS的群集失败
奴隶的状态:集群信息
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:8
cluster_size:3
cluster_current_epoch:4
cluster_my_epoch:0
cluster_stats_messages_sent:298888
cluster_stats_messages_received:298790
群集正在奴隶上运行
如何在SLAVES上出现群集,而不是在MASTERS上。
ON set foo 1
错误即将发生在(error) CLUSTERDOWN The cluster is down
在set foo 1
上出现错误SLAVES(预期)(error) MOVED 12182 121.244.255.109:6379
我在这里缺少什么?
缺少什么?