Reputation: 3301
mongod
I got the following error
** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.6 before attempting an upgrade to 4.0; see http://dochub.mongodb.org/core/4.0-upgrade-fcv for more details.
But if I use
brew services start mongodb
then mongo server can start.
To fix the mongod error
I found the similar error thread
Error while upgrading Mongodb from 3.2 to 3.6
So I downgraded to mongodb 3.6, and run
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
and then reinstall mongodb 4.0, I still have the same error when I run
mongodb
I still have to use
brew services start mongodb
to start mongodb
In command line, I run
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{ "featureCompatibilityVersion" : { "version" : "3.6" }, "ok" : 1 }
>
It says featureCompatibilityVersion is 3.6
What else I need to do to satisfy "The data files need to be fully upgraded to version 3.6 "?
Thanks!
Upvotes: 17
Views: 15425
Reputation: 365
thx @searain, this procedure worked also on Ubuntu, I just had to adapt the commands, for those who are interested:
Commands for Ubuntu 16.04
sudo cp -rp /var/lib/mongodb/ mongobackup/
sudo cp -p /etc/mongod.conf mongobackup/
sudo service mongod stop
sudo apt purge mongodb-org*
Copy installation commands from [email protected]
sudo apt list -a mongodb-org
sudo apt install -y mongodb-org=3.4.22 mongodb-org-server=3.4.22 mongodb-org-shell=3.4.22 mongodb-org-mongos=3.4.22 mongodb-org-tools=3.4.22 --allow-downgrades
sudo systemctl enable mongod
sudo service mongod start
mongo -u "dba" -p "..." --authenticationDatabase "admin"
Read more about setFeatureCompatibilityVersion
in the docs.
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
If status is not ok
but not authorized
try:
db.grantRolesToUser('admin', [{ role: 'root', db: 'admin' }])
sudo service mongod stop
sudo apt purge mongodb-org*
Copy installation commands from [email protected]
sudo apt list -a mongodb-org
sudo apt install -y mongodb-org=3.6.14 mongodb-org-server=3.6.14 mongodb-org-shell=3.6.14 mongodb-org-mongos=3.6.14 mongodb-org-tools=3.6.14
sudo systemctl enable mongod
sudo service mongod start
mongo -u "dba" -p "..." --authenticationDatabase "admin"
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
sudo service mongod stop
sudo apt purge mongodb-org*
sudo apt install -y mongodb-org
During this process, the mongod.conf might have been lost. Make sure authorization is enabled:
sudo vi /etc/mongod.conf
Needs:
security:
authorization: enabled
sudo systemctl enable mongod
sudo service mongod start
Upvotes: 1
Reputation: 3301
I need to downgrade MongoDB to 3.4. Clean up all the versions. Then upgrade to 3.6 and 4.0 step by step.
First of all, back up your /data/db, just in case.
The following steps are from my experience, I used brew to install/uninstall mongodb.
I followed the instruction from this thread, but run the following steps on iMac.
Error while upgrading Mongodb from 3.2 to 3.6
Uninstall your current mongodb
brew uninstall mongodb
Install mongodb 3.4 version
brew install [email protected]
Start mongod 3.4 version (when you install the old version like above, you need the full path to run it.)
/usr/local/opt/[email protected]/bin/mongod
Start mongo 3.4 version
/usr/local/opt/[email protected]/bin/mongo
Run the important command
> db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
Quit
>quit();
Terminate the mongod
Find PID of mongod process using $ top
Kill the process by $ kill <PID> (the Mongo docs have more info on this)
Uninstall mongodb 3.4
brew uninstall [email protected]
Repeat the above steps for 3.6
Install mongodb 3.6 version
brew install [email protected]
Start mongod 3.6 version
/usr/local/opt/[email protected]/bin/mongod
Start mongo 3.6 version
/usr/local/opt/[email protected]/bin/mongo
Run the important command
> db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
...
Last, after uninstall 3.6, then you can install the most current version, 4.x, you don't have to specify the @4.x etc., just
Install the most current version
brew install mongodb
Upvotes: 52
Reputation: 26182
I would better just do it via mongodump/mongorestore procedures.
Upvotes: 1