阿里云上使用redis集群的一些问题

Cannot assign requested address

当在redis.conf中配置bind 阿里云公网IP,启动时就出现了下面的问题

annot assign requested address

redis.conf中的bind表示的是指定本机可以接受连接的网卡地址,即使用该IP来接受外部的连接。将其改回bind 阿里云私网IP就可以解决问题。

Could not get a resource from the pool

在redis集群搭建完成功运行之后,使用jedisCluster进行连接redis集群时就出现了下面的问题

Could not get a resource from the pool

    通过调试发现,HostAndPort中的节点IP都是阿里云私网IP地址,这是因为在上一个问题中,我们将redis bind在阿里云私网IP地址上了。进一步调试发现,HostAndPort的信息是通过命令cluster nodes获取的,其访问的节点信息来源于nodes-xxx.conf配置文件。修改配置文件中的IP为阿里云公网IP地址即可。
nodes配置文件.png

该配置文件是redis cluster集群启动后生成的,不是redis实例中的配置文件。

cluster配置文件.png