I'm looking for the easiest and the most recommended way to upgrade mongodb version (standalone server and mongodb shell).
Are there any terminal (for mac) commands that i can follow in order to upgrade?
I tried to stop the server by $ mongo
use admin db.shutdownServer()
i get : Sat Mar 17 20:38:15 DBClientCursor::init call() failed Sat Mar 17 20:38:15 query failed : admin.$cmd { shutdown: 1.0 } to: 127.0.0.1:27017 server should be down... Sat Mar 17 20:38:15 trying reconnect to 127.0.0.1:27017 Sat Mar 17 20:38:15 reconnect 127.0.0.1:27017 failed couldn't connect to server 127.0.0.1:27017
I understand that after stopping the server i need to change the bin folder of mongodb. (which i'm failing to do because mongo is in use)
If someone knows an easier way to only upgrade the mongodb version i would really thank him/her! thank you.
1.Import the public key used by the package management system
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
2. Create a list file for MongoDB.
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
3. Reload local package database. sudo apt-get update
4. stop the existing service sudo service mongodb stop
5. first migrate to 2.4 to 2.6 Install a specific release of MongoDB
sudo apt-get install -y mongodb-org=2.6.12 mongodb-org-server=2.6.12 mongodb-org-shell=2.6.12 mongodb-org-mongos=2.6.12 mongodb-org-tools=2.6.12
6.unlink the temp links remove the lock file. rm /tmp/mongodb-27017.sock
7.restart mongo service sudo service mongodb restart
8. Now finally migrate from 2.6 to 3.0 sudo apt-get install -y mongodb-org=3.0.12 mongodb-org-server=3.0.12 mongodb-org-shell=3.0.12 mongodb-org-mongos=3.0.12 mongodb-org-tools=3.0.12
restart again and voila !!!!
For more details follow the official documentation: mongo doc
shutdown mongodb with:
(replace /usr/bin with the right directory) copy new mongodb and restart mongodb afterwards.
Depends on the version upgrade, but usually if it's a major upgrade (example from 1.8.xx to 2.0.XX) you should do at least the following steps:
After that make sure that everything is working properly. If not switch back to the old version, import the data from the backup and check mongoDB jira :)
To Upgrade MongoDB on Ubuntu
First, Backup your data using Mongoexport
e.g:
Then check which version of MongoDB you are running by issuing the command:
Confirm if mongo is currently running:
To Shutdown MongoDB
Then upgraded following these instructions: How to Install MongoDB on Ubuntu
Add the 10 Gen (creators of MongoDB) public key to apt-get so you trust their package:
Update your packages:
install 10gen's MongoDB Debian/Ubuntu package:
If you get an error, try:
Confirm that the mongodb user/group has permission to write to the data directory:
Start up MongoDB as a Daemon (background process) using the following command:
To Shut Down MongoDB enter the Mongo CLI, access the admin and issue the shutdown command:
To upgrade from version 2 to version 3
I was unsuccessful using the methods in the other answers here, and was finally successful when following the offical document's "Upgrade Binaries" approach, like so:
Stop mongo from running :
$ sudo service mongod stop
Download the correct binaries
Copy the downloaded binaries over :
$ sudo cp downloaded_binaries/bin/* /usr/bin
Restart mongo :
$ sudo service mongod start