Complete Guide on Installation of MongoDB in AWS Linux by Tejaswini UL
In this blog, will have a brief on steps for installing MongoDB in AWS Linux. You can get up to speed with MongoDB if you are new or rusty! To begin with, consider you have an EC2 instance running and you have root access to this EC2 instance, then you can install MongoDB with authentication on EC2 AMI Linux.
MongoDB: An open source NoSQL DB that utilizes an document-based data model. MongoDB architecture is built on documents and collections, whereas MySQL stores data in tables and rows and MongoDB uses JSON schemas.
Key features of MongoDB:
-
High performance
-
Aggregation Framework
-
Rich query language
-
MongoDB Sharding
-
Highly available
-
Horizontal scalability
-
MongoDB is Schema – Less
-
Supports geospatial indexes
-
Support for multiple pluggable storage engines
Supported MongodB Packages:
Here are the MongoDB packages that are supported officially with their own repository.
MongodB Package Name |
Synopsis |
mongodb-org |
Its a metapackage that install automatically 4 component packages i.e., server, mongos, shell and tools. |
server |
Carries the mongod daemon and corresponding to init scripts configuration. |
mongos |
Used for MongoDB shard configurations which carries the mongos daemon. |
shell |
Holds the mongo shell. |
tools |
Carries the MongoDB tools such as mongoimport bsondump, mongodump, mongofiles, mongoexport, mongoperf, mongorestore, mongostat, and mongotop. |
Installation Process of MongoDB:
If we want to install MongoDB directly with the help of yum then we need to add MongoDB repository. Here are the installation steps to follow for a root user.
Step 1: Let’s consider we have to connect AWS EC2 Instance with a PEN/PPK File.
For MongoDB 3.4, we can create the following file using any other editor:
If you Consider the Vi editor then, here is the syntax:
Add the following lines in the repository file [mongodb-org-3.4]
Step 2: Here is the command to install MongoDB
Step 3: Start Using MongoDB Service with this command
Now, you have to verify weather MongoDB started or not by cross checking the content of the MongoDB log file using the following path
And then check the log file with the help of the below line:
Here 27017 is considered as a default port. You can even configure one more port in configuration file that is located at /etc/mongod.conf
Step 4: Lets start MongoDB once the every system reboot, using the below command:
After starting the service, For creating a user, you have to connect to the Mongo shell.
By using mongo command we have to connect the Mongo shell, if you found any error while using the command the you have to add export as follows:
Step 5: Admin Selection & User Creation
After successful connection to mongo, we have to choose admin using the command:
use admin
Now create an user as follows:
Step 6: How to Create User for Particular Database
For this, we have to repeat the step 5 using use command.
Now create a user for that database:
Now, the question is how to edit the configuration file if required?
For any Mongo version i.e., 3.x, add the following code to the config:
And run service mongod restart command.
Step 7: If you need MongoDB to connect to Remotely (Which is Optional)
Now, let’s connect MongoDB remotely, for this you have to edit the config file using the VI editor or any other.
For Vi editor here is the command
Then add the IP address in bindIp file as follows and then we have to restart the MongoDB service.
That’s it! :) You’ve successfully installed the MongoDB with AWS Linux.
Uninstallation Process:
Now you may have the question how to uninstall this right? Here are the steps to uninstall:
Step 1: First you have to Stop MongoDB using the command given:
Step 2: Now, Restart the MongoDB Service with the below command:
Here by default the output of MongoDB stored its data file in /var/lib/mongo and here is the log file in:
We have an alternate path for modifying the data and log directory i.e., /etc/mongod.conf file.
Step 3: Now Uninstall MongoDB from AWS Linux:
Once we stopped the mongoDb service, for removing MongoDB fully from the system, we need to remove the even MongoDB application, and the associated config files, logs files and if any other directories that are having data files in them.
-
Remove Packages: We have to remove the any MongoDB packages that are installed previously by using the following command:
-
Remove Data Directories: We have to remove all the all database files and log files using the following commands:
About the author:
The post Complete Guide on Installation of MongoDB in AWS Linux by Tejaswini UL appeared first on Hakin9 - IT Security Magazine.
from Hakin9 – IT Security Magazine https://ift.tt/2IwPjiB
devops online training
ReplyDeleteNice postpower bi training
ReplyDelete