This forum provides solutions for aws developers for their issues.It provides solutions for aws elastic ip, ec2 instance, public ip,route53 pricing, load balancers in aws,Orchestration, ebs,, lambda, installing mongodb on ubuntu etc.

Wednesday, 12 July 2017

Installing MongoDB on Ubuntu 16.04

MongoDB is  included in Ubuntu package repositories, but official MongoDB repository provides most upto date version.

We use official version of MongoDB
$ sudo apt-key adv --keyserver hkp:// --recv EA312927

The output should look like this
ubuntu@ip-192-41-15-154:~$ sudo apt-key adv --keyserver hkp:// --recv EA312927
Executing: /tmp/tmp.u96cXK2VEb/ --keyserver
gpg: requesting key EA312927 from hkp server
gpg: key EA312927: public key "MongoDB 3.2 Release Signing Key <>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

We add MongoDB repository to Apt, so that apt know where to download the repository

echo "deb [ arch=amd64,arm64 ] xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
deb [ arch=amd64,arm64 ] xenial/mongodb-org/3.4 multiverse
Update the Apt 
$ sudo apt-get update 
Hit:1 xenial InRelease
Get:2 xenial-updates InRelease [102 kB]
Ign:3 xenial/mongodb-org/3.4 InRelease
Get:4 xenial-backports InRelease [102 kB]
Get:5 xenial/mongodb-org/3.4 Release [3,457 B]
Get:6 xenial/mongodb-org/3.4 Release.gpg [801 B]
Get:7 xenial-updates/main Sources [258 kB]
Get:8 xenial-updates/main amd64 Packages [573 kB]
Get:9 xenial-updates/universe amd64 Packages [504 kB]
Ign:6 xenial/mongodb-org/3.4 Release.gpg
Hit:10 xenial InRelease
Get:11 xenial-security InRelease [102 kB]
Get:12 xenial/mongodb-org/3.4/multiverse amd64 Packages [5,870 B]
Get:13 xenial/mongodb-org/3.4/multiverse arm64 Packages [5,872 B]
Fetched 1,658 kB in 1s (938 kB/s)
Reading package lists... Done
W: GPG error: xenial/mongodb-org/3.4 Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AC711F9BA35703V6
W: The repository ' xenial/mongodb-org/3.4 Release' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Install MongoDB

$ sudo apt-get install mongodb-org


Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
  mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 66.8 MB of archives.
After this operation, 270 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
WARNING: The following packages cannot be authenticated!
  mongodb-org-shell mongodb-org-server mongodb-org-mongos mongodb-org-tools mongodb-org
Install these packages without verification? [y/N] Y
Get:1 xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-shell amd64 3.4.6 [7,981 kB]
Get:2 xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-server amd64 3.4.6 [14.2 MB]
Get:3 xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-mongos amd64 3.4.6 [8,110 kB]
Get:4 xenial/mongodb-org/3.4/multiverse amd64 mongodb-org-tools amd64 3.4.6 [36.5 MB]
Get:5 xenial/mongodb-org/3.4/multiverse amd64 mongodb-org amd64 3.4.6 [3,556 B]
Fetched 66.8 MB in 3s (20.3 MB/s)
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 108006 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_3.4.6_amd64.deb ...
Unpacking mongodb-org-shell (3.4.6) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../mongodb-org-server_3.4.6_amd64.deb ...
Unpacking mongodb-org-server (3.4.6) ...
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../mongodb-org-mongos_3.4.6_amd64.deb ...
Unpacking mongodb-org-mongos (3.4.6) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_3.4.6_amd64.deb ...
Unpacking mongodb-org-tools (3.4.6) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_3.4.6_amd64.deb ...
Unpacking mongodb-org (3.4.6) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mongodb-org-shell (3.4.6) ...
Setting up mongodb-org-server (3.4.6) ...
Adding system user `mongodb' (UID 113) ...
Adding new user `mongodb' (UID 113) with group `nogroup' ...
Not creating home directory `/home/mongodb'.
Adding group `mongodb' (GID 118) ...
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Setting up mongodb-org-mongos (3.4.6) ...
Setting up mongodb-org-tools (3.4.6) ...
Setting up mongodb-org (3.4.6) ...
Create mongodb.service configuration file
$ sudo nano /etc/systemd/system/mongodb.service
Start MongoDB as Daemon
$ sudo systemctl start mongod
Check status of MongoDB
$ sudo systemctl status mongod

 mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/etc/systemd/system/mongodb.service; disabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-07-16 03:25:42 UTC; 1min 43s ago
 Main PID: 13102 (mongod)
    Tasks: 20
   Memory: 34.8M
      CPU: 408ms
   CGroup: /system.slice/mongodb.service
           └─13102 /usr/bin/mongod --quiet --config /etc/mongod.conf
Jul 13 03:25:42 ip-192-31-13-143 systemd[1]: Started High-performance, schema-free document-oriented database.

Enable process start for MongoDB when system reboot
$ sudo systemctl enable mongodb
Created symlink from /etc/systemd/system/ to /etc/systemd/system/mongodb.service.

0 coment�rios:

Post a comment


Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts