I am running MongoDb before on Windows and my Java app was connecting perfectly. Now I switch the MongoDb to Linux, and started simply as “./mongod”. But whenever I try to connect to Mongo, I got the following exception.
Caused by: com.mongodb.MongoException: can't find a master
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:434)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:209)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
at com.mongodb.DBCollection.findOne(DBCollection.java:647)
at com.mongodb.DBCollection.findOne(DBCollection.java:626)
at com.mongodb.DBApiLayer$MyCollection.createIndex(DBApiLayer.java:364)
at com.mongodb.DBCollection.createIndex(DBCollection.java:436)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:515)
at com.google.code.morphia.DatastoreImpl.ensureIndex(DatastoreImpl.java:245)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:310)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:279)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:340)
at com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:333)
Sounds like your configs are different between linux and windows mongo servers. Ensure your linux server has joined the replica set properly , and is not firewalled off from the other servers. All the documentation is here: http://www.mongodb.org/display/DOCS/Replica+Sets