簡體   English   中英

Redis集群創建無法連接到服務器,出了什么問題?

[英]Redis cluster creating cannot connect to the server, what's wrong?

我在Aliyun上部署了3台不同的服務器,每台服務器運行2個redis實例,端口號為6379和6380。

我試圖用這6個節點構建一個redis集群。(Redis版本3.2.0)。 但它失敗並說“抱歉,無法連接到節點10.161.94.215:6379”(10.161.94.215是我的第一台服務器的LAN IP地址。)

顯然服務器運行得很好,我可以通過redis-cli獲得它。

Gem已安裝。

禁用Requirepass,不需要auth。

沒有ip綁定

也沒有保護模式。

錯誤圖片

有關群集的所有配置選項都已設置好。

這有什么問題?

我想我現在知道為什么。

使用本地主機的IP。

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

我想你是從不同的子網創建集群。 那可能是個問題。

看起來保護模式是redis 3.2中的一個新安全功能。 簡短版本是如果您沒有顯式綁定到IP地址,它將只允許訪問localhost。

如果您只想在單個主機上創建群集,則可能沒問題。 如果您使用多個主機來創建群集,則需要關閉保護模式或顯式綁定到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'正在運行,但如果您這樣做,則無法通過互聯網公開訪問。 使用CONFIG REWRITE使此更改成為永久更改。 2)或者,您可以通過編輯Redis配置文件並將protected mode選項設置為“no”來禁用保護模式,然后重新啟動服務器。 3)如果您手動啟動服務器進行測試,請使用“--protected-mode no”選項重新啟動它。 4)設置綁定地址或驗證密碼。 注意:您只需要執行上述操作之一,服務器就可以開始接受來自外部的連接。

redis-trib.rb的輸出相當簡潔(可能是恰當的)。

sudo nano /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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM