sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6



Install MongoDB Community Edition on Ubuntu

On this page

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

Overview

Use this tutorial to install MongoDB Community Edition on LTS Ubuntu Linux systems from.debpackages. 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 theglibcpackage on Ubuntu 16.04 for POWER,you must upgrade theglibcpackage to at leastglibc2.23-0ubuntu5before running MongoDB. Systems with older versions of theglibcpackage 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 AMetapackagethat will automatically 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 themongoshell.
mongodb-org-tools Contains the following MongoDB tools:mongoimportbsondump,mongodump,mongoexport,mongofiles,mongooplog,mongoperf,mongorestore,mongostat,andmongotop.

Themongodb-org-serverpackage provides an initialization script that startsmongodwith the/etc/mongod.confconfiguration file.

SeeRun MongoDB Community Editionfor details on using this initialization script.

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

The default/etc/mongod.confconfiguration file supplied by the packages havebind_ipset to127.0.0.1by default. Modify this setting as needed for your environment before initializing areplica set.

Install MongoDB Community Edition
NOTE

To install a different version of MongoDB,please refer to that version’s documentation. For example,see version3.2.

MongoDB only provides packages for 64-bit LTS (long-term support) Ubuntu releases. For example,they are not supported.

1

Import 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 distributors sign packages with GPG keys. Issue the following command to import theMongoDB public GPG Key:

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.listlist file using the command appropriate for your version of Ubuntu:

Ubuntu 12.04
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
Ubuntu 16.04
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. SeeUNIX ulimit Settingsfor more information.

The MongoDB instance stores its data files in/var/lib/mongodband its log files in/var/log/mongodbby default,and runs using themongodbuser account. You can specify alternate log and data file directories in/etc/mongod.conf. SeesystemLog.pathandstorage.dbPathfor additional information.

If you change the user that runs the MongoDB process,youmustmodify the access control rights to the/var/lib/mongodband/var/log/mongodbdirectories to give this user access to these directories.

1

Start MongoDB.

Issue the following command to startmongod:

sudo service mongod start
2

Verify that MongoDB has started successfully

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

[initandlisten] waiting for connections on port <port>

where<port>is the port configured in/etc/mongod.conf,0)">27017by default.

3

Stop MongoDB.

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

sudo service mongod stop
4

Restart MongoDB.

Issue the following command to restartsudo service mongod restart

5

Begin using MongoDB.

To help you start using MongoDB,MongoDB providesGetting Started Guidesin varIoUs driver editions. SeeGetting Startedfor the available editions.

Before deploying MongoDB in a production environment,consider theProduction Notesdocument.

Later,to stop MongoDB,pressControl+Cin the terminal 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 willcompletelyremove MongoDB,its configuration,andalldatabases. This process is not reversible,so ensure that all of your configuration and data is backed up before proceeding.

1

Stop MongoDB.

Stop the 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

ubuntu 安装 mongodb 3的更多相关文章

  1. Swift 如何访问 MongoDB

    Perfect开源项目参与Perfect开发Slack在线协同MongoDBMongoDB库函数是在mongo-c语言库的基础上封装而成,能够为Swift轻松访问MongoDB服务器提供便利。请确保安装并激活了最新版本的Swift3.0toolchain。注意每次向项目追加依存关系时,必须要打开Swift软件包管理器重新创建一个新的Xcode项目文件。在您的项目中声明MongoDB请在您的Perfect项目源程序开头声明并导入MongoDB函数库:创建一个MongoDB数据库连接创建到MongoDB服务器

  2. TP5(thinkPHP5)框架mongodb扩展安装及特殊操作示例

    这篇文章主要介绍了TP5(thinkPHP5)框架mongodb扩展安装及特殊操作,结合实例形式分析了MongoDB扩展的基本安装、配置、模型操作以及使用Push操作实现的数据添加、更新等方法,需要的朋友可以参考下

  3. Node.js和MongoDB实现简单日志分析系统

    这篇文章主要介绍了Node.js和MongoDB实现简单日志分析系统,本文给出了服务器端、客户端、图表生成、Shell自动执行等功能的实现代码,需要的朋友可以参考下

  4. Laravel框架中集成MongoDB和使用详解

    今天小编就为大家分享一篇Laravel框架中集成MongoDB和使用详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

  5. Node.js中使用mongoskin操作mongoDB实例

    这篇文章主要介绍了Node.js中使用mongoskin操作mongoDB实例,Mongous是一个轻量级的nodejs mongodb驱动,需要的朋友可以参考下

  6. Node.js中使用mongoose操作mongodb数据库的方法

    如何利用mongoose将数据写入mongodb数据库呢?操作方法很简单,下面小编给大家分享Node.js中使用mongoose操作mongodb数据库的方法,感兴趣的朋友一起看看吧

  7. php如何利用pecl安装mongodb扩展详解

    这篇文章主要给大家介绍了关于php如何利用pecl安装mongodb扩展的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

  8. SpringBoot MongoDB详细使用教程

    这篇文章主要介绍了SpringBoot整合Mongodb实现简单的增删查改,MongoDB是一个以分布式数据库为核心的数据库,因此高可用性、横向扩展和地理分布是内置的,并且易于使用。况且,MongoDB是免费的,开源的,感兴趣的朋友跟随小编一起看看吧

  9. CentOS上安装Node.js和mongodb笔记

    这篇文章主要介绍了CentOS上安装Node.js和mongodb笔记,本文讲解了Python安装、Node.js安装、npm安装、mongodb驱动安装、mongodb数据库操作测试代码等内容,需要的朋友可以参考下

  10. php7安装mongoDB扩展的方法分析

    这篇文章主要介绍了php7安装mongoDB扩展的方法,简单分析了php7安装MongoDB扩展的步骤与相关配置操作技巧,需要的朋友可以参考下

随机推荐

  1. crontab发送一个月份的电子邮件

    ubuntu14.04邮件服务器:Postfixroot收到来自crontab的十几封电子邮件.这些邮件包含PHP警告.>我已经解决了这些警告的原因.>我已修复每个cronjobs不发送电子邮件(输出发送到>/dev/null2>&1)>我删除了之前的所有电子邮件/var/mail/root/var/spool/mail/root但我仍然每小时收到十几封电子邮件.这些电子邮件来自cronjobs,

  2. 模拟两个ubuntu服务器计算机之间的慢速连接

    我想模拟以下场景:假设我有4台ubuntu服务器机器A,B,C和D.我想在机器A和机器C之间减少20%的网络带宽,在A和B之间减少10%.使用网络模拟/限制工具来做到这一点?

  3. ubuntu-12.04 – 如何在ubuntu 12.04中卸载从源安装的redis?

    我从源代码在Ubuntu12.04上安装了redis-server.但在某些时候它无法完全安装,最后一次makeinstallcmd失败.然后我刚刚通过apt包安装.现在我很困惑哪个安装正在运行哪个conf文件?实际上我想卸载/删除通过源安装的所有内容,只是想安装一个包.转到源代码树并尝试以下命令:如果这不起作用,您可以列出软件自行安装所需的步骤:

  4. ubuntu – “apt-get source”无法找到包但“apt-get install”和“apt-get cache”可以找到它

    我正在尝试下载软件包的源代码,但是当我运行时它无法找到.但是当我运行apt-cache搜索squid3时,它会找到它.它也适用于apt-getinstallsquid3.我使用的是Ubuntu11.04服务器,这是我的/etc/apt/sources.list我已经多次更新了.我尝试了很多不同的debs,并没有发现任何其他地方的错误.这里的问题是你的二进制包(deb)与你的源包(deb-src)不

  5. ubuntu – 有没有办法检测nginx何时完成正常关闭?

    &&touchrestarted),因为即使Nginx没有完成其关闭,touch命令也会立即执行.有没有好办法呢?这样的事情怎么样?因此,pgrep将查找任何Nginx进程,而while循环将让它坐在那里直到它们全部消失.你可以改变一些有用的东西,比如睡1;/etc/init.d/Nginx停止,以便它会休眠一秒钟,然后尝试使用init.d脚本停止Nginx.你也可以在某处放置一个计数器,这样你就可以在需要太长时间时发出轰击信号.

  6. ubuntu – 如何将所有外发电子邮件从postfix重定向到单个地址进行测试

    我正在为基于Web的应用程序设置测试服务器,该应用程序发送一些电子邮件通知.有时候测试是使用真实的客户数据进行的,因此我需要保证服务器在我们测试时无法向真实客户发送电子邮件.我想要的是配置postfix,以便它接收任何外发电子邮件并将其重定向到一个电子邮件地址,而不是传递到真正的目的地.我正在运行ubuntu服务器9.10.先感谢您设置本地用户以接收所有被困邮件:你需要在main.cf中添加:然后

  7. ubuntu – vagrant无法连接到虚拟框

    当我使用基本的Vagrantfile,只配置了两条线:我看到我的虚拟框打开,但是我的流氓日志多次显示此行直到超时:然后,超时后的一段时间,虚拟框框终于要求我登录,但是太久了!所以我用流氓/流氓记录.然后在我的物理机器上,如果我“流氓ssh”.没有事情发生,直到:怎么了?

  8. ubuntu – Nginx – 转发HTTP AUTH – 用户?

    我和Nginx和Jenkins有些麻烦.我尝试使用Nginx作为Jenkins实例的反向代理,使用HTTP基本身份验证.它到目前为止工作,但我不知道如何传递带有AUTH用户名的标头?}尝试将此指令添加到您的位置块

  9. Debian / Ubuntu – 删除后如何恢复/ var / cache / apt结构?

    我在ubuntu服务器上的空间不足,所以我做了这个命令以节省空间但是现在在尝试使用apt时,我会收到以下错误:等等显然我删除了一些目录结构.有没有办法做apt-getrebuild-var-tree或类似的?

  10. 检查ubuntu上安装的rubygems版本?

    如何查看我的ubuntu盒子上安装的rubygems版本?只是一个想法,列出已安装的软件包和grep为ruby或宝石或其他:)dpkg–get-selections

返回
顶部