DEV Community

Roby Cigar
Roby Cigar

Posted on

Cara Install MongoDB di Ubuntu

Berikut ini langkah2 menginstall mongodb mengunakan sistem operasi linux dengan distro ubuntu versi 22.10

  1. Import public key
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
Enter fullscreen mode Exit fullscreen mode

Jalankan kode tersebut, maka akan memunculkan output bertuliskan OK

  1. Membuat file list
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
Enter fullscreen mode Exit fullscreen mode
  1. Reload package local
sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
  1. Install package mongoDB
sudo apt-get install -y mongodb-org
Enter fullscreen mode Exit fullscreen mode
  1. Start server mongodb
sudo systemctl daemon-reload
sudo systemctl start mongod
sudo systemctl status mongod
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

Jika anda mendapatkan error Process: 8724 ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf (code=exited, status=14)
masukkan perintah berikut.

chown -R mongodb:mongodb /var/lib/mongodb
chown mongodb:mongodb /tmp/mongodb-27017.sock

sudo service mongod restart
Enter fullscreen mode Exit fullscreen mode

Sumber:

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
https://askubuntu.com/questions/823288/mongodb-loads-but-breaks-returning-status-14

Discussion (0)