1.1. 配置docker-compose.yml
mongod.conf内容如下,一般只需要修改wiredTiger.engineConfig.cacheSizeGB
,具体大小请查考官方文档
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /data/db
journal:
enabled: true
directoryPerDB: true
engine: wiredTiger
wiredTiger:
engineConfig:
cacheSizeGB: 8
directoryForIndexes: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#replication:
replication:
oplogSizeMB: 51200
replSetName: rs0
security:
authorization: disabled
#enabled
#disabled
创建文件夹用来持久化数据
# db存放数据库文件,log存放mongodb日志,config存放mongodb配置文件
mkdir db log co