Viesturs Knopkens
Viesturs Knopkens

Reputation: 604

Mongo DB as service on Ubuntu

I installed MongoDB on Ubuntu 14.04 using this tutorial. Everything works fine, but how can I run it as service not only manualy?

To make it more clear: I want that MongoDB keeps running after I close "ssh shell".

Upvotes: 0

Views: 116

Answers (1)

Long Nguyen
Long Nguyen

Reputation: 11275

The easiest way is to install it via APT

Step 1: Import public key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

Step 2: Add the MongoDB repository details so APT

echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

Then update APT packages:

sudo apt-get update

Step 3: Installing and Verifying MongoDB

sudo apt-get install -y mongodb-org

Verify it status

service mongod status

It should show: mongod start/running, process 1611

You can also stop, start, and restart MongoDB using the service command (e.g. service mongod stop, server mongod start).

References: https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-14-04

Upvotes: 1

Related Questions