2016-05-14 691 views
1

我在阿里云上部署了3个不同的服务器,每个服务器都运行2个端口为6379和6380的redis实例。Redis集群创建无法连接到服务器,出了什么问题?

我试图用这6个节点构建一个redis集群(Redis版本3.2.0)。但它失败了,并说:“对不起,无法连接到节点10.161.94.215:6379”(10.161.94.215是我的第一台服务器的lan ip地址。)

显然,服务器运行得很好,而且我可以通过redis-cli获取它。

宝石已安装。

Requirepass被禁止,不需要授权。

没有ip绑定

没有保护模式。

error pic

所有有关群集的配置选项以及设置。

这是怎么回事?

回答

0

我想我现在知道为什么。

使用本地主机的IP。

src/redis-trib.rb create 127.0.0.1:6379 127.0.0.1:6380 h2:p1 h2:p2 h3:p1 h3:p2 
0

我想你是从一个不同的子网创建群集。这可能是一个问题。

0

看起来像保护模式是redis 3.2中的一项新的安全功能。短版本是如果你没有明确地绑定到一个IP地址,它将只允许访问本地主机。

如果您只希望在单个主机上创建群集,则可能是好的。如果您使用多台主机创建集群,则需要关闭保护模式或显式绑定到一个IP地址。

从redis.conf文件:

# Protected mode is a layer of security protection, in order to avoid that 
# Redis instances left open on the internet are accessed and exploited. 
# 
# When protected mode is on and if: 
# 
# 1) The server is not binding explicitly to a set of addresses using the 
# "bind" directive. 
# 2) No password is configured. 

# The server only accepts connections from clients connecting from the 
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain 
# sockets. 
# 
# By default protected mode is enabled. You should disable it only if 
# you are sure you want clients from other hosts to connect to Redis 
# even if no authentication is configured, nor a specific set of interfaces 
# are explicitly listed using the "bind" directive. 
protected-mode yes 

有关于如何纠正这个,如果你试图使用的东西除了回环接口连接到它的指令:

DENIED Redis的运行在保护模式下,因为启用了保护模式,没有指定绑定地址,所以不向客户端请求认证密码。在这种模式下,连接只能从回送接口接受。如果要从外部计算机连接到Redis,您可以采用以下解决方案之一:1)只需禁用保护模式,即可通过从同一主机连接到Redis,从回送接口发送命令'CONFIG SET protected-mode no'正在运行,但如果你这样做,MAKE SURE Redis不能从互联网公开访问。使用CONFIG REWRITE使此更改永久生效。 2)或者,您可以通过编辑Redis配置文件并将保护模式选项设置为'no'来禁用保护模式,然后重新启动服务器。 3)如果您只是为了测试而手动启动服务器,请使用' - 保护模式否'选项重启它。 4)设置绑定地址或认证密码。注意:您只需执行上述任一操作即可让服务器开始接受来自外部的连接。

redis-trib.rb的输出非常简洁(可能适当)。

0

须藤纳米/etc/redis/6379.conf

Replace #bind 127.0.0.1 or bind 127.0.0.1 with bind 0.0.0.0 

sudo service redis_6379 restart 

允许访问Redis的任何地方。