我已经从Rancher目录中安装了MongoDB Replica集,并且启动正常。下一个合乎逻辑的事情是暴露主服务器,以便我可以配置和使用它。我已经看到我可以使用负载均衡器暴露27017 TCP端口但是那将循环而不是与mongo主机具有亲和力。
牧羊人有没有办法只揭露主人?
答案 0 :(得分:0)
根据概述此方法的article,考虑使用HAProxy:
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