2014-10-04 56 views
0

對不起,應該因爲不得不問這個問題而被拍攝,但這一天浪費了 - 感覺就像我已經閱讀了所有內容。RabbitMQ - AWS EC2 Clustering hell

我無法在分佈於三個不同區域的EC2實例(3)上創建羣集。主持人:

[email protected] 
[email protected] 
[email protected] 

試圖使羣集前的初始狀態:

[email protected]:~$ sudo rabbitmqctl cluster_status 
Cluster status of node '[email protected]' ... 
[{nodes,[{disc,['[email protected]']}]}, 
{running_nodes,['[email protected]']}, 
{partitions,[]}] 

[email protected]:~$ sudo rabbitmqctl cluster_status 
Cluster status of node '[email protected]' ... 
[{nodes,[{disc,['[email protected]']}]}, 
{running_nodes,['[email protected]']}, 
{partitions,[]}] 

[email protected]:~$ sudo rabbitmqctl cluster_status 
Cluster status of node '[email protected]' ... 
[{nodes,[{disc,['[email protected]']}]}, 
{running_nodes,['[email protected]']}, 
{partitions,[]}] 

當我試圖從一臺服務器檢查狀態另一個:

sudo rabbitmqctl status -n [email protected] 

Status of node '[email protected]' ... 
Error: unable to connect to node '[email protected]': nodedown 
nodes in question: ['[email protected]'] 

hosts, their running nodes and ports: 
- unable to connect to epmd on ip-172-31-1-82: timeout (timed out) 

current node details: 
- node name: '[email protected]' 
- home dir: /var/lib/rabbitmq 
- cookie hash: 0tsf/OyQZI7zobmv1Ia97w== 

所有這三個服務器都相同的erlang cookie哈希。

我可以確認的主機名設置正確:

host ip-172-31-36-111 

ip-172-31-36-111.us-west-2.compute.internal has address 172.31.36.111 

我知道的端口是開放的:

netstat -plten | grep beam 

因爲我打開的所有TCP和UDP在這一點上作爲一個試驗,無更改。

最後這是否會表現不同給出的故障:

sudo rabbitmqctl join_cluster --ram [email protected] 

Clustering node '[email protected]' with '[email protected]' ... 
Error: {cannot_discover_cluster,"The nodes provided are either offline or not running"} 

請幫幫忙,這個驅動瘋狂。

+0

你可以試着用sudo rabbitmq-server -detached啓動一個broker,並且如果從那裏 – silviud 2014-12-05 19:49:14

回答

0

問題是,他們在不同的地區(大概在EC2-經典 - 你沒有提到你是否使用VPC)。這意味着它們不能通過其私有IP進行通信(例如,參見例如Can EC2 instances in different regions communicate over their private IP addresses?

ping 172.31.36.111 例如將從其他服務器之一失敗。使用主機名Ping可能甚至可能在DNS查找中失敗。

的選項有:

  1. 把他們在不同的區域中的一個區域(在EC2經典,它們就能通信)。在這種情況下,您也可以使用VPC,將其放入單獨的子網中,但允許通過適當設置的安全組進行互連。
  2. 在每臺服務器上設置/ etc/hosts以指向相關的public其他服務器的IP(您可以將彈性IP附加到每臺服務器以確保跨服務器重啓時的穩定性)。爲了清晰起見,您還可以設置每臺服務器的主機名。將您的安全組設置爲允許在rabbitmq使用的相關端口上進行訪問。這樣做可能會有安全隱患,因爲數據將通過公共互聯網傳播。
  3. 在羣集中的每臺服務器之間設置一個VPN。亞馬遜VPC有一個VPN設施,但我想可以自己設置它。

我認爲只有選項1最簡單。選項2具有重大的安全影響(我相信有保護集羣服務器之間連接的方法,但據我所知,它們沒有記錄在rabbitmq網站上)。選項3很複雜,但如果您需要多個區域,可能是最好的選擇。

請注意,rabbitmq集羣並不意味着要在廣泛的地理區域運行,因爲它們在網絡分區方面並不太可靠。看到這裏:https://www.rabbitmq.com/clustering.html