一、问题简述

  1. 最近在修复Redis环境漏洞过程中,修改了其中一台linux主机上的两个Redis结点的配置文件,导致后续结点重启失败。

二、部署方式

  1. 使用三台不同的linux主机来完成Redis6个结点的部署(三主三从)。
  2. 由下图所示
hostportnodeType
111.229.96.1627000/7001master/slaver
111.229.96.1637002/7003slaver/slaver
111.229.96.1647004/7005master/master
  1. 结点类型可通过如下命令查看
#redis连接   -c:以集群的方式连接 -h:主机ip地址 -p:ip端口
#错误演示 
[ml@inmshgis13 src]$ ./redis-cli -h 111.229.96.164 -p 7005
111.229.96.164:7005> get name
(error) MOVED 5798 111.229.96.164:7005
// 最好是加上-c
[ml@inmshgis13 src]$ ./redis-cli -c -h 111.229.96.164 -p 7005
111.229.96.164:7005> info replication
# Replication
role:slave
master_host:111.229.96.164
master_port:7005
master_link_status:up
master_last_io_seconds_ago:0
master_sync_in_progress:0
slave_repl_offset:2728687610
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:33049affb1e8c1cc3cc54e0250532a94c921e78e
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:2728687610
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2727639035
repl_backlog_histlen:1048576

三、启动步骤
/gis/redis/redis/redis_cluster/7000

  1. 分别启动三台linux主机上的redis结点
[ml@inmshgis13 ~]$ cd /gis/redis/redis/src
[ml@inmshgis13 src]$ ./redis-server /gis/redis/redis/redis_cluster/7000/redis.conf
[ml@inmshgis13 src]$ ./redis-server /gis/redis/redis/redis_cluster/7001/redis.conf
...
  1. 生成集群
[ml@inmshgis13 src]$ ./redis-trib.rb create --replicas 1 111.229.96.162:7000 111.229.96.162:7001 111.229.96.163:7002 111.229.96.163:7003 111.229.96.164:7004 111.229.96.164:7005
  1. 查看集群状态
111.229.96.164:7005> cluster info
cluster_state:ok  //集群启动成功标志 失败为fail
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:14
cluster_my_epoch:5
cluster_stats_messages_ping_sent:87052
cluster_stats_messages_pong_sent:83735
cluster_stats_messages_sent:170787
cluster_stats_messages_ping_received:83735
cluster_stats_messages_pong_received:87052
cluster_stats_messages_received:170787
Logo

更多推荐