0
config.mongoose = {
  url: 'mongodb://127.0.0.1:27017,127.0.0.1:27018/db?replicaSet=rs0',
  options: {
    mongos: true,
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true,
    useFindAndModify: false,
    autoReconnect: true,
    reconnectTries: Number.MAX_VALUE,
    bufferMaxEntries: 0,
    poolSize: 1000,
  },
};

这种连接方式会报错

复制集的 url 应该怎样书写呢

发表新评论

报的什么错?版本是什么?

[egg-mongoose]connect ECONNREFUSED 127.0.0.1:27017

reason: {“type”:”ReplicaSetNoPrimary”,”setName”:”rs0″,”maxSetVersion”:1,”maxElectionId”:”7fffffff0000000000000002″,”servers”:{},”stale”:false,”compatible”:true,”compatibi
lityError”:null,”logicalSessionTimeoutMinutes”:null,”heartbeatFrequencyMS”:10000,”localThresholdMS”:15,”commonWireVersion”:8}