Setup
Stack config: https://github.com/one137/dockerhost-stacks/blob/main/stacks/50-mongodb.yml
Add ct-npm to 50-mongodb_internal network
Add a stream host to NPM, through the UI or:
curl -sX POST -H "Authorization: Bearer ${NPM_TOKEN}" -H "Content-Type:application/json" -d '{"incoming_port": 27017, "forwarding_port": 27017, "forwarding_host": "ct-mongodb", "tcp_forwarding": true, "udp_forwarding": true}' http://localhost:81/api/nginx/streams | jqConnect: mongosh mongodb://${ROOT_USERNAME}:${ROOT_PASSWORD}@mongodb.one137.dev
XFS
To use an XFS filesystem, see Format and mount a NAS iSCSI drive (XFS for Mongo)
Addressing Mongo warnings/optimizations
Connection warning can be suppressed by —quiet (mongosh --quiet mongodb://***:***@mongodb.one137.dev:27017).
Otherwise, to actually address them (probably only if Mongo lives in its own VM, and if high perf is needed):
sudo vim /etc/sysctl.confand addvm.max_map_count=1677720andvm.swappiness=1, thensudo sysctl -pto apply- Add following commands to
/etc/rc.localif available or create a custom systemd service for them to make them permanent, if needed (not tested):echo always | sudo tee /sys/kernel/mm/transparent_hugepage/enabledecho defer+madvise | sudo tee /sys/kernel/mm/transparent_hugepage/defragecho 0 | sudo tee /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none