Installing MongoDB under Ubuntu16.04lts

Source: Internet
Author: User
Tags gpg install mongodb

1. Installing MongoDB

First step: Import the public key used by the package management system

Ubuntu package management tools (i.e. dpkg , and apt ) ensure package consistency and authenticity by requiring the reseller to sign the package with GPG key. Issue the following command to import the MongoDB public GPG key:sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

Step Two: Create a list file for MongoDB

First, to determine the version of the Ubuntu system you are using, to view the current kernel version, open the terminal and type the uname -r command to view the kernel version:

View kernel version commands as follows:

[Email protected]:~$ uname-r
4.10.0-33-generic

Check whether the operating system is 32-bit or 64-bit:

[Email protected]:~$ sudo uname--m
x86_64

View Ubuntu version

[Email protected]:~$ sudo lsb_release-a
No LSB modules is available.
Distributor Id:ubuntu
Description:ubuntu 16.04.3 LTS
release:16.04
Codename:xenial

Create a list file using the commands that are appropriate for your Ubuntu version /etc/apt/sources.list.d/mongodb-org-3.4.list :

Ubuntu 14.04:

$ echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

Ubuntu 16.04:

$ echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

Step three: Reload the local package database

Issue the following command to reload the local package database:

sudo apt-get update

Fourth Step: Install MongoDB Package

Install the latest stable version of MongoDB. Issue the following command:

sudo apt-get install -y mongodb-org

2. Running MongoDB

The MongoDB instance defaults to storing its data file in /var/lib/mongodb its log file and /var/log/mongodb running with the MongoDB user account. You can /etc/mongod.conf specify the alternate log and data file directories in. For additional information, see Systemlog.path and Storage.dbpath.

If you change the user running the MongoDB process, you can modify /var/lib/mongodb and /var/log/mongodb access control permissions on the directory so that the user can access the directories.

Start MongoDB

Issue the following command to start MongoDB:

$ sudo service mongod start
Shell

Verify that MongoDB has started successfully

By checking /var/log/mongodb/mongod.log the contents of the log file in to verify that the Mongod process started successfully, there should be a line content similar to the following in the journal file-

Test with MongoDB command-


Stop MongoDB

Depending on your needs, you can stop the Mongod process by issuing the following command:

sudo service mongod stop

Restart MongoDB

Issue the following command to restart Mongod:

sudo service mongod restart
 

Installing MongoDB under Ubuntu16.04lts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.