How to install mongoDB on Ubuntu

Ubuntu上如何安装mongodb数据库(How to install mongoDB on Ubuntu)

Published: May 19, 2011 , Updated: May 19, 2011 , Author: mkyong

下文将会介绍如何安装mongodb 在你的ubuntu11.10

步骤总结:

  1. 在你的source.list添加10个gen包 (Add 10gen package to source.list)
  2. 升级系统的包(Update package)用sudo apt-get update
  3. 添加GPG密钥(Add GPG Key)
  4. 安装mongodb-10gen
  5. 完事
1. Add 10gen package to source.list

The 10gen package contains the latest mongoDB version, append below line to the end of the file “/etc/apt/sources.list

deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

For example, you can vim the “source.list” and append the 10gen package like this :

$ sudo vim /etc/apt/sources.list

File : /etc/apt/sources.list

#...content omitted ...
 
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu natty main
deb-src http://extras.ubuntu.com/ubuntu natty main
 
#mongo repo ###############new line
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
2. Update package

Update the modified “/etc/apt/sources.list” :

sudo apt-get update

Now, a new “mongodb-10gen – An object/document-oriented database” is available for install.

3. Add GPG Key

10gen package required GPG key, import it :

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
4. Install mongodb-10gen

Everything is ready, now you can Install the mongoDB package :

sudo apt-get install mongodb-10gen
5. Post-Installation

Now, mongoDB is installed, started, and auto start mongoDB script is generated to “/etc/init/mongo” and “/etc/init.d/mongo“. In addition, all mongoDB files are copied to “/usr/bin” folder.

The main configuration file “mongodb.conf” is located at “/etc/mongodb.conf“, change the values to customize your mongoDB server.

File : mongodb.conf

 
# mongodb.conf
 
# Where to store the data.
 
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
 
#where to log
logpath=/var/log/mongodb/mongodb.log
 
logappend=true
 
#port = 27017
#......
6. Verification

To verify it, just connect it with “mongo

$ mongo
MongoDB shell version: 1.8.1
connecting to: test
>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值