multiple instances of Mongo DB on same server

The aforementioned answer is not a recommended way to run multiple instances (especially when the servers might be running at the same time) as it will lead to usage of the same config parameters like for example logpath and pidfilepath which in most cases is not what you want.

Please, consider creating dedicated mongod configuration files like mongod-QA.conf and mongod-STAGE.conf. In these files you may want to provide dbpath, logpath folders, bind_ip, port and pidfilepath specific to each mongod instance and that will not affect each other.

After these steps you are good to trigger two instances as follows

mongod --config <path-to>/mongod-QA.conf
mongod --config <path-to>/mongod-STAGE.conf

You can find more details on mongodb docs page


You just need to create another folder(ex: mongodb2) dbpath for the second instance, and run it in a different port(ex: 27018)

 mongod --dbpath /usr/local/var/mongodb2 --port 27018