installing multiple instances of mongodb
This walk through assumes you are running on max os and using homebrew to install mongodb.
1. Open up the terminal and install mongodb with homebrew. Follow the instructions at the end after homebrew completed the mongodb installation.
brew update brew install mongodb
2. If installed correctly, you should be able to shell into the mongo shell by simply type mongo
on the terminal. And here are the executable binaries and config files homebrew has created for mongodb
ls -l /usr/local/Cellar/mongodb/3.0.0/bin ls -l /usr/local/etc/mongo*
3. Now we can start to create multiple mongodb instances by creating multiple mongo config files with different mongodb storage directory, port number and log files. Let’s create a second config file at /usr/local/etc/mongod2.conf
with these configurations. The most important changes are the dbPath and port number. The defalut port is 27017, and we have it here with 27018 or we can have it to be any other port number that is not taken yet. The dbPath let you specify the storage directory so this new mongo instance will not mixed together with other mongo instances.
systemLog: destination: file path: /usr/local/var/log/mongodb/mongo2.log logAppend: true storage: dbPath: /usr/local/var/mongodb2 net: bindIp: 127.0.0.1 port: 27018
4. To start up the second mongo instance, shell into it, show dbs and exit. When you shell into it you have to specpify the port number otherwise it will bring you to the default mongo instance on port 27017. To do anyother adminstrative mongo commands on this new instance such as mongorestore, you will have to specfy the port number as well.
mongod --config /usr/local/etc/mongod2.conf & mongo --port 27018 show dbs; exit;
Search within Codexpedia
Search the entire web