Install MongoDB Community Edition on Ubuntu

Overview

Use this tutorial to install MongoDB Community Edition on LTS Ubuntu Linux systems from .deb packages. While Ubuntu includes its own MongoDB packages, the official MongoDB Community Edition packages are generally more up-to-date.

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 are not supported.

PACKAGE UPDATES REQUIRED ON UBUNTU 16.04 FOR IBM POWER SYSTEMS

Due to a lock elision bug present in older versions of the glibc package on Ubuntu 16.04 for POWER, you must upgrade the glibc package to at least glibc 2.23-0ubuntu5 before running MongoDB. Systems with older versions of the glibc package will experience database server crashes and misbehavior due to random memory corruption, and are 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 metapackage that will automatically install the four component packages listed below.
mongodb-org-server Contains the mongod daemon and associated configuration and init scripts.
mongodb-org-mongos Contains the mongos daemon.
mongodb-org-shell Contains the mongo shell.
mongodb-org-tools Contains the following MongoDB tools: mongoimport bsondumpmongodump,mongoexportmongofilesmongooplogmongoperfmongorestoremongostat, and mongotop.

The mongodb-org-server package provides an initialization script that starts mongod with the/etc/mongod.conf configuration file.

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

These packages conflict with the mongodbmongodb-server, and mongodb-clients packages provided by Ubuntu.

The default /etc/mongod.conf configuration file supplied by the packages have bind_ip set to127.0.0.1 by default. 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 are not supported.

1

Import the public key used by the package management system.

The Ubuntu package management tools (i.e. dpkg and apt) ensure package consistency and authenticity by requiring that distributors 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
2

Create a list file for MongoDB.

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

Ubuntu 12.04
Copy
echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
Ubuntu 14.04
Copy
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
Copy
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
3

Reload local package database.

Issue the following command to reload the local package database:

sudo apt-get update
4

Install 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 that a session may use. These limits may negatively impact MongoDB operation. See UNIX ulimit Settings for more information.

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodbby default, and runs using the mongodb user account. You can specify alternate log and data file directories in/etc/mongod.conf. See systemLog.path and storage.dbPath for additional information.

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

1

Start MongoDB.

Issue the following command to start mongod:

sudo service mongod start
2

Verify that MongoDB has started successfully

Verify that the mongod process has started successfully by checking the contents of the log file at/var/log/mongodb/mongod.log for a line reading

[initandlisten] waiting for connections on port <port>

where <port> is the port configured in /etc/mongod.conf27017 by default.

3

Stop MongoDB.

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

sudo service mongod stop
4

Restart MongoDB.

Issue the following command to restart mongod:

sudo service mongod restart
5

Begin using MongoDB.

To help you 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 Control+C in the terminal where the mongod instance 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 will completely remove MongoDB, its configuration, and all databases. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding.

1

Stop MongoDB.

Stop the mongod process by issuing the following command:

sudo service mongod stop
2

Remove Packages.

Remove any MongoDB packages that you had previously installed.

sudo apt-get purge mongodb-org*
3

Remove Data Directories.

Remove MongoDB databases and log files.

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

© MongoDB, Inc 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc

Install MongoDB Community Edition on Ubuntu的更多相关文章

  1. Install MongoDB on Windows

    Overview Use this tutorial to install MongoDB on a Windows systems. PLATFORM SUPPORT Starting in ver ...

  2. Install MongoDB on Windows (Windows下安装MongoDB)

    Install MongoDB on Windows Overview Use this tutorial to install MongoDB on a Windows systems. PLATF ...

  3. Install MongoDB driver for PHP on XAMPP for Mac OSX

    试了不少方法,最后还是这个最有效. [转自:http://thatsimplecode.com/install-mongodb-driver-for-php-on-xampp-for-mac-osx] ...

  4. Install MongoDB on Red Hat Enterprise, CentOS, Fedora, or Amazon Linux

    Install MongoDB on Red Hat Enterprise, CentOS, Fedora, or Amazon Linux¶ Overview Use this tutorial t ...

  5. Install Cocos2d-x v3.3 on Ubuntu 14.04 & Ubuntu 14.10(转)

    Install Cocos2d-x v3.3 on Ubuntu 14.04 & Ubuntu 14.10 1 get the source code sudo apt-get install ...

  6. installation - How to install Synaptic Package Manager? - Ask Ubuntu

    installation - How to install Synaptic Package Manager? - Ask Ubuntu How to install Synaptic Package ...

  7. sudo brew install mongodb报错

    报错信息如下: Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew ...

  8. Install Redis 3.2 on Ubuntu

    Install Redis 3.2 on Ubuntu It’s very easy to install Redis 3 on Ubuntu 16, just need to add PPA rep ...

  9. NLP--- How to install the tool NLTK in Ubuntu ?

    NLP--- How to install the tool NLTK in Ubuntu ? 1. open the website of NLTK and download it.  https: ...

随机推荐

  1. EasyDSS RTMP流媒体服务器中调用videojs播放rtmp视频显示在左上角问题

    本文转自EasyDarwin团队成员Penggy的博客:http://www.jianshu.com/p/f63f5b7c691b 问题描述: 近期我开发了一款新一代的RTMP/HLS流媒体服务器软件 ...

  2. [Linux] Boot分区满了的处理方法 The volume "boot" has only 0 bytes disk space remaining

    1.查看系统目前正在用的内核 abby@abby:~$ uname -r ..--generic 2.查看/boot保存的所有内核 abby@abby:~$ ls -lah /boot total 3 ...

  3. android Camera模块分析

    Android Camera Module Architecture and Bottom layer communication mechanism              ----------- ...

  4. HOG特征简述

    ---恢复内容开始--- 参考文献:http://blog.csdn.net/zouxy09/article/details/7929348 分为几步: 1)cell:有n×m个像素组成,计算每个像素 ...

  5. JavaScript库基本格式写法

    /********************************************************************* * JavaScript库基本格式写法 * 说明: * 由 ...

  6. java 实现共享锁和排它锁

    一直对多线程有恐惧,在实现共享锁和排它锁之后,感觉好了很多. 共享锁    就是查询的时候,如果没有修改,可以支持多线程查询: 排它锁    就是修改的时候,锁定共享锁,停止查询,同时,锁定排它锁,只 ...

  7. 微信网页登录Tips

    http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html 以这篇文章为例,一般都是用户在第三方app中登录时,由第三方去申请资源服务器的登录权限等.即 ...

  8. Vim:基础

    Normal模式 即是command “vim test.txt” 时进入的界面. 常用command: :help<Enter>   查看命令. :wq<Enter>     ...

  9. 隐居网V2.0

    经过一个月加班加点的努力,我们终于把隐居网V2.0版做好了(一个设计两个前端三个程序).上一版的隐居网因为经验不够底层架构没搭好(前台和后台都是),又是赶工期,导致后面越做越坑爹.所谓从哪里跌倒从哪里 ...

  10. WebStorm的下载与安装

    百度搜索: 链接:http://www.jetbrains.com/webstorm/ 链接:http://www.jetbrains.com/student/ 学生免费授权计划 请从正规来源下载软件 ...