Install MongoDB Community Edition on Ubuntu

Source: Internet
Author: User
Tags gpg install mongodb mongodb


    • Install MongoDB >
    • Install MongoDB Community Edition >
    • Install MongoDB Community Edition on Linux >
    • Install MongoDB Community Edition on Ubuntu
Install MongoDB Community Edition on Ubuntu


On the This page


    • Overview
    • Packages
    • Install MongoDB Community Edition
    • Run MongoDB Community Edition
    • Uninstall MongoDB Community Edition
Overview


Use this tutorial to install the MongoDB Community Edition on the LTS Ubuntu Linux systems from.debpackages. While Ubuntu includes its own MongoDB packages, the official MongoDB Community Edition packages is generally more up-to-d Ate.



PLATFORM Support



MongoDB only provides packages for 64-bit LTS (long-term support) Ubuntu releases. For example, 12.04 lts (precise), 14.04 lts (trusty), 16.04 Lts (xenial), and so on. These packages may work with other Ubuntu releases, however, they is not supported.



Package UPDATES REQUIRED on UBUNTU 16.04 for IBM POWER SYSTEMS



Due to a lock elision bugs present in older versionsglibcof the "on Ubuntu 16.04 for POWER, you must upgrade the" c1/> package to at leastglibc 2.23-0ubuntu5before running MongoDB. Systems with older versions of the package wouldglibcexperience database server crashes and misbehavior due to random mem Ory corruption, and is unsuitable for production deployments of MongoDB


Packages


MongoDB provides officially supported packages in their own repository. This repository contains the following packages:


Package
Name Description
mongodb-org A that wouldmetapackageautomatically install the four component packages listed below.
mongodb-org-server Contains themongoddaemon and associated configuration and init scripts.
mongodb-org-mongos Contains themongosdaemon.
mongodb-org-shell Contains The mongo shell.
mongodb-org-tools Contains the following MongoDB tools: mongoimport bsondump,  mongodump,mongoexport,  mongofiles,  mongooplog,  mongoperf,  Mongorestore,  mongostat, and  mongotop.


The packagemongodb-org-serverprovides a initialization script that starts with themongod/etc/mongod.confconfiguration file.



See Run MongoDB Community Edition for details on using the this initialization script.



These packages conflict withmongodbthe,mongodb-server, andmongodb-clientspackages provided by Ubuntu.



The default/etc/mongod.confconfiguration file supplied by the packages hasbind_ipset to by127.0.0.1default. Modify This setting as needed for your environment before initializing a replica set.


Install MongoDB Community Edition


NOTE



To install a different version of MongoDB, please refer to that version ' s documentation. For example, see version 3.2.



MongoDB only provides packages for 64-bit LTS (long-term support) Ubuntu releases. For example, 12.04 lts (precise), 14.04 lts (trusty), 16.04 Lts (xenial), and so on. These packages may work with other Ubuntu releases, however, they is not supported.


1Import the public key used by the package management system.


The Ubuntu package management tools (i.e.dpkgandapt) Ensure package consistency and authenticity by requiring that D Istributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key:


Copy
sudo apt-key adv--keyserver hkp://keyserver.ubuntu.com:80--recv 0c49f3730359a14518585931bc711f9ba15703c6
2Create a list file for MongoDB.


Create the/etc/apt/sources.list.d/mongodb-org-3.4.listlist file using the command appropriate for your version of Ubuntu:


Ubuntu 12.04Copy
| sudo tee/etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 14.04Copy
| sudo tee/etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 16.04Copy
| sudo tee/etc/apt/sources.list.d/mongodb-org-3.4.list
3Reload Local Package database.


Issue the following command to reload the local package database:


sudo apt-get update
4Install the MongoDB packages. Install the latest stable version of MongoDB.


Issue the following command:


sudo apt-get install-y mongodb-org
Run MongoDB Community Edition


Most unix-like operating systems limit the system resources, a session may use. These limits may negatively impact MongoDB operation. See UNIX Ulimit Settings for more information.



The MongoDB instance stores their data files/var/lib/mongodbin and their log files/var/log/mongodbin by default, and runs using themongodbuser AC Count. You can specify alternate log and the data file directories in/etc/mongod.conf. See and forsystemLog.pathstorage.dbPathadditional information.



If you change the user of the runs the MongoDB process, you must modify the access control rights to the and/var/lib/mongodb/var/log/mongodbdire Ctories to give the user access to these directories.


1Start MongoDB.


Issue the following command to startmongod:


sudo service Mongod start
2Verify. MongoDB has started successfully


Verify that the process had started successfully by checking the contents of the "log file at for a" linemongod/var/log/mongodb/mongod.logReading


[Initandlisten] Waiting for connections on port <port>


Where<port>/etc/mongod.confis the port configured in, by27017default.


3Stop MongoDB.


As needed, you can stop themongodprocess by issuing the following command:


sudo service Mongod stop
4Restart MongoDB.


Issue The following command to restartmongod:


sudo service mongod restart
5Begin using MongoDB.


To the start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.



Before deploying MongoDB in a production environment, consider the production Notes document.



Later, to-stop MongoDB, press in theControl+Cterminal where themongodinstance is running.


Uninstall MongoDB Community Edition


To completely remove MongoDB from a system, you must remove the MongoDB applications themselves, the configuration files, and any directories containing data and logs. The following section guides you through the necessary steps.



WARNING



This process would completely remove MongoDB, its-configuration, and all databases. This process is not a reversible, so ensure the all of your configuration and data are backed up before proceeding.


1Stop MongoDB.


Stop themongodprocess by issuing the following command:


sudo service Mongod stop
2Remove Packages.


Remove any MongoDB packages so you had previously installed.


sudo apt-get purge mongodb-org*
3Remove Data directories.


Remove MongoDB databases and log files.


sudo rm-r/var/log/mongodbsudo rm-r/var/lib/mongodb
←install MongoDB Community Edition on Amazon linuxinstall MongoDB Community Edition on Debian →


? MongoDB, Inc. 2008-present. MongoDB, Mongo, and the leaf logo is registered trademarks of MongoDB, Inc.



Install MongoDB Community Edition on Ubuntu


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.