redis集群常见报错与解决

本文介绍了在配置和使用Redis集群时遇到的两个常见问题。第一个问题是创建集群时一直等待,解决方法是检查并修改配置文件,确保监听的是本机IP而非127.0.0.1。第二个问题是在查看集群键时遇到MOVED错误,通过添加-c参数解决了跨节点重定向的问题。

报错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.经过排查,发现配置文件中监听的IP地址不可以有127.0.0.1的存在,只能监听各本机的IP地址

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

[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	'//重新创建集群'

问题解决

报错2内容
报错描述
登陆集群节点查看创建的键的时候出现报错:(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

报错解决
通过添加-c参数,解决问题
重新连接查看,问题解决

[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"

问题解决

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值