标签:
系统环境:Centos-7 64位
下载地址:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.5.tgz
上传位置:/usr/local/src
软件安装位置:/usr/local/mongodb
数据存放位置:/usr/local/mongodb/data
日志存放位置:/usr/local/mongodb/logs
安装
解压
[root@localhost /]# cd /usr/local/src
[root@localhost src]# tar -zxv -f mongodb-linux-x86_64-rhel70-3.2.5.tgz
[root@localhost src]# mv mongodb-linux-x86_64-rhel70-3.2.5.tgz /usr/local/mongodb
[root@localhost src]# cd /usr/local/mongodb
创建数据库目录和日志目录
[root@localhost mongodb]#mkdir -p /usr/local/mongodb/data
[root@localhost mongodb]#mkdir -p /usr/local/mongodb/logs
配置防火墙
# vi /etc/sysconfig/iptables
插入
-A INPUT -p tcp -m state --state NEW -m tcp --dport 27017 -j ACCEPT
# service iptables restart
启动mongodb
Mongodb的默认数据库目录是/data/db,改变目录需要在启动时添加路径配置
[root@localhost /]# cd /usr/local/mongodb
[root@localhost mongodb]# ./bin/mongod --dbpath=/usr/local/mongodb/data --logpath /usr/local/mongodb/logs/log.txt --logappend --fork
看到如下信息说明已经安装完成并成功启动:
about to fork child process, waiting until server is ready for connections. forked process: 35828 child process started successfully, parent exiting
停止mongodb
[root@localhost /]# cd /usr/local/mongodb
[root@localhost mongodb]# ./bin/mongod --shutdown --dbpath /usr/local/mongodb/data/
添加Centos开始启动项
[root@localhost src]# vi + /etc/rc.d/rc.local
将mongodb启动命令追加到本文件中:
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data –logpath
/usr/local/mongodb/logs/log.txt --logappend --fork
标签:
原文地址:http://www.cnblogs.com/lpush/p/5428695.html