enable mongodb oplog

necessary for query.observerChanges to work probably with changes to mongodb via a different client.
Otherwise some events are missing due to a fallback via polling, which leads to lost state updates in the meantime.

took me now 3 days to debug....  :'D
This commit is contained in:
chandi 2021-02-24 21:45:25 +01:00
parent 6905723d45
commit 61676a042d
4 changed files with 52 additions and 1 deletions

View File

@ -103,6 +103,13 @@ services:
mongodb: mongodb:
image: mongo:4.4 image: mongo:4.4
restart: unless-stopped restart: unless-stopped
volumes:
- ./mod/mongo/mongod.conf:/etc/mongod.conf
- ./mod/mongo/init-replica.sh:/docker-entrypoint-initdb.d/init-replica.sh
tmpfs:
- /data/configdb
- /data/db
command: mongod --config /etc/mongod.conf --oplogSize 8 --replSet rs0 --noauth
healthcheck: healthcheck:
test: bash -c "if mongo --eval 'quit(db.runCommand({ ping':' 1 }).ok ? 0 ':' 2)'; then exit 0; fi; exit 1;" test: bash -c "if mongo --eval 'quit(db.runCommand({ ping':' 1 }).ok ? 0 ':' 2)'; then exit 0; fi; exit 1;"
networks: networks:

View File

@ -2,7 +2,7 @@
set -e set -e
cd /app cd /app
# export MONGO_OPLOG_URL=mongodb://10.7.7.6/local export MONGO_OPLOG_URL=mongodb://10.7.7.6/local
export MONGO_URL=mongodb://10.7.7.6/meteor export MONGO_URL=mongodb://10.7.7.6/meteor
export NODE_ENV=production export NODE_ENV=production
export SERVER_WEBSOCKET_COMPRESSION=0 export SERVER_WEBSOCKET_COMPRESSION=0

16
mod/mongo/init-replica.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
set -e
host=${HOSTNAME:-$(hostname -f)}
# init replset with defaults
mongo local --eval "rs.initiate({
_id: 'rs0',
members: [ { _id: 0, host: '127.0.0.1:27017' } ]
})"
echo "Waiting to become a master"
echo 'while (!db.isMaster().ismaster) { sleep(100); }' | mongo
echo "I'm the master!"

28
mod/mongo/mongod.conf Normal file
View File

@ -0,0 +1,28 @@
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
storage:
dbPath: /data/db
journal:
enabled: true
wiredTiger:
engineConfig:
cacheSizeGB: 0
journalCompressor: none
directoryForIndexes: true
collectionConfig:
blockCompressor: none
indexConfig:
prefixCompression: false
net:
port: 27017
bindIp: 0.0.0.0
replication:
replSetName: rs0