On a developer machine you might have to install multiple versions of MongoDB or you might want to run multiple MongoDB server instances. Both can be done easily using mongoctl.
To install mongoctl on Ubuntu, just run:
sudo pip install mongoctl
In case you don't have installed pip, just run this before the above command:
git clone https://github.com/pypa/pip.git
cd pip
python setup.py install #might need sudo / root
To install the latest stable MongoDB release just run:
mongoctl install-mongodb
Beside installing MongoDB this also creates the config file for your first MongoDB server name "MyServer". You can simply start it using
mongoctl start MyServer
Stopping is as easy as starting it:
mongoctl stop MyServer
By default, journaling is enabled for MongoDB and may eat your hard disk if you're running many MongoDB servers. Having installed MongoDB using mongoctl, the journal of "MyServer" can be found here:
~/mongodb-data/my-server/journal
Listing the directory content shows us, that our instance uses 3GB of hard disk space.
drwxrwxr-x 2 alexzeitler alexzeitler 4,0K Jan 25 00:09 .
drwxrwxr-x 10 alexzeitler alexzeitler 4,0K Jan 24 23:15 ..
-rw------- 1 alexzeitler alexzeitler 1,0G Jan 25 00:09 prealloc.0
-rw------- 1 alexzeitler alexzeitler 1,0G Nov 25 13:04 prealloc.1
-rw------- 1 alexzeitler alexzeitler 1,0G Nov 25 13:04 prealloc.2
While (until the 2.0 release) disabling the journal is a bad idea for production, it is ok for a development environment.
To disable the journaling for "MyServer", head over to ~/.mongoctl
and edit the servers.config
file.
No find the "MyServer" configuration, which should be the first entry and look like this:
{
"_id": "MyServer",
"description" : "My server (single mongod)",
"cmdOptions": {
"port": 27017,
"dbpath": "~/mongodb-data/my-server",
"directoryperdb": true
}
}
In order to disable MongoDB journaling, add the nojournal
property to cmdOptions
:
{
"_id": "MyServer",
"description" : "My server (single mongod)",
"cmdOptions": {
"port": 27017,
"dbpath": "~/mongodb-data/my-server",
"directoryperdb": true,
"nojournal" : true
}
}
No, stop your "MyServer" instance and delete the files from the ~/mongodb-data/my-server/journal
(you're doing this at your own risk, of course - and as said not in a production environment!) directory.
After starting "MyServer" again, the journal folder should stay empty. That's it!
You can also limit the journal file size to 128MB by setting the smallfiles
property to true
.