我将有一个运行 mongo 复制的 IP 地址列表。我需要自动添加一个节点。如何使用 pymongo 发出状态命令或其他方法来找出哪个 IP 是主要 IP?
谢谢
You should use the ReplicaSetConnetion to connect to your replica set. And according to the documentation for High Availability and PyMongo
By default an instance of ReplicaSetConnection will only send queries to the primary member of the replica set. To use secondaries for queries we have to change the ReadPreference