MongoDB replSet error loading set config (BADCONFIG)

Error when initiate replicaset in MongoDB:

“errmsg” : “replSet error loading set config (BADCONFIG)”, “ok” : 0 }

Solution:

1. Stop mongod, delete all local.* files in DBPath, start mongod or delete database local directly in mongo shell:

use local
db.dropDatabase()

2. Reconfigure replica set members:

config = {_id: “repl1″, members:[

{_id: 0, host: ‘192.168.2.1:27017′},

{_id: 1, host: ‘192.168.2.2:27017′}]

}

 

rs.reconfig(config, {force: true})

MongoDB replSet error loading set config (BADCONFIG)