Skip to content

4. MongoDB

Fadhil Yori Hibatullah edited this page Mar 5, 2020 · 2 revisions

Back

Source : https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

  1. Import MongoDB Repository Key
$ wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
  1. Add MongoDB Ubuntu Repository
$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee -a /etc/apt/sources.list.d/mongodb-org-4.2.list
  1. Update APT index
$ sudo apt update
  1. Install MongoDB
$ sudo apt-get install mongodb-org
  1. Enable Mongo Service
$ sudo systemctl enable mongod.service
  1. Start Mongo Service
$ sudo systemctl start mongod.service
  1. Configuring MongoDB, edit /etc/mongod.conf file, change the following section like below:
net:
  port: 27017
  bindIp: 0.0.0.0
...
security:
  authorization: 'enabled'
...
replication:
  replSetName: rs0
  1. Restart Mongo Service
$ sudo systemctl restart mongod.service

Back