How to install MongoDB on Ubuntu 18.04
MongoDB Installaion on Ubuntu 18.04
MongoDB is a free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with schemata. In this tutorial, you will learn the method to install MongoDB on Ubuntu 18.04
Installation
First we need to update the packages list to have the most recent version of the repository
root@linuxhelp1:~# apt update
Hit:1 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [83.2 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Fetched 247 kB in 1s (180 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
667 packages can be upgraded. Run 'apt list --upgradable' to see them.
Once it is done, you can install the MongoDB package by running the following command
root@linuxhelp1:~# apt install -y mongodb
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5
libsnappy1v5 libtcmalloc-minimal4 libunwind8 libyaml-cpp0.5v5
mongo-tools mongodb-clients mongodb-server mongodb-server-core
The following NEW packages will be installed:
libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5
Setting up mongodb-server (1:3.6.3-0ubuntu1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/mongodb.service → /lib/systemd/system/mongodb.service.
Setting up mongodb (1:3.6.3-0ubuntu1) ...
Processing triggers for libc-bin (2.27-0ubuntu2) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu6) ...
After installation you need to check the service's status
root@linuxhelp1:~# systemctl status mongodb.service
mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor
Active: active (running) since Wed 2019-01-02 00:23:51 IST; 43s ago
Docs: man:mongod(1)
Main PID: 36117 (mongod)
Tasks: 23 (limit: 1706)
CGroup: /system.slice/mongodb.service
└─36117 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --conf
Jan 02 00:23:51 linuxhelp1 systemd[1]: Started An object/document-oriented database.
With this the method of MongoDB comes to an end.
Q
Is MongoDB schema-less?
A
No. In MongoDB, schema design is still important. MongoDB's document model does, however, employ a different schema paradigm than traditional relational databases.
Q
How is data stored in MongoDB?
A
Data in MongoDB is stored in BSON documents – JSON-style data structures. Documents contain one or more fields, and each field contains a value of a specific data type, including arrays, binary data, and sub-documents. Documents that tend to share a similar structure are organized as collections.
Q
When and why MongoDB is used?
A
Wherever a developer is considering a relational database, they should consider MongoDB.
Wherever a developer is considering a NoSQL database, they should consider MongoDB.
Wherever a developer is considering a NoSQL database, they should consider MongoDB.
Q
How does mongos detect changes in the sharded cluster configuration?
A
mongos instances maintain a cache of the config database that holds the metadata for the sharded cluster.
mongos updates its cache lazily by issuing a request to a shard and discovering that its metadata is out of date. To force the mongos to reload its cache, you can run the flushRouterConfig command against each mongos directly.
mongos updates its cache lazily by issuing a request to a shard and discovering that its metadata is out of date. To force the mongos to reload its cache, you can run the flushRouterConfig command against each mongos directly.
Q
How is sharding appropriate for a new deployment for MongoDB?
A
Sometimes. However, if your data set fits on a single server, you should begin with an unshared deployment as sharding while your data set is small provides little advantage.