我在 Jelastic 上有一个环境,他们的支持无法提供帮助:P
我使用 java 8 和 MongoDB 2.6.4 设置了 Tomcat 7.0.55 对于 mongo,我还设置了一个外部 ip,以便我可以从本地 tomcat 访问。
这里发生了什么,我能够运行我的本地 Tomcat 和 Jelastic 远程 Mongo DB 但是部署后,我从远程 mongo 获取此日志
2015-01-07T22:57:29.637+0000 [conn22208] authenticate db: easylend {authenticate: 1, user: "cre8tech", nonce: "xxx", key: "xxx" }
2015-01-07T22:57:29.638+0000 [conn22208] Failed to authenticate cre8tech@easylend with mechanism MONGODB-CR: AuthenticationFailed keymismatch
我 1000% 确定凭证是正确的,因此该方法用于记录,因为我可以在本地使用它到他们的远程 mongo + 我可以通过使用来访问它
mongo XXXX.whelastic.net/{myDbName} --username {username} --password {password}
@Bean
@Override
public Mongo mongo() throws Exception {
ServerAddress serverAdress = new ServerAddress(host, Integer.parseInt(port));
Mongo mongo = null;
if (usr != null && !usr.isEmpty()) {
MongoCredential credential = MongoCredential.createMongoCRCredential(usr, database, pwd.toCharArray());
mongo = new MongoClient(serverAdress, Arrays.asList(credential));
} else {
mongo = new MongoClient(serverAdress);
}
mongo.setWriteConcern(WriteConcern.SAFE);
return mongo;
}
登录tomcat只是说不能认证
com.mongodb.CommandFailureException: { "serverUsed" : "********" , "code" : 18 , "ok" : 0.0 , "errmsg" : "auth fails"}
我的理论是远程 Jelastic tomcat 可能包含一些干扰我使用的 mongo 驱动程序的 jar/libs
感谢您的帮助