Mongodb repica set config in a property file

狂风中的少年 提交于 2019-12-11 14:14:16

问题


We have a grails project in production. Grails version is 2.3.4. We are using MongoDB for persistence. Earlier, we had all the config hardcoded inside DataSource.groovy. The client demanded that the config be outside the .war file. So we moved it to a .groovy file. Everything was working fine, including the repicaSet config. Then the client came up with another requirement. Since a groovy file can be used to give any programmable instruction, it can be misused by a person whose job is just to update a property file. So they want all the config in a .properties file.

here is the contents of my .properties file

grails.mongo.host=10.3.253.201
grails.mongo.port=27017
grails.mongo.databaseName=testDb
grails.mongo.username=mongouser
grails.mongo.password=mongouser

Where can I give the details of replicaSet? Thanks in advance.


回答1:


I would like to answer this question in case someone else is facing the same isssue.

grails.mongo.uri=mongodb://10.3.253.201,10.3.253.202,10.3.253.203/test
grails.mongo.host=10.3.253.201
grails.mongo.port=27017
grails.mongo.databaseName=test
grails.mongo.username=mongouser
grails.mongo.password=mongouser

This is the content of my config.properties file and it started working for me.

201 was the primary node and the other two were backup in my cluster.

Regards.



来源:https://stackoverflow.com/questions/49258204/mongodb-repica-set-config-in-a-property-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!