在Ubuntu上安装Mongodb

Install MongoDB
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:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

2
Create a list file for MongoDB.

Create the /etc/apt/sources.list.d/mongodb-org-3.0.list list file using the following command:

echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.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.

You can install either the latest stable version of MongoDB or a specific version of MongoDB.
Install the latest stable version of MongoDB.

Issue the following command:

sudo apt-get install -y mongodb-org

提示:如果未成功,可把命令的-y去掉。 sudo apt-get install  mongodb-org

Install a specific release of MongoDB.

Specify each component package individually and append the version number to the package name, as in the following example:

sudo apt-get install -y mongodb-org=3.0.0 mongodb-org-server=3.0.0 mongodb-org-shell=3.0.0 mongodb-org-mongos=3.0.0 mongodb-org-tools=3.0.0

提示:如果未成功,可把命令的-y去掉。

sudo apt-get install mongodb-org=3.0.0 mongodb-org-server=3.0.0 mongodb-org-shell=3.0.0 mongodb-org-mongos=3.0.0 mongodb-org-tools=3.0.0

Pin a specific version of MongoDB.

Although you can specify any available version of MongoDB, apt-get will upgrade the packages when a newer version becomes available. To prevent unintended upgrades, pin the package. To pin the version of MongoDB at the currently installed version, issue the following command sequence:

echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections

Versions of the MongoDB packages before 2.6 use a different repo location. Refer to the version of the documentation appropriate for your MongoDB version.
Run MongoDB

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodb by 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.conf, 27017 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 begin using MongoDB, see Getting Started with MongoDB. Also consider the Production Notes document before deploying MongoDB in a production environment.

Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.

提示:

打开mongodb服务mongod,直接在在命令终端输入mongod即可。

打开mongodb客户端命令窗口mongo,直接在在命令终端输入mongo即可。

时间: 2024-11-12 11:49:43

在Ubuntu上安装Mongodb的相关文章

Ubuntu上安装MongoDB(译)

add by zhj:直接从第四步开始就可以了,而且安装好MongoDB后会自动启动的,不必自己去执行启动命令 原文:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ 一. 概述 通过这个教程,我们可以用.deb包在LTS Ubuntu上安装MongoDB社区版.虽然Ubuntu自己也有MongoDB包,但是官方的MongoDB社区版通常要更新一些. 注:平台支持 MongoDB只为64位 LTS Ubuntu

在Ubuntu Kylin15.05上安装MongoDB

在Ubuntu Kylin15.05上安装MongoDB MongoDB是典型的NoSQL,但是据说也有很多人在用它.于是我尝试一下在Ubuntu Kylin上安装一下这个数据库. 首先去它的官网看看吧.链接地址:https://www.mongodb.org,界面做得很不错的样子,而且也非常方便,很快就可以找到下载地址.看了一下官网,话说使用Ubuntu的LTS版会更加方便,不过我没有选择好,安装的是Ubuntu Kylin系统,因此不能简单地使用apt进行安装了.好在MongoDB官方有一个

在Ubuntu下安装mongodb

一. 在Ubuntu下最傻瓜的步骤(以下都在root用户下进行操作): 1.运行"apt-get install mongo" 如果遇到找不到安装包的话运行"apt-get update" 2.这时装好以后应该会自动运行mongod程序,通过"pgrep mongo -l "查看进程是否已经启动 3.在终端输入"mongo",然后回车进入数据库 (Over) 下面说下如何自己启动mongodb的程序. 二. 重启系统以后mon

在 RedHat Enterprise、CentOS 或 Fedora Linux 上安装 MongoDB

在 RedHat Enterprise.CentOS 或 Fedora Linux 上安装 MongoDB 1.大纲 ? 备注:采用yum安装后,所有进程将自动在/usr/bin下,如下的mongo.mongod.mongostat以后都可以直接cd /usr/bin之后直接使用. 该教程列出了在 RedHat Enterprise Linux.CentOS Linux.Fedora Linux 及相关系统上部署Mongodb的基本安装流程.该程序使用 .rpm 程序包作为安装基础.10gen

64位ubuntu上安装 hadoop-2.4.0

完全参考:http://blog.csdn.net/cruise_h/article/details/18709969 这上面的安装教程 伪分布配置: http://my.oschina.net/mynote/blog/93735 64位ubuntu上安装 hadoop-2.4.0,布布扣,bubuko.com

[异常解决] ubuntu上安装JLink驱动遇到的坑及给后来者的建议

一.前言 最近将整个电脑格式化,改成了linux操作系统 希望这样能让自己在一个新的世界探索技术.提升自己吧- win上的工具用多了,就不想变化了- 继上一篇<ubuntu上安装虚拟机遇到的问题(vmware坑了,virtual-box简单安装,在virtual-box中安装精简版win7)> link:http://www.cnblogs.com/zjutlitao/p/5061917.html 遇到的在ubuntu上装虚拟机坑之后,接下来又遇到了一个新的问题—— 如何在在ubuntu上安装

在ubuntu上安装maven

下载maven http://maven.apache.org/download.cgi 解压 用压缩管理器打开,解压至home目录下 配置环境变量 sudo gedit /etc/profile 添加 export M2_HOME=<span style="color:#ff0000;">/home/weibo/apache-maven-3.0.5(视自己的情况而定)</span> export M2=$M2_HOME/bin export PATH=$M2:

Ubuntu上安装QQ

作者:邹祁峰 邮箱:[email protected] 博客:http://blog.csdn.net/qifengzou 日期:2014.06.12 转载请注明来自"祁峰"的CSDN博客 自从腾讯QQ发布Linux QQ后,其他第三方均纷纷退出Linux版本QQ的开发和维护,而后腾讯QQ也停止了Linux QQ的开发和维护,致使目前Ubuntu上只能使用网页QQ. 而直接登陆网页QQ又使用户不能及时方便的获知对方的回复,目前可使用PIDGIN登陆QQ,能很好的解决网页QQ的这个缺点.

在Windows上安装MongoDB

原文官方文档:https://docs.mongodb.org/v2.6/tutorial/install-mongodb-on-windows/ 基于版本:MongoDB 2.6 概览 通过这个示例在Windows上安装MongoDB. 平台支持: 从2.2版本开始,MongoDB不支持Windows XP了,请使用最新版本的Windows使用较新的MongoDB的版本. 重要: 如果你使用的Windows Server 2008 R2的edition版本或者是Windows 7,请安装a h