我在我的nodejs应用程序中使用sails-mongo,我的配置如下所示:
mongoDb: {
adapter: 'sails-mongo',
url: 'mongodb://prod_user:prod_password@router-1-incloud:16888,router-2-incloud:16888/db_name',
auto_reconnect: true,
poolSize: parseInt(process.env.MONGO_POOL_LIMIT) || 10,
w: parseInt(process.env.MONGO_WRITE_CONCERT_INT) || 'majority',
reconnectInterval: 200,
wtimeout: parseInt(process.env.MONGO_WRITE_TIMEOUT_MS) || 2000,
retryMiliSeconds: 200,
numberOfRetries: 3,
readPreference: process.env.MONGO_READ_PREFERENCE || 'primaryPreferred',
socketOptions: {
noDelay: true,
keepAlive: 0,
connectTimeoutMS: parseInt(process.env.MONGO_CONNECT_TIMEOUT_MS) || 2000,
socketTimeoutMS: parseInt(process.env.MONGO_SOCKET_TIMEOUT_MS) || 2000
}
因此,当router-1-incloud:16888
发生故障时,即使重新启动应用程序,驱动程序也不会切换到router-2-incloud:16888
,它始终需要两个路由器都可用,或者它不会建立连接到蒙戈。是否需要调整配置值以便自动切换到任何可用的主机?