配置文件1
# mongod.conf
systemLog:
destination: file
logAppend: true
storage:
journal:
enabled: true
directoryPerDB: true
engine: wiredTiger
wiredTiger:
engineConfig:
cacheSizeGB: 2
directoryForIndexes: true
indexConfig:
prefixCompression: true
processManagement:
fork: true
net:
port: 27017
目录介绍 /data/wyd/mongodb下的目录内容如下 backup(备份) log(日志) pid(pid文件) script shard-a-primary(数据库目录)
cacheSize是指系统分配给mongod用的内存,比如你系统有三十G内存,你可以分配二十四G内存给Mongodb
配置文件详细说明参考
启动
numactl --interleave=all mongod -f /etc/mongod.conf \
--dbpath /data/wyd03/mongodbard-a-primary \
--logpath /data/wyd03/mongodb/logard-a-primary.log \
--pidfilepath /data/wyd03/mongodb/pidard-a-primary.pid --port 27021
指定不一样的pid和端口这样就可以起启多个不一样的进程
线上配置文件二
dbpath=/data/mongodb/db
logpath=/data/mongodb/logs/mongodb.log
bind_ip=127.0.0.1
port=27017
fork=true
nohttpinterface=true
auth=true
启动 /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/conf/mongodb.conf
线上配置文件三
systemLog:
quiet: false
logAppend: true
destination: file
path: /data/mongodb/logs/mongod.log
storage:
dbPath: /data/mongodb/db
journal:
enabled: true
engine: wiredTiger
wiredTiger:
engineConfig:
cacheSizeGB: 16
indexConfig:
prefixCompression: true
processManagement:
fork: true
net:
bindIp: 127.0.0.1
port: 27017
security:
authorization: enabled