1. 下载解压安装包
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgztar -zxvf mongodb-linux-x86_64-rhel70-3.2.4.tgz
2. 移动到目标目录
mv -f mongodb-linux-x86_64-rhel70-3.2.4 /opt/mongodb
3. 增加profile配置
vim /etc/profile
export MONGODB_HOME=/opt/mongodbexport PATH=$PATH:$MONGODB_HOME/bin
刷新系统配置
source /etc/profile
4. mongodb启动配置
cd /opt/mongodb/binmkdir datacd datamkdir dbcd ../mkdir logscd logstouch mongodb.logcd ../vim mongodb.conf
dbpath = /opt/mongodb/data/db #数据文件存放目录logpath = /opt/mongodb/logs/mongodb.log #日志文件存放目录port = 27017 #端口fork = true #以守护程序的方式启用,即在后台运行nohttpinterface = true
5. 启动MongoDB
./mongod -f mongodb.conf
如果出现这个错误,可能是各个配置没有细心写, 写错了,或者权限问题
ERROR: child process failed, exited with error number 1
