Deployment Overview of MongoDB on Server¶
Prerequisites and Basic Requirements¶
The following requirements must be met before deploying MongoDB on the server:
-
Operating System: Ubuntu Jammy (22.04 LTS)
-
Architecture: AMD64 or ARM64
-
Privileges: Root access or a user with
sudoprivileges is required to install packages and manage services. -
Domain: The server operates within the
hostkey.inzone. -
Ports: The default port for MongoDB is 27017, which must be open for local or internal network access unless otherwise configured.
File and Directory Structure¶
MongoDB components are installed in the following locations:
-
Configuration Directory:
/etc/mongod.conf(Main configuration file) -
Data Directory:
/var/lib/mongo(Default location for database storage) -
Log Directory:
/var/log/mongodb(Location for log files) -
Lock File:
/var/lock/mongodb(Location for lock files) -
PID File:
/var/run/mongodb(Location for process ID files)
Application Installation Process¶
The application is installed using the native package manager for the Ubuntu distribution. The installation process includes the following steps:
-
System Update: The system packages are updated using the APT package manager.
-
Dependency Installation: Required tools such as
curl,gnupg,nano,vim,htop,net-tools, anddnsutilsare installed. -
Repository Setup:
-
The GPG key for MongoDB version
8.0is added to the system. -
A repository list file is created at
/etc/apt/sources.list.d/mongodb-org-8.0.listpointing to the official MongoDB repository forubuntu jammy.
-
-
Package Installation: The
mongodb-orgpackage is installed, which includes the MongoDB server (mongod) and client tools. -
Service Activation: The
mongodservice is started and enabled to launch automatically on system boot.
Access Rights and Security¶
Security measures are implemented as follows:
-
Service Management: The MongoDB service is managed via
systemd. -
Firewall: The configuration assumes that necessary ports are open for the MongoDB service. External access should be restricted to trusted networks.
-
Authentication: By default, MongoDB installations require explicit configuration to enable authentication. Ensure that user accounts are created and authentication is enabled in the configuration file before exposing the service to untrusted networks.
Databases¶
The database storage and connection settings are configured as follows:
-
Storage Location: Data is stored in the
/var/lib/mongodirectory. -
Connection Method: Connections are established via the TCP/IP protocol.
-
Default Bind Address: MongoDB typically binds to
127.0.0.1(localhost) by default, requiring local access unless thebindIpparameter is modified in the configuration file. -
Database Engine: The installation provides the standard MongoDB 8.0 engine.
Available Ports for Connection¶
The following port is utilized by the deployed MongoDB instance:
- 27017: Default port for the MongoDB service.
Starting, Stopping, and Updating¶
The MongoDB service is managed using systemd commands. Use the following commands to control the service:
-
Start the service:
-
Stop the service:
-
Restart the service:
-
Check service status:
-
Enable service on boot:
To update the MongoDB software to a newer patch version available in the repository, run: