25

I needed to upgrade mongodb from 3.2 to 3.6 in my environment. For the process i first migrated from 3.2 to 3.4 as recommended. After successful migration to 3.4, i started migration to 3.6 i am not able to start mongod. When checked log file i found error like: IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.

MY Mongod.conf

systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log

storage: dbPath: /var/lib/mongo journal: enabled: true

processManagement: fork: true # fork and run in background pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile

net: port: 27017 bindIp: 127.0.0.1

Himanshu
  • 835
  • 1
  • 13
  • 22

2 Answers2

58

I have similar problem, I've upgraded on Ubuntu 16.04 from MongoDB 3.4 to 3.6 but I missed this important step

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

Then I must downgrade to 3.4 to do it and then upgrade to 3.6 again. Here is the detail steps:

1. Uninstall 3.6

Backup /etc/mongod.conf
Backup /etc/apt/sources.list.d/mongodb-org-3.6.listed (rename or move it to another folder)

sudo apt-get update
sudo apt-get remove mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools

2. Re-install 3.4
Check folder /etc/apt/sources.list.d/ to see if this file exists or not: mongodb-org-3.4.list. If it does not exist, you can re-create by this command:

echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

then install by apt-get

sudo apt-get update
sudo apt-get install -y mongodb-org
mongod --version
sudo systemctl start mongod

In my case the command systemctl start mongod return error Failed to start mongod.service: Unit mongod.service not found I resolved by these commands:

sudo systemctl enable mongod
sudo service mongod restart
sudo service mongod status

3. Execute very important command
After downgrade to 3.4, run this

mongo
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.10
> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
{ "featureCompatibilityVersion" : "3.4", "ok" : 1 }
> exit

4. Upgrade 3.6 again
Restore this file /etc/apt/sources.list.d/mongodb-org-3.6.listed

sudo apt-get update
sudo apt-get install mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools

Restore /etc/mongod.conf. Now, MongoDB 3.6 started without any problem

Hengjie
  • 4,598
  • 2
  • 30
  • 35
Cao Mạnh Quang
  • 1,027
  • 11
  • 10
  • 1
    Just a small correction, apt-get is missing on these commands: sudo remove mongodb-org-mongos sudo remove mongodb-org-server sudo remove mongodb-org-shell sudo remove mongodb-org-tools – Nuno Barreto Mar 06 '18 at 17:10
  • And a little recommendation: check `setFeatureCompatibilityVersion` on all the replica set members with: `db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )` (https://docs.mongodb.com/manual/release-notes/3.6-upgrade-replica-set/#prerequisites) – AstraSerg Mar 22 '18 at 10:56
  • 2
    I had to add --allow-unauthenticated during step "2. Re-install 3.4" `sudo apt-get install -y mongodb-org --allow-unauthenticated` – guillim Jun 26 '18 at 09:37
  • 4
    I had to add the repo-key for mongodb-org: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6 – Some Juan Oct 08 '18 at 20:22
  • very helpful - I missed the same step and this allowed me to recover – Tahbaza Jan 19 '19 at 18:04
  • Mistype: filename should be `/etc/apt/sources.list.d/mongodb-org-3.6.list`, not `/etc/apt/sources.list.d/mongodb-org-3.6.listed`. Can you please correct you answer (replaceing `listed` to `list`)? – Maxím G. Apr 16 '19 at 10:55
  • The missing step should be in blinking red on all upgrade from 3.2 to 3.6 documentation. Thanks for the instructions. – Cotta Apr 18 '20 at 03:23
3

This may be the case when your db folder contains old mongoDB database format (like 3.4)

here is a useful hack if you don't mind LOOSING ALL YOUR DATA

  • After saving it you can delete the content of /data/db folder (ubuntu/linux mint)
  • Then restart mongod, then it should work normally
TOPKAT
  • 6,667
  • 2
  • 44
  • 72