How to Re-intialize MongoDB in Openstack

Following is the procedure to re-initialize MongoDB in OpenStack

1. Stop mongod on all the nodes (if it is running). If service is in fail state then leave it as is
2. Remove all the files in /var/lib/mongod. If you are moving the mongodb directory and making new one make sure to run restorecon command     # mv /var/lib/mongodb /var/lib/mongodb-old      # mkdir /var/lib/mongodb     # chown mongodb.mongodb /var/lib/mongodb     # restorecon /var/lib/mongodb
3. start the mongodb on first controller
4. Get the mongo service ip from ceilometer.conf file     # cat /etc/ceilometer/ceilometer.conf | grep mongo     connection=mongodb://x.y.z.a:27017,x.y.z.b:27017,x.y.z.c:27017/ceilometer?replicaSet=tripleo
5. login to the mongodb     # mongo x.y.z.a
6. Intiate the replicaset     > rs.initiate()
7. Make the current node as master     >rs.isMaster(“x.y.z.a”)
8. Start the mongodb on other two controllers
9. Add other two nodes as members from first controller     >rs.add(“x.y.z.b”)     &…