Embracing MongoDB on CentOS 7
In the realm of modern databases, MongoDB stands tall as a champion of flexibility, scalability, and speed. If you’re venturing into the enchanting realm of CentOS 7 and seeking the elixir of MongoDB, fret not! This guide shall illuminate your path, unveiling the steps to summon this powerful NoSQL database into your CentOS 7 domain. Brace yourself as we embark on a journey, unraveling the intricacies of MongoDB installation on this venerable operating system.
Preparing the Terrain:
Update and Repository Setup
Before commencing our MongoDB quest, preparation is key. To ensure a smooth installation, we’ll first navigate the landscape of CentOS 7, updating its repositories and preparing the stage for the MongoDB installation ritual. Employ the mighty command line and update the system with the following command:
sudo yum update -y
Now that the system is abreast with the latest updates, it’s time to lay the foundation for MongoDB. Forge ahead by creating a repository file for MongoDB:
sudo vi /etc/yum.repos.d/mongodb-org.repo
Within this file, inscribe the sacred incantations that beckon MongoDB to CentOS 7:
[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc
Summoning MongoDB:
Installation Ritual
With the stage set, it’s time to invoke MongoDB into the CentOS 7 realm. Execute the following commands with reverence to initiate the installation ritual:
sudo yum install -y mongodb-org
As the echoes of commands reverberate through the terminal, watch in awe as MongoDB descends from the digital heavens and manifests within your system. With each package and dependency seamlessly installed, the MongoDB daemon comes to life, ready to heed your beck and call.
Commanding the Oracle:
MongoDB Service Controls
Now that MongoDB graces your CentOS 7 abode, mastery over its essence beckons. To command this oracle, navigate the ethereal realms of service controls. Enthralled, issue the following commands to harness MongoDB’s power:
Start MongoDB:
sudo systemctl start mongod
Enable MongoDB to launch at system boot:
sudo systemctl enable mongod
Unleash the mighty status command to ascertain MongoDB’s state:
sudo systemctl status mongod
Marvel at the status report, affirming MongoDB’s allegiance to your commands. The daemon whispers tales of its uptime, revealing its connection status with the threads of your CentOS 7 tapestry.
Fortifying the Citadel:
Firewall Configuration
Amidst this digital sanctum, fortification is paramount. We shield MongoDB from malevolent intruders by fortifying the citadel with firewall configurations. Embrace the flames of security with the following commands:
sudo firewall-cmd --permanent --add-port=27017/tcp
sudo firewall-cmd --reload
Witness as the firewall acknowledges MongoDB’s presence, parting its gates solely for the designated port 27017. Safeguarded within this enclave, MongoDB awaits your beckoning, shielded from unwarranted access.
Embracing the Oracle:
Connecting to MongoDB
With MongoDB enshrined within CentOS 7, the moment arrives to forge a connection, to traverse the ethereal link between user and database. Invoke the MongoDB shell, the conduit to its realms, by employing the following invocation:
mongo
Behold, as the veil between mortal and database is lifted, granting access to MongoDB’s fathomless depths. Here, you wield commands, weave queries, and sculpt data with the finesse of a digital artisan.