安装MongoDB的方法有不少种,能够源代码安装,在Centos也能够用yum源安装的方法。因为MongoDB更新得比较快,我比较喜欢用yum源安装的方法。64位Centos下的安装步骤以下:mongodb
一、准备工做shell
运行yum命令查看MongoDB的包信息 [root@localhost~]# yum info mongo-10gen数据库
(提示没有相关匹配的信息,) 说明你的centos系统中的yum源不包含MongoDB的相关资源,因此要在使用yum命令安装MongoDB前须要增长yum源,也就是在 /etc/yum.repos.d/目录中增长 *.repo yum源配置文件centos
二、vi /etc/yum.repos.d/10gen.repo,输入下面的语句:安全
[10gen] 服务器
name=10gen Repository app
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64 ide
gpgcheck=0 工具
作好yum源的配置后,若是配置正确执行下面的命令即可以查询MongoDB相关的信息: this
查看mongoDB的服务器包的信息
[root@localhost geffzhang]# yum info mongo-10gen-server
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Installed Packages
Name : mongo-10gen-server
Arch : x86_64
Version : 2.0.6
Release : mongodb_1
Size : 13 M
Repo : installed
From repo : 10gen
Summary : mongo server, sharding server, and support scripts
URL : http://www.mongodb.org
License : AGPL 3.0
Description : Mongo (from "huMONGOus") is a schema-free document-oriented
: database.
:
: This package provides the mongo server software, mongo sharding
: server softwware, default configuration files, and init.d scripts.
查看客户端安装状况
[root@localhost geffzhang]#
* base: centos.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Installed Packages
Name : mongo-10gen
Arch : x86_64
Version : 2.0.6
Release : mongodb_1
Size : 69 M
Repo : installed
From repo : 10gen
Summary : mongo client shell and tools
URL : http://www.mongodb.org
License : AGPL 3.0
Description : Mongo (from "huMONGOus") is a schema-free document-oriented
: database. It features dynamic profileable queries, full indexing,
: replication and fail-over support, efficient storage of large
: binary data objects, and auto-sharding.
:
: This package provides the mongo shell, import/export tools, and
: other client utilities.
三、安装MongoDB的服务器端和客户端工具
[root@localhost geffzhang]# yum install mongo-10gen-server
[root@localhost geffzhang]# yum install mongo-10gen
四、启动Mongodb
service mongod start
之后有更新了,停掉mongodb,执行yum update mongo-10gen mongo-10gen-server 便可。
五、服务器配置: /etc/mongod.conf