使用3组Master-Slave群集模拟一个Cluster模式的群集

来源:互联网 发布:python salesforce 编辑:程序博客网 时间:2024/06/03 14:53

                               使用3组Master-Slave群集模式模拟Redis的Cluster模式群集

补充点很有用的知识:

watch -n 60 'redis-cli -h 192.168.10.11 -p 6379  info |grep total_commands_processed >> qps2.txt && date >> qps2.txt'

Sentinel和Redis身份验证
当一个master配置为需要密码才能连接时,客户端和slave在连接时都需要提供密码。

master通过requirepass设置自身的密码,不提供密码无法连接到这个master。
slave通过masterauth来设置访问master时的密码。

但是当使用了sentinel时,由于一个master可能会变成一个slave,一个slave也可能会变成master,
所以需要同时设置上述两个配置项。

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 config get timeout
1) "timeout"
2) "0"

很早以前redis.conf文件里这个参数值好像是300秒,现在默认值已经改为0啦
默认值timeout=0表示Redis服务端永远不主动关闭客户端空闲超时连接
此处就不要设置超时时间了 选择默认值0就行了。
在redis.conf里如果你设置了timeout参数的值,
那么参数timeout值>0就表示客户端的连接何时被释放(关闭)就由redis服务器来管理了。


安装和启动redis和redis-sentienl服务:yum -y install redissystemctl enable redissystemctl restart redissystemctl enable redis-sentinelsystemctl restart redis-sentinel  注意bind参数绑定自己真实网卡IP地址参数的方式:bind参数只能直接打开/etc/redis.conf配置文件编辑(例如root@contoso11这台机器 bind 192.168.10.11 127.0.0.1,其中192.168.10.11是这台机器真实的IP地址)bind参数不支持这种格式的命令来设置redis-cli -h 192.168.10.14 -p 6379 config set bind "192.168.10.14 127.0.0.1"但支持读bind参数的值,如下:[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 config get bind1) "bind"2) "192.168.10.11 127.0.0.1"[root@contoso12 ~]# redis-cli -h 192.168.10.12 -p 6379 config get bind1) "bind"2) "192.168.10.12 127.0.0.1"[root@contoso13 ~]# redis-cli -h 192.168.10.13 -p 6379 config get bind[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 6379 config get bind[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 6379 config get bind[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 6379 config get bind[root@contoso17 ~]# redis-cli -h 192.168.10.17 -p 6379 config get bind[root@contoso18 ~]# redis-cli -h 192.168.10.18 -p 6379 config get bind[root@contoso19 ~]# redis-cli -h 192.168.10.19 -p 6379 config get bind第一组Master-Slave群集 主节点IP:192.168.10.11 6379                      从节点IP:192.168.10.14 6379                      从节点IP:192.168.10.15 6379                      从节点IP:192.168.10.16 6379[root@contoso11 ~]# 192.168.10.11:6379> slaveof no one    // slaveof参数默认被注释禁用,该指令等价于注释禁用slaveof参数[root@contoso11 ~]# 192.168.10.11:6379> config rewrite    // 将slaveof的修改写入到 redis.conf 中[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 6379 slaveof 192.168.10.11 6379  // 指定从节点的主节点[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 6379 config rewrite              // 将slaveof的修改写入到 redis.conf 中[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 6379 slaveof 192.168.10.11 6379  // 指定从节点的主节点[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 6379 config rewrite              // 将slaveof的修改写入到 redis.conf 中[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 6379 slaveof 192.168.10.11 6379  // 指定从节点的主节点[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 6379 config rewrite              // 将slaveof的修改写入到 redis.conf 中设置第一组中3个Slave谁做新的Master(slave-priority参数值相互比较而言值越小的优先级别越高,优先级别越高的Slave节点将被选举成新的Master)[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 6379 config set slave-priority 99[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 6379 config rewrite[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 6379 config set slave-priority 98[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 6379 config rewrite[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 6379 config set slave-priority 97[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 6379 config rewrite第一种方式:直接编辑配置redis-sentinel文件[root@contoso11 ~]# vi /etc/redis-sentinel.conf        // master-11 that is the master-group-nameport 26379dir "/tmp"sentinel monitor master-11 192.168.10.11 6379 2        // 2表示当有2个Sentinel服务检测到master异常时才会判定其失效,即只有当2个Sentinel都判定Master失效了才会自动迁移,如果Sentinel的数量不达标,则不会执行自动故障迁移。sentinel config-epoch master-11 0            //sentinel down-after-milliseconds master-11 30000    // 30秒master不响应认为它是SDOWN主观下线并且启动failoversentinel leader-epoch master-11 0            //sentinel parallel-syncs master-11 1            // 同时最多有多少个slave更新slaveof参数,建议设置为1,以免影响正常对外提供服务sentinel failover-timeout master-11 180000        // 在3分钟内执行failover故障转移---slave节点切换成master节点# Generated by CONFIG REWRITEsentinel known-slave master-11 192.168.10.14 6379    // 已知的slave节点sentinel known-slave master-11 192.168.10.16 6379    // 已知的slave节点sentinel known-slave master-11 192.168.10.15 6379    // 已知的slave节点sentinel current-epoch 0                //注意:不同的是以下指令会直接改变硬盘配置文件参数的值[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 1[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL SET master-11 quorum  2            // quorum参数的值由1变为2,表示发起failover需要的有多少个sentinel服务同意;[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL SET master-11 parallel-syncs 1            // 默认值为1,执行该指令后你在redis-sentinel.conf文件中无法找到这个参数值;只要参数值不等于1,指令执行效果会出现在配置文件中[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL SET master-11 down-after-milliseconds 30000    // 默认值为30000,执行该指令后你在redis-sentinel.conf文件中无法找到这个参数值    ;只要参数值不等于30000,指令执行效果会出现在配置文件中[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL SET master-11 failover-timeout 180000        // 默认值为180000,执行该指令后你在redis-sentinel.conf文件中无法找到这个参数值;只要参数值不等于180000,指令执行效果会出现在配置文件中删除用来监视Master-Slave群集的Sentinel服务(重新再一次地配置Sentinel服务时使用)[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL REMOVE master-11    // 删除master-group-name,sentinel服务只会剩下以下4个参数值,3个从节点的slaveof参数指定的<master> <ip> <port>不受影响(master-slave群集不受影响)[root@contoso11 ~]# cat /etc/redis-sentinel.conf    //master-11 that is the master-group-nameport 26379logfile "/var/log/redis/sentinel.log"dir "/tmp"sentinel current-epoch 0[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 info Replication        // 只能在master节点上查看,可以证明删除master-group-name后不影响master-slave群集# Replicationrole:masterconnected_slaves:3slave0:ip=192.168.10.14,port=6379,state=online,offset=4055450,lag=1slave1:ip=192.168.10.15,port=6379,state=online,offset=4055450,lag=0slave2:ip=192.168.10.16,port=6379,state=online,offset=4055450,lag=1master_repl_offset:4055450repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:3006875repl_backlog_histlen:1048576[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL failover master-11    // 强制Redis群集做failover失败转移[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL RESET master-11    //第二种方式:直接命令行配置redis-sentinel服务[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL SET master-11 parallel-syncs 1[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL SET master-11 down-after-milliseconds 30000[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL SET master-11 failover-timeout 180000[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL SET master-11 parallel-syncs 1[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL SET master-11 down-after-milliseconds 30000[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL SET master-11 failover-timeout 180000[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 26379 SENTINEL SET master-11 parallel-syncs 1[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 26379 SENTINEL SET master-11 down-after-milliseconds 30000[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 26379 SENTINEL SET master-11 failover-timeout 180000[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 26379 SENTINEL SET master-11 parallel-syncs 1[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 26379 SENTINEL SET master-11 down-after-milliseconds 30000[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 26379 SENTINEL SET master-11 failover-timeout 180000查看master:[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL get-master-addr-by-name master-111) "192.168.10.11"2) "6379"[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 26379 SENTINEL get-master-addr-by-name master-111) "192.168.10.11"2) "6379"[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 26379 SENTINEL get-master-addr-by-name master-111) "192.168.10.11"2) "6379"Testing the failover:查看日志文件记录:tail -f /var/log/redis/redis.logtail -f /var/log/redis/sentinel.log所有节点上都打开监视命令monitor感受群集发生切换时会发送和接收那些命令清空日志文件记录:cat /dev/null > /var/log/redis/redis.logcat /dev/null > /var/log/redis/sentinel.log重新配置先删除这一组master-group-name:[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL REMOVE mymaster[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL REMOVE mymaster[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 26379 SENTINEL REMOVE mymaster[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 26379 SENTINEL REMOVE mymaster最简单的安装指令(Master-Slave 一主三从上都启用redis-sentinel服务):[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 26379 SENTINEL MONITOR master-11 192.168.10.11 6379 2[root@contoso16 ~]# redis-cli -h 192.168.10.16 -p 6379 config get slave-priority // slave-priority值越小的首先切换成主节点,当前值=99[root@contoso15 ~]# redis-cli -h 192.168.10.15 -p 6379 config get slave-priority // slave-priority值越小的首先切换成主节点,当前值=98[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 6379 config get slave-priority // slave-priority值越小的首先切换成主节点,当前值=97测试failover:[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 DEBUG sleep 30 // 参数值设置为30没反应,参数值设置为50会发生主从切换[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 DEBUG SEGFAULT[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 shutdown // 表示把192.168.10.11这台redis关闭[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 info Replication // 查看切换后Master-Slave关系# Replicationrole:slavemaster_host:192.168.10.14master_port:6379master_link_status:upmaster_last_io_seconds_ago:0master_sync_in_progress:0slave_repl_offset:73998slave_priority:100slave_read_only:1connected_slaves:0master_repl_offset:0repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:55023[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 6379 info Replication // 查看切换后Master-Slave关系# Replicationrole:masterconnected_slaves:3slave0:ip=192.168.10.16,port=6379,state=online,offset=123730,lag=1slave1:ip=192.168.10.15,port=6379,state=online,offset=123438,lag=1slave2:ip=192.168.10.11,port=6379,state=online,offset=123584,lag=1master_repl_offset:123876repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:51357repl_backlog_histlen:72520[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 SENTINEL get-master-addr-by-name master-11 // 查看切换后的Master1) "192.168.10.14"2) "6379"[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 config set slave-priority 90[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 config rewrite[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 SENTINEL failover master-11    // 强制Redis群集做failover失败转移使用命令关闭RDB持久化:在客户端执行127.0.0.1:6316> config set save ""[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 config set save ""                //当前可同时同步的slave数最大同步阀值第二组Master-Slave群集 主节点IP:192.168.10.12 6379                      从节点IP:192.168.10.17 6379                      从节点IP:192.168.10.18 6379[root@contoso17 ~]# redis-cli -h 192.168.10.17 -p 6379 slaveof 192.168.10.12 6379[root@contoso17 ~]# redis-cli -h 192.168.10.17 -p 6379 config rewrite    // 将slaveof的修改写入到 redis.conf 中[root@contoso18 ~]# redis-cli -h 192.168.10.18 -p 6379 slaveof 192.168.10.12 6379[root@contoso18 ~]# redis-cli -h 192.168.10.18 -p 6379 config rewrite    // 将slaveof的修改写入到 redis.conf 中第三组Master-Slave群集 主节点IP:192.168.10.13 6379                      从节点IP:192.168.10.19 6379[root@contoso19 ~]# redis-cli -h 192.168.10.19 -p 6379 slaveof 192.168.10.13 6379[root@contoso19 ~]# redis-cli -h 192.168.10.19 -p 6379 config rewrite    // 将slaveof的修改写入到 redis.conf 中                 查看每组Master-Slave模式群集运行信息[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 info[root@contoso12 ~]# redis-cli -h 192.168.10.12 -p 6379 info[root@contoso13 ~]# redis-cli -h 192.168.10.13 -p 6379 info[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 config get bind[root@contoso11 ~]# ps aux|grep redisredis      1132  0.3  0.6 142760  7892 ?        Ssl  Feb04   9:20 /usr/bin/redis-server 192.168.10.11:6379redis      3313  0.4  0.4 142760  5856 ?        Ssl  Feb05   7:05 /usr/bin/redis-sentinel *:26379 [sentinel]root       3994  0.0  0.0 112648   948 pts/0    S+   23:57   0:00 grep --color=auto redis[root@contoso11 ~]#http://redis.io/topics/sentinelhttp://redisdoc.com/topic/sentinel.html允许一次性有几台slave连接新的master(建议一个)sentinel config-epoch mymaster 1sentinel leader-epoch mymaster 0sentinel current-epoch 0[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 info Sentinel# Sentinelsentinel_masters:1sentinel_tilt:0sentinel_running_scripts:0sentinel_scripts_queue_length:0master0:name=master-11,status=ok,address=192.168.10.11:6379,slaves=3,sentinels=1[root@contoso11 ~]#[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 sentinel get-master-addr-by-name master-111) "192.168.10.11"2) "6379"[root@contoso11 ~]#[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 sentinel sentinels master-11(empty list or set)[root@contoso11 ~]#[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 sentinel master master-11[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 26379 sentinel slaves master-11http://www.178linux.com/672[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 info# Serverredis_version:3.0.7                //Redis版本号redis_git_sha1:00000000redis_git_dirty:0redis_build_id:729f6a60eb2ca742redis_mode:standalone                //Redis运行模式os:Linux 3.10.0-327.el7.x86_64 x86_64        //操作系统的版本arch_bits:64                    //操作系统架构是64位multiplexing_api:epollgcc_version:4.8.5                //gcc版本号process_id:1132                    //服务器进程编号pidrun_id:5e952d86b643d0070ed73d04f2c9a3bc50fb875e //Redis随机标示符(用于sentinel和群集)tcp_port:6379                    //Redis服务被监听的端口uptime_in_seconds:17671                //Redis运行时长(单位:秒)uptime_in_days:0                //Redis运行时长(单位:天)hz:10lru_clock:11778202                //以分钟为单位的自增时钟(用于LRU管理)config_file:/etc/redis.conf            //Redis配置文件的绝对路径# Clientsconnected_clients:1                //已连接客户端的数量(不包括通过从属服务器连接的客户数)client_longest_output_list:0            //当前连接的客户端中最长的输出列表client_biggest_input_buf:0            //当前连接的客户端中最长的输入缓存blocked_clients:0                //正在等待阻塞命令(如:BLPOP BRPOP BRPOPLPUSH)的客户端的数量(需要被监控)# Memoryused_memory:1926752                //由Redis分配内存算法分配的内存总量(单位:byte 字节)                used_memory_human:1.84M                //以M兆字节为单位格式化输出Redis占用的内存used_memory_rss:8048640                //从操作系统的角度返回Redis已分配的内存总量(俗称常驻集大小),这个值与top还有ps等命令输出的一致used_memory_peak:1978648            //Redis的内存消耗峰值(单位:字节)used_memory_peak_human:1.89M            //以M兆字节为单位格式化输出Redis的内存消耗峰值used_memory_lua:36864                //LRU引擎所使用的内存大小mem_fragmentation_ratio:4.18            //used_memory_rss:8048640/used_memory:1926752 = 4.18mem_allocator:jemalloc-3.6.0在理想情况下,used_memory_rss的值应该只比used_memory稍微高一点。当used_memory_rss > used_memory,且两者的值相差较大时,表示存在(内部或外部的)内存碎片。内存碎片的比率可以通过mem_fragmentation_ratio的值看出。当used_memory_rss < used_memory时,表示Redis的部分内存被操作系统换出到交换空间了,在这种情况下,操作可能会产生明显的延迟。# Persistenceloading:0                    //记录服务器是否正在载入持久化文件rdb_changes_since_last_save:0            //距离最近一次成功创建持久化文件之后,经过了多少秒rdb_bgsave_in_progress:0            //记录了服务器是否正在创建RDB文件rdb_last_save_time:1454618394            //最近一次成功创建RDB文件的UNIX时间戳rdb_last_bgsave_status:ok            //最近一次创建RDB文件是成功还是失败rdb_last_bgsave_time_sec:1            //最近一次创建RDB文件耗费的秒数rdb_current_bgsave_time_sec:-1            //如果服务器正在创建RDB文件,那么这个域记录的就是当前的创建操作已经耗费的秒数aof_enabled:0                    //AOF是否处于打开状态aof_rewrite_in_progress:0            //服务器是否正在创建AOF文件aof_rewrite_scheduled:0                //RDB文件创建完毕后,是否需要执行预约的AOF重写操作aof_last_rewrite_time_sec:-1            //最近一次创建AOF文件耗费的时长aof_current_rewrite_time_sec:-1            //如果服务器正在创建AOF文件,那么这个域记录的就是当前的创建操作已经耗费的秒数aof_last_bgrewrite_status:ok            //最近一次创建AOF文件是成功还是失败aof_last_write_status:ok# Statstotal_connections_received:4            //服务已接受的连接请求数量total_commands_processed:1267            //服务已执行的命令数量instantaneous_ops_per_sec:2            //服务器每秒种执行的命令数量total_net_input_bytes:45325total_net_output_bytes:1898instantaneous_input_kbps:0.10instantaneous_output_kbps:0.00rejected_connections:0                //因为最大客户端数量限制而被拒绝的连接请求数量sync_full:3sync_partial_ok:0sync_partial_err:0expired_keys:0                    //因为过期而被自动删除的key数量evicted_keys:0                    //因为最大内存容量限制而被驱逐的key数量keyspace_hits:0                    //查找key成功的次数keyspace_misses:0                //查找key失败的次数pubsub_channels:0                //目前被订阅频道的数量pubsub_patterns:0                //目前被订阅模式的数量latest_fork_usec:963                //最近一次fork操作耗费的毫秒数migrate_cached_sockets:0# Replicationrole:master //如果当前服务器没有在复制任何其他服务器,那么这个域的值就是master;否则这个域的值就是slave。注意在创建复制链接的时候,一个从服务器也可能是另外一个服务器的主服务器。connected_slaves:3slave0:ip=192.168.10.14,port=6379,state=online,offset=729,lag=1slave1:ip=192.168.10.15,port=6379,state=online,offset=729,lag=1slave2:ip=192.168.10.16,port=6379,state=online,offset=729,lag=1master_repl_offset:729repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:2repl_backlog_histlen:728# CPUused_cpu_sys:38.31            //Redis服务器耗费的系统CPUused_cpu_user:3.26            //Redis服务器耗费的用户CPUused_cpu_sys_children:0.03        //后台进程耗费的系统CPUused_cpu_user_children:0.00        //后台进程耗费的用户CPU# Clustercluster_enabled:0# Keyspace[root@contoso11 ~]#测试故障转移执行以下命令使得主节点redis服务停止[root@contoso11 ~]# redis-cli -h 192.168.10.11 -p 6379 shutdown //表示把192.168.10.11这台redis服务关闭[root@contoso14 ~]# redis-cli -h 192.168.10.14 -p 26379 info Sentinel //查看新的主节点信息

像上面那样再定义2组Master-Slave群集就定义3组主从群集了 因为Cluster模式至少需要3个主节点 没有从节点群集是可以启动的

只要自己实现的代理客户端实现Redis内置的哈希算法,然后定义Slot区间的对应IP地址配置文件,就能实现比官网更牛的Cluster模式群集



原创粉丝点击