2017-01-26 128 views
0

我已經從牧場主目錄安裝了MongoDB副本集,並啓動罰款。下一個合乎邏輯的事情是公開主人,以便我可以配置和使用它。我已經看到,我可以使用負載平衡器公開27017 TCP端口,但隨後將輪循,而不是與mongo master有親緣關係。牧場主MongoDB副本集揭露主

Rancher是否有辦法公開主人?

+0

我不能既摸不着頭腦。所有mongodb實例都暴露在專用網絡中,所以我只收集了他們的IP並以'mongodb:// {privateip1}:27017,{privateip2}:27017,{privateip3}:27017morpheus-dev的形式輸入了一個連接字符串「我假設有更好的方法來做到這一點 – CaptEmulation

+0

是的,這不會是理想的,因爲你將在所有這些主機上使用該端口。我認爲最好的辦法是設置HAProxy來做到這一點。 – occasl

回答

0

考慮使用HAProxy的這種按本article,概述了這種方法:

listen mongodb_cluster 
bind 10.0.0.10:27017 
option tcp-check 
# MongoDB Wire Protocol 
tcp-check send-binary 3a000000 # Message Length (58) 
tcp-check send-binary EEEEEEEE # Request ID (random value) 
tcp-check send-binary 00000000 # Response To (nothing) 
tcp-check send-binary d4070000 # OpCode (Query) 
tcp-check send-binary 00000000 # Query Flags 
tcp-check send-binary 61646d696e2e # fullCollectionName (admin.$cmd) 
tcp-check send-binary 24636d6400 # continued 
tcp-check send-binary 00000000 # NumToSkip 
tcp-check send-binary FFFFFFFF # NumToReturn 
# Start of Document 
tcp-check send-binary 13000000 # Document Length (19) 
tcp-check send-binary 10 # Type (Int32) 
tcp-check send-binary 69736d617374657200 # ismaster: 
tcp-check send-binary 01000000 # Value : 1 
tcp-check send-binary 00 # Term 

tcp-check expect binary 69736d61737465720001 #ismaster True 

option tcpka 
option tcplog 
server mongo-node-01 10.0.0.11:27017 check inter 2000 
server mongo-node-02 10.0.0.12:27017 check inter 2000