Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否可以通过 Mongo Java 驱动程序以编程方式确定 Replset 的运行状况。我想知道的是:PRIMARY 在哪里?第二个在 oplog 时间里有多“赶上”?这是可能的吗?做这件事的 API 是什么?
db.command("ismaster").get("primary") :给你当前的主
db.getSisterDB("admin").command("replSetGetStatus").get("members") :它包含所有成员的必要复制详细信息。此命令必须在 admin 数据库上运行
希望能帮助到你。