MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need.
MongoDB 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
MongoDB is free and open-source, published under the GNU Affero General Public License
Step 1. Add the MongoDB Repository:
mongodb-org package does not exist within the default repositories for CentOS. However, MongoDB maintains a dedicated repository. Let’s add it to our server.
vi editor, create a
.repo file for
yum, the package management utility for CentOS:
Option A: If you are running a 64-bit system, add the following information to the file you have created.
Then exit and save the file.
Option B: If you are running a 32-bit system, add the following information to the file you’ve created, using i to insert:
Then exit and save the file. I believe everyone is aware how to edit and save a file in vi editor.
Step 2. Install MongoDB:
yum -y install mongodb-org mongodb-org-server
Note: Here I have given ‘-y’ in the above command, this tell that we are by default typed “yes” for all the confirmation that are going to ask in the installation process. You do need to enter”yes” or “y” while installation.
Step 3. Get MongoDB Running:
systemctl start mongod
Check MongoDB Service Status:
systemctl status mongod
systemctl utility did not provide a result after executing the
start command, but we can check that the service started by viewing the end of the
mongod.log file with the
Step 4. Verifying Startup:
Because a database-driven application cannot function without a database, we’ll make sure that the MongoDB daemon,
mongod, will start with the system.
systemctl utility to check its startup status:
systemctl is-enabled mongod; echo
output of zero confirms an enabled daemon, which we want. A one, however, confirms a disabled daemon that will not start.
. . . enabled 0
In the event of a disabled daemon, use the
systemctl utility to enable it:
systemctl enable mongod
Summary List of Status Statistics (Continuous)
Summary List of Status Statistics (5 Rows, Summarized Every 2 Seconds):
mongostat --rowcount 5 2
Enter the MongoDB Command Line:
By default, running this command will look for a MongoDB server listening on port 27017 on the localhost interface.
If you’d like to connect to a MongoDB server running on a different port, then use the –port option. For example, if you wanted to connect to a local MongoDB server listening on port 33333, then you’d issue the following command:
mongo --port 33333
My name is Shashank Shekhar. I am a Software Engineer, currently working in one of the leading web-hosting companies in India. I am having 2 years of experience in Linux Server Administration.
I love to work in Linux environment & love learning new things.
Powered by Facebook Comments