我已经从 Rancher 目录安装了 MongoDB 副本集,并且启动良好。下一个合乎逻辑的事情是公开 master,以便我可以配置和使用它。我已经看到我可以使用负载平衡器公开 27017 TCP 端口,但是这将循环而不是与 mongo 主服务器有关联。
Rancher有没有办法只暴露主人?
根据本文概述了这种方法,请考虑为此使用 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