Aim

In this post we will be installing MongoDB 3.4 on Ubuntu 18.04

Step 1 : Add the key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

Step 2 : Add and update the apt repository

echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt update

Step 3 : Install MongoDB 3.4

sudo apt-get install -y mongodb-org=3.4.17 mongodb-org-server=3.4.17 mongodb-org-shell=3.4.17 mongodb-org-mongos=3.4.17 mongodb-org-tools=3.4.17

Check MongoDB is Running or not

systemctl status mongod
  • This will give you the below output
selftuts@node1:~$ systemctl status mongod
mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: https://docs.mongodb.org/manual
  • You can clearly see the Active: inactive (dead)

Starting MongoDB

 systemctl start mongod
  • Again check the status of MongoDB service
systemctl status mongod
  • You will get the below output
selftuts@node1:~$ systemctl status mongod
● mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-08-05 06:15:05 UTC; 4s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 3450 (mongod)
   CGroup: /system.slice/mongod.service
           └─3450 /usr/bin/mongod --config /etc/mongod.conf
  • You can see the Active: active (running) since Wed 2020-08-05 06:15:05 UTC; 4s ago

Goto MongoDB console

  • Just type mongo in your terminal
mongo
  • You will enter into the MongoDB client console with below output
selftuts@node1:~$ mongo
MongoDB shell version v3.4.17
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.17
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
        http://docs.mongodb.org/
Questions? Try the support group
        http://groups.google.com/group/mongodb-user
Server has startup warnings:
2020-08-05T06:15:05.874+0000 I STORAGE  [initandlisten]
2020-08-05T06:15:05.874+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-08-05T06:15:05.874+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-08-05T06:15:05.995+0000 I CONTROL  [initandlisten]
2020-08-05T06:15:05.995+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-08-05T06:15:05.995+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-08-05T06:15:05.995+0000 I CONTROL  [initandlisten]
>

Happy Coding

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x