2017-04-06 1 views
4

grails 3 앱을 라이브 서버에 배포하고 있습니다. mongodb 인스턴스가 복제 모드로 설정되었고 라이브 박스에서 성공적으로 테스트되었습니다. 내가 herehere 지정된대로 replicaSetconnectionString을 사용했다mongodb 복제본에 대해 grails 3을 구성하는 방법

mongo -u uname -authenticationDatabase dbname ip-1.ec2.internal:27017/dbname -p password 

:와 내가 테스트. 그러나 두 경우 모두 호스트 구성이 제공되지 않은 것처럼 동작하므로 기본값은 localhost입니다. 그리고 설정되지 않았으므로 실패합니다.

mongodb { 
      replicaSet = [ "ip-1.ec2.internal", "ip-12.ec2.internal", "ip-3.ec2.internal"] 
      host = "ip-1.ec2.internal" //This works for any of the hosts 
      port = 27017 
      username = "username" 
      password = "password" 
      databaseName = "dbname" 
     } 

나는 최신 버전 사용하고 있습니다 : 여기

grailsVersion=3.2.8 //It was the same for 3.2.5 
gormVersion=6.0.9.RELEASE 
gradleWrapperVersion=3.4.1 //It was the same for 3.0 

을 자신의 버전과 플러그인 목록됩니다 여기에 application.groovy이다

compile 'org.grails.plugins:mongodb:6.1.0' 
compile 'org.grails:grails-datastore-rest-client:6.0.9.RELEASE' 

는 그리고이입니다 내가 만난 오류 :

01:22:26.410 - [localhost-startStop-1] INFO org.mongodb.driver.cluster - No server chosen by 
ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, 
all=[ServerDescription{address=127.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: 
Exception authenticating MongoCredential{mechanism=null, userName='username', source='dbname', password=<hidden>, 
mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 
'Authentication failed.' on server 127.0.0.1:27017. The full response 
is { "ok" : 0.0, "code" : 18, "errmsg" : "Authentication failed." }}}]}. Waiting for 30000 ms before timing out 

지금 옵션이 없어졌습니다. 아무도 도와 주실 수 없습니까? 감사.

+0

이 문서 http://gorm.grails.org/latest/mongodb/manual/index.html#advancedConfig입니다. 그런 식으로 복제본을 지정할 수 있다는 것에 대해서는 아무 것도 보이지 않습니다. 난 당신이 단지 URL 문자열을 설정해야한다고 생각 –

+0

@ JamesKleeh, 그 위대한 일을, 감사합니다. – Godfred

답변

2

James Kleeh가 제안한 connection strings은이 문제를 해결했습니다. 이것은 내가이 example에서 참조를 사용하는 방법입니다

mongodb { 
    url = "mongodb://ip-1.ec2.internal,ip-2.ec2.internal,ip-3.ec2.internal/?replicaSet=hostname-of-mongod-instance" 
    port = 27017 
    ... 
} 
관련 문제