What is Redis?

What is Redis?

introduction

Redis is an Open Source NoSQL database. It is very popular, capable and remarkably fast In-Memory database. It stores the data in key-value pair and no doubtfully says it is a NoSQL database.

Redis doesn’t have a query language like relational databases. It doesn’t support an Indexing. But, we can do our own indexing to store the additional data.

Redis also supports persistent storage optionally, that stores the data into the disk. Also, it works as a Master-Slave Replication. Master database syncs with Slave database. If the Master fails, the slave takes control.

where to use redis?

  • It is used to store the Stateless tokens (JWT) and invalidates the user sessions for blacklisted/expired tokens.
  • It is used to cache the search results.
  • It is used to send the notifications with the support of Publisher and Subscriber mechanism.

what is sql?

SQL is a Structured Query Language and used for structured databases with Predefined schema. Data stored in the tables and a table consists of columns. Few SQL databases are given below.

  • MySQL
  • Oracle
  • Microsoft SQL Server
  • MariaDB

What is nosql?

NoSQL don’t have structured language and it supports dynamic schema. Few NoSQL databases are given below

  • Redis and Dynomo databases are supports Key Pair value storage.
  • MongoDB and CouchDB databases are supports to store Documents by using collections.
  • Cassandra and HBase databases are used to store the huge data sets with wide column.
  • Neo4J and Infinite Graph databases are used to store locations, geometries and topological information.

SQL vs NoSQL

  1. Schema
    • SQL stores the data into tables and NoSQL stores the data into Key Pair, Document, columnar and Graph.
  2. Query
    • SQL uses structure Query language and NoSQL uses unstructured query language.
  3. Scalability
    • SQL uses vertical scaling (enabling the scalability by using same server hardware) and No SQL uses horizontal scaling (by adding additional servers)
  4. Reliability
    • SQL supports ACID properties. NoSQL doesn’t support ACID properties.
  5. ACID Properties
    • In order to ensure accuracy, completeness, and data integrity.
    • SQL databases are doesn’t compromise the ACID properties. But NoSQL compromises.

When to use SQL

  • Data have stable and defined structure.
  • ACID compliance.
  • Insanely store and retrieval.

When to use NoSQL

  • Storing a big amount of data with no defined structure.
  • Cloud storage and hosting – horizontal scaling and cost effective.
  • Quick software development and Prototype.
Advertisements

How to install MongoDB on Linux Debian 9?

How to install MongoDB on Linux Debian 9?

The MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need. It stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time. The document model maps to the objects in your application code, making data easy to work with. Ad hoc queries, indexing, and real time aggregation provide powerful ways to access and analyze your data. MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use by www.mongodb.com.

In this blog, we will install the MongoDB on Linux Debian 9. The step by step procedure has been given below to install MongoDB.

First, update all the existing packages by using below command.

sudo apt update

Then, install the MongoDB package by using apt install command.

sudo apt install -y mongodb

The above command installs the latest stable version of MongoDB and also it starts the MongoDB service automatically after the installation complete.

Now, this the time to verify the MongoDB service has been started or not on the Linux Debian 9.

Execute the below system control status command to see the status of MongoDB service.

 sudo systemctl status mongodb 

You will see the below output on the console.

Then, verify the MongoDB server connection by using diagnostic command.

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

After executed the command, you will see the below output on the console with Database server version and OK attribute.

MongoDB shell version: 3.2.11
connecting to: test
{
        "authInfo" : {
                "authenticatedUsers" : [ ],
                "authenticatedUserRoles" : [ ]
        },
        "ok" : 1
}

The OK field value “1” represents, database server is running without any issues.

Below commands are used to manage the MongoDB service by using system control commands.

To view the status of the MongoDB service.

sudo systemctl status mongodb

To stop the MongoDB service.

sudo systemctl stop mongodb

To start the MongoDB service when it stopped.

sudo systemctl start mongodb

To restart the MongoDB service.

 sudo systemctl restart mongodb 

By default MongoDB service will start when the system starts. To disable that execute the below command.

sudo systemctl disable mongodb

Execute the below command to enable the MongoDB service when the system starts.

sudo systemctl enable mongodb

The MongoDB successfully installed on the Linux Debian 9.