Installing MongoDB on Ubuntu 18.04

Defines how to install DBMS as well as examination connectivity on virtual .

What is MongoDB?

MongoDB is an open resource document-oriented that provides high performance, high accessibility, as well as automatic scaling. MongoDB is available free of charge under a Public license, along with a business permit from the manufacturer.

The manufacturing company has defined MongoDB as:

«MongoDB is a scalable, open source, high performance, document-oriented database.»

Benefits of MongoDB

  • first of all, the DBMS is extremely simple to mount and also configure;
  • One of the most fundamental feature of MongoDB is that is a schemaless data source. Because MongoDB does not consist of a schema, only your specifies your schema.
  • the capability to derive an information design based on . A method to save data in BSON format (binary JSON), ruby hashes, and so on aids to store data in a hassle-free way, at the same time it is able to keep arrays as well as other documents;
  • document inquiry language plays an essential role in sustaining dynamic inquiries;
    quickly scalable;
  • performance tuning is definitely simple contrasted to any relational databases;
  • there is no demand to map application challenge information objects;
  • supplies faster accessibility to information due to its nature of using internal memory for storage;
  • MongoDB can also be used as a filesystem which helps with tons balancing:
  • MongoDB supports normal expression and area searching;
  • MongoDB can likewise be run as a service;
  • a large quantity of documentation is readily available;
  • Sharding assistance is among the key features. Partitioning is the procedure of keeping information across various machines as well as MongoDB’s capability to process the data as the dimension of the information grows. This causes straight scaling. With sharding, you can write as well as learn more data as the amount of data increases.

Installation

Before you start installing the MongoDB document-based DBMS, you need to download and import the GPG key into your operating system.

sudo apt-key adv --keyserver hkp://keyserver..com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

After importing the GPG key, add the repository:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu
xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

Update your local package database and install MongoDB:

sudo apt-get update
sudo apt-get install mongodb

Start the DBMS on the virtual server:

sudo systemctl start mongodb

If you need to start the service immediately after the server boots, then run the following command:

sudo systemctl enable mongodb

Check the status of a running service:

sudo systemctl status mongodb

If everything is installed correctly, then the following message will be displayed in the console:

● mongodb.service - An object/document-oriented database
   Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-07-22 14:30:11 MSK; 36min ago
     Docs: man:mongod(1)
 Main PID: 31599 (mongod)
    Tasks: 23 (limit: 507
   CGroup: /system.slice/mongodb.service
           └─31599 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf
Jul 22 14:30:11 Ubuntu1804x64 systemd[1]: Started An object/document-oriented database.

By default, the service should listen on port 27017, to check this, run the following command:

ss -tunelp | grep 27017

You will see the following output:

tcp    LISTEN   0    128     127.0.0.1:27017        0.0.0.0:*
users:(("mongod",pid=31599,fd=11)) uid:112 ino:72894 sk:1 

Connectivity Check

For a test connection to the MongoDB DBMS, you can run the command:

mongo --eval 'db.runCommand({ connectionStatus: 1 })'

Brief information on the connection result in json format:

MongoDB  version v3.6.3
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.6.3
{
        "authInfo" :
                "authenticatedUsers" : [ ],
                "authenticatedUserRoles" : [ ]
        },
        "ok" : 1
 }

To connect to the subd, use a simple command:

mongo

The following are simple examples for working with mongo.

Database creation:

> use cloud_db
switched to db cloud_db

Show current database:

> db
cloud_db

Insert data:

> db.files.insert({"name":"HostRooster"})
WriteResult({ "nInserted" : 1 })

List all databases on the server:

> show dbs
admin    0.000GB
config   0.000GB
local    0.000GB
сloud_db  0.000GB

Delete the current database:

> db.dropDatabase()
{ "dropped" : "cloud_db", "ok" : 1 }

exit command:

> exit
bye

 

Welcome to the world of DomainRooster, where roosters (and hens) rule the roost! We're a one-stop shop for all your entrepreneurial needs, bringing together domain names and website hosting, and all the tools you need to bring your ideas to life. With our help, you'll soar to new heights and hatch great success. Think of us as your trusty sidekick, always there to lend a wing and help you navigate the sometimes-complex world of domain names and web hosting. Our team of roosters are experts in their fields and are always on hand to answer any questions and provide guidance. So why wait? Sign up today and join the ranks of the world's greatest entrepreneurs. With DomainRooster, the sky's the limit! And remember, as the saying goes, "Successful people do what unsuccessful people are not willing to do." So don't be afraid to take that leap of faith - DomainRooster is here to help you reach for the stars. Caw on!