Friday, December 27, 2024
Google search engine
HomeData Modelling & AIHow To Install MongoDB 4 on Debian 10 (Buster)

How To Install MongoDB 4 on Debian 10 (Buster)

How can I install MongoDB 4 on Debian 10 (Buster)?. MongoDB is an open source NoSQL database written in C++ for massive scalability, high performance, and availability. As of this article update, the repositories available are for Debian 9. We will add some hacks to Install MongoDB 4 on Debian 10 (Buster). But once the repository is available for Debian 10, this article will be updated.

Here are the steps you’ll need to Install MongoDB 4 on Debian 10 (Buster). I’m doing this setup on a fresh minimal installation of Debian 10 server. This is recommended to ensure you don’t break running applications dependencies.

Add MongoDB repository

Import MongoDB GPG Key

sudo apt update
sudo apt -y install gnupg2
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

Then add repository URL to your Debian system.

echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main" | sudo tee /etc/apt/sources.list.d/mongodb-org.list

Install MongoDB Server

We have added required repositories and installed libcurl3. Let’s now install MongoDB on Debian 10 (Stretch).

sudo apt update
sudo apt -y install mongodb-org

Get package information with apt info command.

$ apt info mongodb-org
Package: mongodb-org
Version: 4.4.24
Priority: optional
Section: database
Maintainer: MongoDB Packaging <[email protected]>
Installed-Size: 13.3 kB
....

The installation of the above package will install the following dependency packages:

mongodb-org-server – This provides MongoDB daemon mongod
mongodb-org-mongos – This is a MongoDB Shard daemon
mongodb-org-shell – This provides a shell to MongoDB
mongodb-org-tools – MongoDB tools used for export, dump, import e.t.c

Start MongoDB Server service

The server daemon is named mongod. Start and set it to start on server reboot/boot up.

sudo systemctl enable --now mongod

Check its running status.

$ systemctl status  mongod.service
 mongod.service - MongoDB Database Server
   Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2023-09-06 23:01:31 UTC; 21s ago
     Docs: https://docs.mongodb.org/manual
 Main PID: 2908 (mongod)
   Memory: 68.6M
   CGroup: /system.slice/mongod.service
           └─2908 /usr/bin/mongod --config /etc/mongod.conf

Sep 06 23:01:31 deb10 systemd[1]: Started MongoDB Database Server.
Sep 06 23:01:31 deb10 mongod[2908]: {"t":{"$date":"2023-09-06T23:01:31.358Z"},"s":"I",  "c":"CONTROL",  "id":7484500, "ctx":"main","msg":"Environment variable MONGODB_CONFIG_OVERRIDE_NOFORK == 1, ov

The service listens on localhost TCP port 27017 by default.

$ sudo ss -tunelp
Netid   State    Recv-Q   Send-Q     Local Address:Port        Peer Address:Port                                                                   
udp     UNCONN   0        0                0.0.0.0:68               0.0.0.0:*       users:(("dhclient",pid=440,fd=7)) ino:13373 sk:1 <->           
tcp     LISTEN   0        128            127.0.0.1:27017            0.0.0.0:*       users:(("mongod",pid=5939,fd=11)) uid:106 ino:35394 sk:2 <->   
tcp     LISTEN   0        128              0.0.0.0:22               0.0.0.0:*       users:(("sshd",pid=602,fd=3)) ino:14676 sk:3 <->               
tcp     LISTEN   0        128                 [::]:22                  [::]:*       users:(("sshd",pid=602,fd=4)) ino:14678 sk:4 v6only:1 <->

This setting can be altered on the /etc/mongod.conf file.

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

The IP 127.0.0.1 can be replaced with an IP address on the server’s network interface to bind to.

Restart mongod service if a change is made.

sudo systemctl restart mongod

To get to MongoDB shell, run:

$ mongo
MongoDB shell version 4.4.24
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("9a688b2e-251c-4951-b92b-28218c9a4154") }
MongoDB server version: 4.4.24
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
Server has startup warnings: 
2023-10-25T21:07:38.418+0000 I  STORAGE  [initandlisten] 
2023-10-25T21:07:38.418+0000 I  STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2023-10-25T21:07:38.418+0000 I  STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] 
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] 
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] 
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] **        We suggest setting it to 'never'
2023-10-25T21:07:38.907+0000 I  CONTROL  [initandlisten] 
---
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).

The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.

To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

> 

More reading:  How to configure MongoDB 4 authentication.

You have installed MongoDB 4 on Debian 10 successfully.

See other guides on installing MongoDB 4 on other systems:

RELATED ARTICLES

Most Popular

Recent Comments