安装
源码安装:
wget -c https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.19.tgz
tar xzf mongodb-linux-x86_64-3.4.19.tgz
mv mongodb-linux-x86_64-3.4.19 /usr/local/mongodb
使用 vi/etc/profile.d/mongodb.sh
命令添加全局变量:
exportPATH=$PATH:/usr/local/mongodb/bin
配置
创建数据库文件夹
mkdir -p /data/mongo
创建日志目录
mkdir -p /var/log/mongodb
创建配置文件
vi /etc/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: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /data/mongo
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: 17017
bindIp: 0.0.0.0 # Listen to local interface only, comment to listen on all interfaces.
#security:
# authorization: enabled
#operationProfiling:
#replication:
# replSetName:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp: