Upgrading Mongodb from 3.4 to 3.6

Viewed 8118

I am trying to upgrade my single node mongodb cluster from 3.4 to 3.6.
Everything is ok but I am not able to change feature compatibility to 3.6. When I try-

db.adminCommand( { setFeatureCompatibilityVersion:"'3.6'" } )

I get an error saying -

{
"ok" : 0,
"errmsg" : "Invalid command argument. Expected '3.4' or '3.2', found '3.6' in: { setFeatureCompatibilityVersion: \"'3.6'\" }. See http://dochub.mongodb.org/core/3.4-feature-compatibility.",
"code" : 2,
"codeName" : "BadValue"
}
4 Answers

you can try to follow the instructions on this site Upgrade a Standalone to 3.6

and if you use Ubunt OS, try this:

Step 1: Stop the old Mongod server

run “sudo systemctl stop mongod” and MongoDB will be stopped.

Step 2: Import the MongoDB public key

Run “sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5” and the key is imported for you!

Step 3: Update the list file for apt/MongoDB

To remove the old list run “sudo rm /etc/apt/sources.list.d/mongodb-org-3.4.list” Now add the new one with “echo “deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list” Run “sudo apt-get update” to update apt’s lists.

Step 4: Upgrade the MongoDB install

The easiest way to do this is to run “sudo apt-get upgrade -y” which will make apt update all the out of date packages in your system. Fun! If it asks to replace the file at /etc/mongod.conf just say no to keep your settings as they are.

Step 5: Start MongoDB

Run “sudo systemctl start mongod” and we are up and running. It’s as easy as that!

It seems like what you posted has an error with double and single quotes (making the error message you posted make sense :-) ).

db.adminCommand( { setFeatureCompatibilityVersion:"'3.6'" } )

It should have been:

db.adminCommand( { setFeatureCompatibilityVersion:"3.6" } )

In addition, you may want to learn more about the "FCV" from these instructions.

For some reason my db version was not updated, may be some dependencies got messed up. I uninstalled current installation with purge option and reinstalled mongodb and it fixed the issue.
Don't forget to create backup for config file if you are using purge option.

As official definition: It enables or disables the features that persist data incompatible with earlier versions(*means lower versions than your current one) of MongoDB. So for example, if I got mongo3.6 then I have to worry about the previous versions, not the current. Are you trying to set compatibility for the same version on itself? The error also suggests your system require to map the previous versions only. i.e. version lower than your current installed one.

Related