在Debian系统下,MongoDB的配置文件通常是/etc/mongod.conf。其配置文件格式主要采用YAML格式,但也包含一些ini风格的配置选项。以下是配置文件的主要部分和示例:
storage
dbPath: 数据库存储路径,如/mongo_data/data。directoryPerDB: 每个数据库一个目录,默认为true。journal: 启用日志,默认为true。engine
wiredTiger: 使用WiredTiger存储引擎,配置如下:
where to write logging data: 日志数据写入路径,如/mongo_data/log/mongod.log。systemLog
destination: 日志目的地,可以是file。logAppend: 是否追加日志,默认为true。path: 日志文件路径,如/mongo_data/log/mongod.log。network
port: 监听端口,默认为27017。bindIp: 绑定的IP地址,如127.0.0.1,192.168.56.2。processManagement
timeZoneInfo: 时区信息路径,如/usr/share/zoneinfo。storage:
dbPath: /mongo_data/data
directoryPerDB: true
journal:
enabled: true
engine:
wiredTiger:
where to write logging data: /mongo_data/log/mongod.log
systemLog:
destination: file
logAppend: true
path: /mongo_data/log/mongod.log
network:
port: 27017
bindIp: 127.0.0.1,192.168.56.2
processManagement:
timeZoneInfo: /usr/share/zoneinfo
请注意,某些配置在MongoDB初始化后就不能修改,因此建议在初始化前配置好这些重要设置。