1、 下载MongoDB
cd /opt/
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.2.tgz
2、 解压到/usr/local,修改目录名为mongodb
tar -xf mongodb-linux-x86_64-rhel70-4.4.2.tgz -C /usr/local/mongodb
3、 创建3个文件夹,data log conf
cd /usr/local/mongodb
mkdir data log conf
4、 新建配置文件mongod.conf,需要配置日志文件路径,数据文件路径
cd conf
vim mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /usr/local/mongodb/log/mongod.log
# Where and how to store data.
storage:
dbPath: /usr/local/mongodb/data
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
5、 创建pid目录
mkdir -p /var/run/mongodb
6、 启动mongodb
cd /usr/local/mongodb/bin/
./mongod -f ../conf/mongod.conf
mongo是客户端
mongod是服务端
mogos是路由
启动成功
如果有报错,查看日志文件 /usr/local/mongodb/log/mongod.log