We configured MongoDB replica set in Ubuntu server with two secondary set. When we try to connect to replica set via mongo shell. It is connecting to secondary. We should make sure that it should only connected to Primary set. connection string we tried: mongo 'mongodb://publicIP1:27017,publicIP2:27017,publicIP3:27017/?replcaSet=rs123'
See this doc: https://docs.mongodb.com/manual/core/read-preference/ . The connection string will look like: "mongodb://localhost?readPreference=primary"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.