sql >> Database >  >> NoSQL >> MongoDB

Mongoose-verbinding met replicaset

We gebruiken dit:

if(config.db.indexOf('replicaSet') > - 1) {
  dbOptions = {
    db: {native_parser: true},
    replset: {
      auto_reconnect:false,
      poolSize: 10,
      socketOptions: {
        keepAlive: 1000,
        connectTimeoutMS: 30000
      }
    },
    server: {
      poolSize: 5,
      socketOptions: {
        keepAlive: 1000,
        connectTimeoutMS: 30000
      }
    }
  };
}

var db = mongoose.connect(config.db, dbOptions);

waar

config.db =  'mongodb://USER:[email protected]:port1,host2:port2/DBNAME?replicaSet=RSNAME'

Auto_reconnect is uitgeschakeld volgens https://team.goodeggs.com/reconnecting-to-mongodb-when-mongoose-connect-fails-at-startup-83ca8496ca02



  1. Cassandra vs. MongoDB:welke moet je kiezen?

  2. Overzicht van de MongoDB Database Profiler

  3. Mongo DB Java 3.x-stuurprogramma - Groeperen op query

  4. MongoDB $dateToParts