nodejs连mongodb副本集集群出现auth fails的认证失败错误
发布于 1年前 作者 manbusky 1644 次浏览

我的mongodb副本集已经设置好了keyFile,正常启动没有问题。

查看状态是这样的

use admin switched to db admin db.auth(“admin","admin”) 1 replication:PRIMARY> rs.status() { “set” : "replication", “date” : ISODate(“2013-09-26T07:13:19Z”), “myState” : 1, “members” : [ { “_id” : 0, “name” : "192.168.0.123:27000", “health” : 1, “state” : 2, “stateStr” : "SECONDARY", “uptime” : 256, “optime” : Timestamp(1380179182000, 1), “optimeDate” : ISODate(“2013-09-26T07:06:22Z”), “lastHeartbeat” : ISODate(“2013-09-26T07:13:19Z”), “lastHeartbeatRecv” : ISODate(“2013-09-26T07:13:19Z”), “pingMs” : 0, “syncingTo” : “192.168.0.124:27000” }, { “_id” : 1, “name” : "192.168.0.124:27000", “health” : 1, “state” : 1, “stateStr” : "PRIMARY", “uptime” : 256, “optime” : Timestamp(1380179182000, 1), “optimeDate” : ISODate(“2013-09-26T07:06:22Z”), “self” : true }, { “_id” : 2, “name” : "192.168.0.125:27000", “health” : 1, “state” : 2, “stateStr” : "SECONDARY", “uptime” : 256, “optime” : Timestamp(1380179182000, 1), “optimeDate” : ISODate(“2013-09-26T07:06:22Z”), “lastHeartbeat” : ISODate(“2013-09-26T07:13:19Z”), “lastHeartbeatRecv” : ISODate(“2013-09-26T07:13:18Z”), “pingMs” : 0, “syncingTo” : “192.168.0.124:27000” } ], “ok” : 1 } replication:PRIMARY>

这说明副本集启动是没有问题的。

可是我使用如下connection url进行连接老是报错! mongodb://dbo:pwd[[[[[[[[[[[[[[[[[[[[@host1](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1)](/user/host1):27000,host2:27000,host3:27000/mydb?auto_reconnect&poolSize=15&connectTimeoutMS=5000&socketTimeoutMS=5000&replicaSet=replication&slaveOk=true&readPreference=secondaryPreferred

其中host1是192.168.0.124, host2是192.168.0.123, host3是192.168.0.125,

报错如下: { [MongoError: auth fails] name: 'MongoError’, code: 18, ok: 0, errmsg: ‘auth fa ils’ }

1 回复

求解答呀, dbo/pwd是肯定可以访问这三个服务的。

回到顶部