一.依赖和环境
centos7.2,4核cpu, 8G内存 100G硬盘
版本:3.4.7社区版本
端口:27017
数据目录:/usr/local/mongodb/data/mongodb
配置文件:/usr/local/mongodb/data/mongodb.conf
二.部署
1.下载3.4.7版本wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.7.tgz?_ga=2.27332668.129100306.1533718841-1981701661.1533718841
2.改名并移动mv mongodb-* mongodb.tgz
tar -xf mongodb.tgz
mv mongodb-linux-x86_64-rhel70-3.4.7 /usr/lcoal/mongodb
chmod +x /usr/local/mongodb/bin/*
3.添加环境变量vim /etc/profile
export PATH=/usr/local/mongodb/bin:$PATH
source/etc/profile
4.创建数据目录和日志目录cd /usr/local/mongodb/
mkdir -p data/mongodb
mkdir -p data/logs
5.编写配置文件vim data/mongodb.conf
bind_ip = 192.168.146.38
port = 27017
#后台运行
fork = true
## 数据目录
dbpath=/usr/local/mongodb/data/mongodb
## 日志路径
logpath=/usr/local/mongodb/data/logs/mongod.log
## is log Rotate mongoDB 3.0
logappend = true
#logRotate = true
## 开启日志
journal = true
## 使用小文件进行开发
smallfiles = true
三.启动和测试
1.启动mongod --config /usr/local/mongodb/data/mongodb.conf
2.显示如下正确
about to fork child process, waiting until server is ready for connections.
forked process: 17802
child process started successfully, parent exiting
3.查看进程netstat -unltp | grep mongo