Ubuntu Üzerine Standalone MongoDB Kurulumu

Kübra Çetin Erkan
Turk Telekom Bulut Teknolojileri
2 min readDec 2, 2022

1- mongodb download sayfasından tgz indirilir.

https://www.mongodb.com/try/download/community

Eski release’leri aşağıdaki linkten bulabilirsiniz.

https://www.mongodb.com/download-center/community/releases/archive

Official installation dokümanı:

https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-ubuntu-tarball/

2- Bir klasör veya dizin oluşturmanız gerektiğinde mkdir komutu ile oluşturulur .

mkdir -p /mongodb/data/db
mkdir -p /mongodb/conf
mkdir -p /mongodb/log
mkdir -p /mongodb/binary

3- Tar’ın açılımı Tape archive’dir ve bir veya birden fazla dosya ve klasörlerin sıkıştırılması için kullanılır. mongodb-linux-x86_64-ubuntu2004–4.4.18.tgz sıkıştırıyoruz.

tar -zxvf mongodb-linux-x86_64-ubuntu2004–4.4.18.tgz

4- cp komutu dosya kopyalamaya yarar. /mongodb/binary/mongodb-linux-x86_64-ubuntu2004–4.4.18/bin/* ‘i /usr/local/bin/ di<ininin altına kopyalıyoruz.

cp /mongodb/binary/mongodb-linux-x86_64-ubuntu2004–4.4.18/bin/* /usr/local/bin/

5- mongod konfigürasyon dosyası oluşturulur.

# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /mongodb/log/mongod.log
# Where and how to store data.
storage:
dbPath: /mongodb/data/db
journal:
enabled: true
directoryPerDB: true
# engine:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /mongodb/conf/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27020
bindIp: 127.0.0.1, 10.131.6.38 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
#security:
#authorization: enabled
#keyFile: /data/mongodb/configs/rs-keyfile
#operationProfiling:
#replication:
#replSetName: rs01
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:

6- Mongod service dosyası oluşturulur.

vi /lib/systemd/system/mongod.service
[Unit]
Description=MongoDB Database Service
Wants=network.target
After=network.target
[Service]
Type=forking
PIDFile=/mongodb/conf/mongod.pid
ExecStart=/usr/local/bin/mongod -f /mongodb/conf/mongod.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
User=root
Group=root
StandardOutput=syslog
StandardError=syslog
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
[Install]
WantedBy=multi-user.target

7- Sistemi reload yapıyoruz.

systemctl daemon-reload

8-Mongod servisini başlatıyoruz.Aşağıdaki iki komutta kullanılabilir.

systemctl start mongod.service

ya da

mongod -f /mongodb/conf/mongod.conf

9- Service enable’a çekilir.

root@umbreon01map0:/lib/systemd/system# systemctl enable mongod.service

10- Servisler kontrol edilir.

root@umbreon01map0:/lib/systemd/system# systemctl status mongod.service
● mongod.service — MongoDB Database Service
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022–11–22 18:37:06 +03; 1min 27s ago
Process: 1189424 ExecStart=/usr/local/bin/mongod -f /mongodb/conf/mongod.conf (code=exited, status=0/SUCCESS)
Main PID: 1189426 (mongod)
Memory: 166.7M
CPU: 1.459s
CGroup: /system.slice/mongod.service
└─1189426 /usr/local/bin/mongod -f /mongodb/conf/mongod.conf
Nov 22 18:37:04 umbreon01map0 systemd[1]: Starting MongoDB Database Service…
Nov 22 18:37:04 umbreon01map0 mongod[1189424]: about to fork child process, waiting until server is ready for connections.
Nov 22 18:37:04 umbreon01map0 mongod[1189426]: forked process: 1189426
Nov 22 18:37:06 umbreon01map0 mongod[1189424]: child process started successfully, parent exiting
Nov 22 18:37:06 umbreon01map0 systemd[1]: Started MongoDB Database Service.

11-Mongo processlerinin çalışıp çalışmadığı bilgisi kontrol edilir.

root@umbreon01map0:/lib/systemd/system# ps -ef | grep mongo
root 1189426 1 1 18:37 ? 00:00:01 /usr/local/bin/mongod -f /mongodb/conf/mongod.conf
root 1189487 1187070 0 18:38 pts/9 00:00:00 grep mongo

Teşekkürler..

--

--