I wasn't able to use wiredTiger upgrading MongoDB. However, at May 17
I uninstalled MongoDB 2.6 then installed MongoDB 3.0.3 . Immediate after the installation, I added storageEngine=wiredTiger
on top of my mongod.conf file. Then I gave sudo service mongod start
command and eventually I could.
Edit:
For fresh installed as directed by official documentation;
- Open configuration file using
sudo nano /etc/mongod.conf
- Change the
# engine
line to engine: wiredTiger
like the below
- Run mongod using the command
sudo service mongod start
.
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
engine: wiredTiger
# mmapv1:
# wiredTiger:
Edit:
If the current version is supported the wiredTiger;
- Get the backup of the current database using mongodump command
- Stop the mongod service using
sudo service mongod stop
command
- Add
storageEngine=wiredTiger
text as the first line of mongod.conf
file
- Delete the all file on
/var/lib/mongodb
(or /data/db
folder if used)
[This is important. Because MongoDB cannot convert the current MMAP db files to wiredTiger format]
- Start the mongod service using
sudo service mongod start
command
- Restore the database from the backup using [mongorestore][2] command
- wiredTiger is being used...
There is actually nothing really wrong here, at least not based on what you have included in the question. Go back to this point:
ubuntu-user@ubuntu-vm:~$ mongo
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings:
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten]
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2015-03-27T12:37:30.430+0100 I CONTROL [initandlisten]
> ^C
At this point you have a running mongod
(the procedure you followed installs it as a service), and you have successfully connected to it using the mongo
shell, it just has a hugepages warning - that is something you should fix long-term but it does not prevent MongoDB from running.
You then exited the shell and attemped to start another mongod
for some reason (you do not need to, the service is still running). If you run mongod
without a config file or any options, it will attempt to start with its defaults (port 27017, data directory = /data/db
). In this case /data/db
does not exist and so you get the error and it terminates.
To fix the error in terms of the hugepages you can alter grub.conf
file, as outlined in this answer but you may have made a mistake or omitted something when you made your changes. It's also possible that you will lose those changes if/when you upgrade your kernel. Hence I would recommend undoing your grub changes and trying the second option listed in the answer above, that is, add the command to your /etc/rc.local file.
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
As an added bonus, you can run this from the command line (as root), then restart the mongod
service to confirm the changes have been picked up successfully.
Best Answer
Upgrade Requirements To upgrade an existing MongoDB deployment to 3.0, you must be running 2.6. If you’re running a version of MongoDB before 2.6, you must upgrade to 2.6 before upgrading to 3.0. See Upgrade MongoDB to 2.6 for the procedure to upgrade from 2.4 to 2.6. Once upgraded to MongoDB 2.6, you cannot downgrade to any version earlier than MongoDB 2.4.
http://docs.mongodb.org/manual/release-notes/2.6-upgrade/
One of the most important thing to remember after you are on 2.6 if you are trying to use WiredTiger as your storage engine, you do need to take a mongodump by connecting into current mongodb version and then switch to mongodb 3.0 with a different db path,
IMP: You will not be able to use existing DB path as previous storage on mmapv1
Command to use: mongod --storageEngine wiredTiger --dbpath
mongodump and mongorestore can operate against a running mongod process, and used to take a backup and restore the backup respectively.
http://docs.mongodb.org/manual/reference/configuration-options/