Saturday, July 27, 2019

MongoDB 4.0 on Ubuntu 18.04 bionic


MongoDB is a cross-platform document-oriented database program. 
Classified as a NoSQL database program, MongoDB uses JSON-like documents with schema. 
Source: Wikipedia

MongoDB 4.0 was released on 2018-08-06

New 'wow' features of MongoDB 4.0:

  • multi-document ACID transactions
  • data type conversions
  • 40% faster shard migrations
  • non-blocking secondary replica reads

And some other niceties:
  • native visualizations with MongoDB Charts
  • Compass aggregation pipeline builder
  • Stitch serverless platform
  • SHA-2 authentication
  • Mobile database
  • HIPAA compliance to the MongoDB Atlas database service
  • free community monitoring service
  • Kubernetes integration

While the new features in MongoDB 4.0 are great, 
the latest Ubuntu version 18.04 official repository still installs MongoDB version 3.6

To get the current version of MongoDB
> mongo --version

To install MongoDB version 4.0, you need to install from MongoDB's repository.

Instructions to install MongoDB 4.0 and some hurdles I encountered follow:

1) Add the MongoDB repo
> sudo vi /etc/apt/sources.list.d/mongodb-org-4.0.list  
deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse  

2) Add MongoDB the repo key
> sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

3) Update your system
> sudo apt-get update

4) Install MongoDB 4.0
> sudo apt-get install mongodb-org

5) Status and restart MongoDB
> sudo systemctl status mongod
> sudo systemctl restart mongod

Hurdles:
If MongoDB does not start, there may be some issues with removing the prior MongoDB version.

Errors I encountered:
error processing archive /var/cache/apt/archives/mongodb-org-server_4.0.10_amd64.deb (--unpack):
error trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
error trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
error trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.6.3-0ubuntu1

Some potential fixes
> sudo apt --fix-broken install
This by it self did not help

Remove prior MongoDB and other unused packages
> sudo apt autoremove
This did fix the issue and allow me to run MongoDB 4.0

To get version of MongoDB
> mongo --version

Also, if you accidentally tried to get the version from the daemon
> mongodb --version  
MongoDB will start as your user, often sudo/root,
which may cause some MongoDB files to be created as root.

You may have to reset user/group permissions
> sudo chown -R mongodb:mongodb /data/mongodb/


-End of Document-
Thanks for reading

No comments:

Post a Comment