docs/Databases/MongoDB-Oplog-Configuration.md
MongoDB oplog is critical for WeKan's pub/sub performance. Without it, Meteor falls back to polling-based change detection, which causes:
WeKan uses Meteor's pub/sub system for real-time updates. Meteor uses MongoDB's oplog to:
Without oplog: Meteor polls every N milliseconds and compares full datasets With oplog: Meteor subscribes to change stream and receives instant notifications
Step 1: Enable MongoDB Replica Set
For MongoDB 4.0+, run:
# On Linux/Mac
mongosh
> rs.initiate()
> rs.status()
# Or with mongo (older versions)
mongo
> rs.initiate()
> rs.status()
Step 2: Configure MONGO_OPLOG_URL
In start-wekan.sh:
export MONGO_OPLOG_URL=mongodb://127.0.0.1:27017/local?replicaSet=rs0
In start-wekan.bat:
SET MONGO_OPLOG_URL=mongodb://127.0.0.1:27017/local?replicaSet=rs0
MongoDB service configuration:
mongodb:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- wekan-db:/data/db
command: mongod --replSet rs0
WeKan service environment:
wekan:
environment:
- MONGO_URL=mongodb://mongodb:27017/wekan
- MONGO_OPLOG_URL=mongodb://mongodb:27017/local?replicaSet=rs0
The Dockerfile now includes MONGO_OPLOG_URL in environment:
ENV MONGO_OPLOG_URL=""
Set at runtime:
docker run \
-e MONGO_OPLOG_URL=mongodb://mongodb:27017/local?replicaSet=rs0 \
wekan:latest
# Set oplog URL
sudo wekan.wekan-help | grep MONGO_OPLOG
# Configure
sudo snap set wekan MONGO_OPLOG_URL=mongodb://127.0.0.1:27017/local?replicaSet=rs0
For MongoDB Atlas (AWS, Azure, GCP):
MONGO_OPLOG_URL=mongodb://<username>:<password>@<cluster>.<region>.mongodb.net/local?authSource=admin&replicaSet=<replSetName>
Example:
MONGO_URL=mongodb+srv://user:[email protected]/wekan?retryWrites=true&w=majority
MONGO_OPLOG_URL=mongodb+srv://user:[email protected]/local?authSource=admin&replicaSet=atlas-replica-set
Check if oplog is working:
# Check MongoDB replica set status
mongosh
> rs.status()
# Check WeKan logs for oplog confirmation
grep -i oplog /path/to/wekan/logs
# Should show: "oplog enabled" or similar message
With oplog enabled, the following WeKan optimizations work at full potential:
These optimizations were designed assuming oplog is available. Without it, polling delays reduce their effectiveness.
rs.initiate() in MongoDBdb.getSiblingDB('local').oplog.rs.stats()