Install and configure MongoDB in Ubuntu 16.04 LTS

Source: Internet
Author: User
Tags install mongodb mongodb query

Install and configure MongoDB in Ubuntu 16.04 LTS

MongoDB is a high-performance NoSQL database. Compared with relational databases, it also provides high performance and high flexibility. Here we will explain how to install and configure the MongoDB database on Ubuntu 16.04 LTS.

Add software source

Bkjia@bkjia.com ~ /$ Sudo apt-key adv -- keyserver hkp: // keyserver.ubuntu.com: 80 -- recv EA312927
[Sudo] password for bkjia:
Executing:/tmp. AasdNL9T70/gpg.1.sh -- keyserver
Hkp: // keyserver.ubuntu.com: 80
-- Recv
EA312927
Gpg: requesting key EA312927 from hkp server keyserver.ubuntu.com
Gpg: key EA312927: public key "MongoDB 3.2 Release Signing Key <packaging@mongodb.com>" imported
Gpg: Total number processed: 1
Gpg: imported: 1 (RSA: 1)

Bkjia@bkjia.com ~ $
Bkjia @ qwfys ~ $ Echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee/etc/apt/sources. list. d/mongodb-org-3.2.list
Deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse

Update local cache

Bkjia@bkjia.com ~ $ Apt update
Hit: 1 http://archive.ubuntukylin.com: 10006/ubuntukylin xenial InRelease
Ign: 2 http://mirrors.ustc.edu.cn/linuxmint sylvia InRelease
Hit: 3 http://mirrors.ustc.edu.cn/ubuntu xenial InRelease
Hit: 4 http://mirrors.ustc.edu.cn/ubuntu xenial-updates InRelease
Hit: 5 http://mirrors.ustc.edu.cn/ubuntu xenial-backports InRelease
Hit: 6 http://mirrors.ustc.edu.cn/linuxmint sylvia Release
Ign: 8 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 InRelease
Hit: 9 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial InRelease
Get: 10 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 Release [3,462 B]
Get: 11 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit: 12 http://archive.canonical.com/ubuntu xenial InRelease
Get: 13 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 Release. gpg [801 B]
Get: 14 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2/multiverse amd64 Packages [8,905 B]
Fetched 115 kB in 3 s (35.2 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

Query which packages can be installed

Bkjia@bkjia.com ~ $ Apt list | grep mongo

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Jmeter-mongodb/xenial, xenial 2.11-5 all
Juju-mongo-tools3.2/xenial 3.2.4 + ds-0ubuntu1 amd64
Juju-mongodb/xenial 2.4.10-0ubuntu6 amd64
Juju-mongodb2.6/xenial 2.6.10-0ubuntu1 amd64
Juju-mongodb3.2/xenial-updates 3.2.15-0ubuntu1 ~ 16.04.1 amd64
Libcatmandu-store-mongodb-perl/xenial, xenial 0.0403-1 all
Libmongo-client-dev/xenial 0.1.8-2 amd64
Libmongo-client-doc/xenial, xenial 0.1.8-2 all
Libmongo-client0/xenial 0.1.8-2 amd64
Libmongo-client0-dbg/xenial 0.1.8-2 amd64
Libmongoc-1.0-0/xenial 1.3.1-1 amd64
Lib1_c-dbg/xenial 1.3.1-1 amd64
Lib1_c-dev/xenial 1.3.1-1 amd64
Libmongoc-doc/xenial, xenial 1.3.1-1 all
Libmongodb-java/xenial, xenial 2.12.4-1 all
Libmongodb-perl/xenial 1.2.2-1 amd64
Libmongodbx-class-perl/xenial, xenial 1.030002-1 all
Mongodb/xenial. 6.10-0ubuntu1 amd64
Mongodb-clients/xenial. 6.10-0ubuntu1 amd64
Mongodb-org/xenial 3.2.18 amd64
Mongodb-org-mongos/xenial 3.2.18 amd64
Mongodb-org-server/xenial 3.2.18 amd64
Mongodb-org-shell/xenial 3.2.18 amd64
Mongodb-org-tools/xenial 3.2.18 amd64
Mongodb-server/xenial. 6.10-0ubuntu1 amd64
Php-mongodb/xenial 1.1.5-1 ~ Build1 amd64
Puppet-module-puppetlabs-mongodb/xenial, xenial 0.7.0-1 all
Python-runtime engine/xenial, xenial 0.10.6-1 all
Python-runtime engine-doc/xenial, xenial 0.10.6-1 all
Python-pymongo/xenial 3.2-1build1 amd64
Python-pymongo-doc/xenial, xenial 3.2-1build1 all
Python-pymongo-ext/xenial 3.2-1build1 amd64
Python3-mongoengine/xenial, xenial 0.10.6-1 all
Python3-pymongo/xenial 3.2-1build1 amd64
Python3-pymongo-ext/xenial 3.2-1build1 amd64
Ruby-em-mongo/xenial, xenial 0.5.1-1 all
Ruby-mongo/xenial, xenial 1.10.0-1 all
Syslog-ng-mod-mongodb/xenial 3.5.6-2.1 amd64

Install

Bkjia@bkjia.com ~ $ Apt install mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
Dconf-cli libclutter-imcontext-0.1-0 libclutter-imcontext-0.1-bin libibus-qt1 libpango1.0-0 libpangox-1.0-0
Use 'sudo apt autoremove 'to remove them.
The following additional packages will be installed:
Mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
Mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 51.7 MB of archives.
After this operation, 214 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get: 1 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2/multiverse amd64 mongodb-org-shell amd64 3.2.18 [5,275 kB]
Get: 2 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2/multiverse amd64 mongodb-org-server amd64 3.2.18 [10.0 MB]
Get: 3 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2/multiverse amd64 mongodb-org-mongos amd64 3.2.18 [4,675 kB]
Get: 4 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2/multiverse amd64 mongodb-org-tools amd64 3.2.18 [31.8 MB]
Get: 5 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2/multiverse amd64 mongodb-org amd64 3.2.18 [3,562 B]
Fetched 51.7 MB in 11 s (4,514 kB/s)
Selecting previusly unselected package mongodb-org-shell.
(Reading database... 236893 files and directories currently installed .)
Preparing to unpack.../mongodb-org-shell_3.2.18_amd64.deb...
Unpacking mongodb-org-shell (3.2.18 )...
Selecting previusly unselected package mongodb-org-server.
Preparing to unpack.../mongodb-org-server_3.2.18_amd64.deb...
Unpacking mongodb-org-server (3.2.18 )...
Selecting previusly unselected package mongodb-org-mongos.
Preparing to unpack.../mongodb-org-mongos_3.2.18_amd64.deb...
Unpacking mongodb-org-mongos (3.2.18 )...
Selecting previusly unselected package mongodb-org-tools.
Preparing to unpack.../mongodb-org-tools_3.2.18_amd64.deb...
Unpacking mongodb-org-tools (3.2.18 )...
Selecting previusly unselected package mongodb-org.
Preparing to unpack.../mongodb-org_3.2.18_amd64.deb...
Unpacking mongodb-org (3.2.18 )...
Processing triggers for man-db (2.7.5-1 )...
Setting up mongodb-org-shell (3.2.18 )...
Setting up mongodb-org-server (3.2.18 )...
Adding system user 'mongodb '(UID 124 )...
Adding new user 'mongodb '(UID 124) with group 'nogroup '...
Not creating home directory '/home/mongodb '.
Adding group 'mongodb '(GID 132 )...
Done.
Adding user 'mongodb 'to group 'mongodb '...
Adding user mongodb to group mongodb
Done.
Setting up mongodb-org-mongos (3.2.18 )...
Setting up mongodb-org-tools (3.2.18 )...
Setting up mongodb-org (3.2.18 )...

View service status

Bkjia@bkjia.com ~ $ Systemctl status mongodb
● Mongodb. service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Bkjia@bkjia.com ~ $ Sudo systemctl status mongod
● Mongod. service-High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/uplod. service; disabled; vendor preset: enabled)
Active: active (running) since Thu 11:43:16 CST; 2 h 13 min ago
Docs: https://docs.mongodb.org/manual
Main PID: 13494 (mongod)
CGroup:/system. slice/consumer D. service
Capacity-13494/usr/bin/release d -- quiet -- config/etc/release d. conf

Jan 18 11:43:16 bkjia.com systemd [1]: Started High-performance, schema-free document-oriented database.
Jan 18 13:56:35 bkjia.com systemd [1]: Started High-performance, schema-free document-oriented database.

Enable startup

Bkjia@bkjia.com ~ $ Sudo systemctl enable mongod
Created symlink from/etc/systemd/system/multi-user.target.wants/systd. service to/lib/systemd/system/systd. service.
Bkjia@bkjia.com ~ $

For more MongoDB tutorials, see the following:

Introduction to MongoDB documents, collections, and databases

MongoDB 3 shard deployment and Fault Simulation

Install MongoDB in CentOS 6.5 yum

Quick installation of MongoDB using CentOS 7 yum

MongoDB query operations

Quickly build MongoDB clusters on Azure virtual machines

Principles of MongoDB replica set

MongoDB 3.4 remote connection authentication failed

Install MongoDB3.4 database system in Ubuntu 16.04

MongoDB authoritative guide 2nd PDF complete with bookmarks directory download see

MongoDB details: click here
MongoDB: click here

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.