Skip to content

Instantly share code, notes, and snippets.

@kennwhite
Last active December 21, 2022 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennwhite/2a0eb0adbe6d591dced8efdc3ad6c498 to your computer and use it in GitHub Desktop.
Save kennwhite/2a0eb0adbe6d591dced8efdc3ad6c498 to your computer and use it in GitHub Desktop.
Set Ubuntu 20.04 mongodb recommended ulimits
# ulimit -a
# sudo sysctl net.ipv4.tcp_fastopen=3
# sudo sysctl vm.max_map_count=524288
# note: "-l" (max locked memory) has no soft limit
# apt-get install numactl
sudo sh -c "sysctl -w net.ipv4.tcp_fastopen=3 ; \
sysctl -w vm.max_map_count=524288 ; \
ulimit -l unlimited ; \
ulimit -S -v unlimited ; \
sudo -u ubuntu /bin/bash -c '\
ulimit -S -f unlimited; \
ulimit -S -t unlimited; \
ulimit -S -n 64000; \
ulimit -S -m 65536; \
numactl --interleave=all ./bin/mongod \
--replSet rs0 --dbpath ./dbfiles \
--bind_ip 0.0.0.0 \
-port 27017 \
--logpath ./dblogs/mongod.log 2>&1 &'"
sleep 5 && echo "rs.initiate()" | mongosh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment