Mongodb Replica set "Connection URI"

Hi,

What should be the connection URI to connect to replica set through primary?
I’m getting this issue Failed: db.collection: error creating collection db.coleection: error running create command: (NotWritablePrimary) not primary

Services list in my Percona cluster:

  • psmdb-db-rs0
  • psmdb-db-rs0-0
  • psmdb-db-rs0-1
  • psmdb-db-rs0-2
  • psmdb-db-rs0-3
  • psmdb-db-rs0-arbiter-0

Connection string used:
mongodb://$BACKUP-ADMIN:$MONGODB_BACKUP_PASSWORD@psmdb-db-rs0.percona-dbs.svc.cluster.local:27017/database?authSource=admin

1 Like

Hello, that would be something like this:

mongodb://$BACKUP-ADMIN:$MONGODB_BACKUP_PASSWORD@psmdb-db-rs0.percona-dbs.svc.cluster.local:27017,psmdb-db-rs1.percona-dbs.svc.cluster.local:27017/?replicaSet=$REPLSET_NAME

1 Like