官方地址:http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat/
第一步:在 /etc/yum.repos.d/目录下创建mongodb-org-3.0.repo 文件(yum源)。
/etc/yum.repos.d/mongodb-org-3.0.repo
创建好文件后复制如下内容:
<span style="font-size:18px;">[mongodb-org-3.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.0/x86_64/
gpgcheck=0
enabled=1</span>
第二步安装:
sudo yum install -y mongodb-org
下面是安装完成后一些配置的说明,用户可以进行自定义。
<span style="font-size:18px;">The MongoDB instance stores its data files in /var/lib/mongo and its log files in /var/log/mongodb by default, and runs using the mongod 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/mongo and /var/log/mongodb directories to give this user access to these directories.</span>
其中mongodb的数据文件在:
<span style="font-size:18px;">/var/lib/mongo</span>
日志文件在:
<span style="font-size:18px;">/var/log/mongodb</span>
配置文件在:
<span style="font-size:18px;">/etc/mongod.conf</span>
最后启动MongoDb:
<span style="font-size:18px;">sudo service mongod start</span>
停止:
sudo service mongod stop
重启:
sudo service mongod restart
这里有一个特别需要注意的地方,就是远程连接需要配置
# Listen to local interface only. Comment out to listen on all interfaces.
bind_ip=0.0.0.0