踩坑日志--redis集群常见报错与解决

文章目录

  • 前言
  • 一:报错1与解决
      • 1.1:报错内容
      • 1.2:问题解决
  • 二:报错2与解决
      • 2.1:报错描述
      • 2.2:报错解决

前言

一:报错1与解决

1.1:报错内容

  • 踩坑日志--redis集群常见报错与解决_第1张图片

  • Can I set the above configuration? (type 'yes' to accept): yes
    >>> Nodes configuration updated
    >>> Assign a different config epoch to each node
    >>> Sending CLUSTER MEET messages to join the cluster
    Waiting for the cluster to join
    ....................................................................................................................................................................................................................................................^C
    
    

1.2:问题解决

  • 经过排查,发现配置文件中监听的IP地址不可以有127.0.0.1的存在,只能监听各本机的IP地址

  • 经过修改并重启服务后再次创建集群立刻成功

  • [root@localhost opt]# vi /etc/redis/6379.conf 	'//修改配置文件'
    [root@localhost opt]# /etc/init.d/redis_6379 restart	'//重启'
    Stopping ...
    Waiting for Redis to shutdown ...
    Redis stopped
    Starting Redis server...
    [root@localhost opt]# netstat -antp |grep  6379
    tcp        0      0 192.168.233.128:16379   0.0.0.0:*               LISTEN      76973/redis-server  
    tcp        0      0 192.168.233.128:6379    0.0.0.0:*               LISTEN      76973/redis-server  
    [root@localhost opt]# redis-cli --cluster create --cluster-replicas 1 192.168.233.128:6379 192.168.233.129:6379 192.168.233.130:6379 192.168.233.131:6379 192.168.233.132:6379 192.168.233.133:6379	'//重新创建集群'
    
    
  • 踩坑日志--redis集群常见报错与解决_第2张图片

二:报错2与解决

2.1:报错描述

  • 登陆集群节点查看创建的键的时候出现报错:(error) MOVED 9379 192.168.233.129:6379

  • [root@localhost opt]# redis-cli -h 192.168.233.130 -p 6379 192.168.233.130:6379> get cent
    (error) MOVED 9379 192.168.233.129:6379
    
    

2.2:报错解决

  • 通过添加-c参数,解决问题

    -c:连接集群结点时使用,此选项可防止moved和ask异常
    
  • 重新连接查看,问题解决

    [root@localhost opt]# redis-cli -h 192.168.233.130 -p 6379 -c
    192.168.233.130:6379> get cent
    -> Redirected to slot [9379] located at 192.168.233.129:6379
    "7.7"
    
    

你可能感兴趣的:(踩坑日志)