Introduction

MongoDB is a popular NoSQL database that is designed for scalability and flexibility. It stores data in JSON-like documents, making it easy to work with and ideal for modern applications. This guide will walk you through the installation and usage of MongoDB on Rocky Linux 9, which can be effectively hosted on a Windows VPS UK for improved performance and reliability.

Prerequisites

  • A Rocky Linux 9 server with root access
  • Basic knowledge of Linux commands
  • An active internet connection

Step 1: Update Your System

Begin by updating your package index and upgrading existing packages:

sudo dnf update -y

Step 2: Add MongoDB Repository

Add the MongoDB repository to your system by creating a new repo file:

sudo nano /etc/yum.repos.d/mongodb-org-6.0.repo

Insert the following content into the file:

[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc

Save and close the file.

Step 3: Install MongoDB

Now, install MongoDB using the following command:

sudo dnf install -y mongodb-org

Step 4: Start and Enable MongoDB Service

Start the MongoDB service and enable it to run on boot:

sudo systemctl start mongod
sudo systemctl enable mongod

Check the status of the MongoDB service:

sudo systemctl status mongod

Step 5: Configure MongoDB (Optional)

You can configure MongoDB by editing the configuration file:

sudo nano /etc/mongod.conf

Make any necessary changes, such as setting up bind IP addresses, enabling authentication, or adjusting storage options.

Step 6: Using MongoDB

To access the MongoDB shell, run:

mongo

You can now start creating databases and collections. For example, to create a new database:

use myDatabase

To insert a document into a collection:

db.myCollection.insertOne({ name: "Example", value: 42 })

Step 7: Conclusion

You have successfully installed and configured MongoDB on Rocky Linux 9. This setup provides a powerful NoSQL database solution that can greatly benefit from being hosted on a Windows VPS. For additional options, explore various VPS UK Windows solutions, including Windows Virtual Private Server Hosting and Windows VPS Hosting UK for optimal database performance.

© 2024 MongoDB Installation Tutorial. All rights reserved.

Cette réponse était-elle pertinente? 0 Utilisateurs l'ont trouvée utile (0 Votes)