[root@mongodb-01 ~]# cat /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: /u01/mongoDB/helloWorld
journal:
enabled: true
engine: wiredTiger
wiredTiger:
engineConfig:
journalCompressor: snappy
cacheSizeGB: 1.5 // Adjust base on physical resource
collectionConfig:
blockCompressor: snappy
# how the process runs - Controls how MongoDB is managed as a system process.
processManagement:
fork: true # Enable MongoDB to run as a background daemon.
pidFilePath: /var/run/mongodb/mongod.pid # Location of the PID file when running as a service.
timeZoneInfo: /usr/share/zoneinfo
# network interfaces - Controls network access to the MongoDB instance
net:
port: 27017
bindIp: mongodb-01,mongodb-02,mongodb-03 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting. No space after each comas.
maxIncomingConnections: 1000 # Limit the number of incoming connections.
#security:
# identify slow queries and performance bottlenecks
operationProfiling:
mode: slowOp # Profiling mode: 'off`', 'slowOp', or 'all'.
slowOpThresholdMs: 100 # Threshold (in milliseconds) for logging slow operations.
# Configures the MongoDB instance for replication
replication:
replSetName: "rs0" # Name of the replica set (comment out for standalone instances).
oplogSizeMB: 1024 # Size of the oplog in MB.
# Sharding distributes data across multiple servers for horizontal scaling
sharding:
clusterRole: shardsvr
# Captures security-related events for auditing and compliance purposes
auditLog:
destination: file # Specifies audit log destination.
path: /var/log/mongodb/audit.log # Location of the audit log file.
format: JSON # Format of the audit log, typically JSON.
filter: { atype: { $in: ["authCheck"] } } # Filter to log only specific events (e.g., authentication checks).
Note: Using db.adminCommand to setting parameters temporary.
Ref: