Git for beginners 4b: Working with remote branches
Moving code around with branches
How to upgrade MongoDB, on Ubuntu
Upgrading from MongoDB 3.6 to 4.0 seems to break the file storage. You need to do the upgrade manually in order for it to work. These are my notes on how I did it on Ubuntu 18.04 Bionic.
If you're already running 4.0, you need to reinstall Mongo 3.6.
In /etc/apt/sources.list.d/
, ensure you have the file /etc/apt/sources.list.d/mongodb-org-3.6.list
, containing the line
deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse
Yes, that is for Xenial: that's the latest version of Ubuntu with version 3.6 in the packages.
Then update apt
and downgrade mongodb
:
$ sudo systemctl stop mongod.service
$ sudo aptitude update
$ sudo apt-get install mongodb-org=3.6.8 mongodb-org-mongos=3.6.8 mongodb-org-server=3.6.8 mongodb-org-shell=3.6.8 mongodb-org-tools=3.6.8
$ sudo systemctl start mongod.service
With Mongo 3.6 installed, now follow the official upgrade instructions.
Start a Mongo shell
$ mongo
In the shell, prepare for the upgrade:
> db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
Check it worked:
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
and check that "featureCompatibilityVersion" : { "version" : "3.6" }
is in the output.
Ensure you have the file /etc/apt/sources.list.d/mongodb-org-4.0.list
containing the line
deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse
A simple sudo aptitude update && aptitude full-upgrade
will then install Mongo 4.0.
Check it's working with $ sudo systemctl status mongod.service
and make sure you can connect to the Mongo shell with $ mongo
.
While we're here, let's upgrade the storage engine from the now-deprecated mmapv1
to the supported wiredTiger
.
The official instructions are very clear.
$ sudo mkdir /opt/mongo
$ sudo chmod a+rwx /opt/mongo
$ mongodump --out /opt/mongo/
$ sudo systemctl stop mongod.service
$ sudo rm -rf /var/lib/mongodb
wiredTiger
storage engine by changing the storage
stanza in /etc/mongo.conf
by changing the engine
line to read:`# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
engine: wiredTiger
# mmapv1:
# wiredTiger:
$ sudo systemctl start mongod.service
$ mongorestore /opt/mongo/
Everything should be working!