2017-01-26 175 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