1. 搭建 yum 源
如果安装epel扩展源,可以安装mongodb2.4版本,但这次我们要安装3.0版本,官方提供的源只支持64位系统
编辑 /etc/yum.repos.d/mongodb-org-3.0.repo
加入如下内容
1 2 3 4 5
| [mongodb-org-3.0] name=MongoDB Repository baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/ gpgcheck=0 enabled=1
|

2. 安装配置 MongoDB
安装很简单 yum install -y mongodb-org
编辑配置文件 /etc/mongod.conf
1 2
| fork: true pidFilePath: /var/run/mongodb/mongod.pid
|

把这两行后面#开头的注释删掉,否则重启的时候会有问题

要想绑定多个ip,在bind_ip 后写多个ip,中间用逗号分隔

监听全部ip留空即可

3. 启动 MongoDB
1 2
| [root@mongodb ~] Starting mongod: [确定]
|
1 2
| [root@mongodb ~] [root@mongodb ~]
|
编辑 /etc/security/limits.conf
加入
1 2 3 4
| mongod soft nofile 64000 mongod hard nofile 64000 mongod soft nproc 32000 mongod hard nproc 32000
|

启动:service mongod start
1 2 3
| [root@mongodb ~] Stopping mongod: [确定] Starting mongod: [确定]
|
启动的过程会比较慢,这是它在写数据 /var/lib/mongo