Created
January 25, 2024 09:59
-
-
Save hoangdh/ed3bc97127d597b89a04ac79ea3cb6ca to your computer and use it in GitHub Desktop.
Script to install mongodb on Ubuntu 22.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "vm.zone_reclaim_mode=0 | |
vm.swappiness=1 | |
vm.max_map_count=102400" >> /etc/sysctl.conf | |
sysctl -p /etc/sysctl.conf | |
apt-get install gnupg curl -y | |
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb -P /tmp | |
dpkg -i /tmp/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb && rm /tmp/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb | |
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor | |
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list | |
apt update | |
apt-get install -y mongodb-org=6.0.12 \ | |
mongodb-org-server=6.0.12 \ | |
mongodb-org-shell=6.0.12 \ | |
mongodb-org-mongos=6.0.12 \ | |
mongodb-org-tools=6.0.12 | |
cat > /etc/systemd/system/disable-transparent-huge-pages.service < EOF | |
[Unit] | |
Description=Disable Transparent Huge Pages (THP) | |
DefaultDependencies=no | |
After=sysinit.target local-fs.target | |
Before=mongod.service | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null' | |
[Install] | |
WantedBy=basic.target | |
EOF | |
systemctl daemon-reload | |
systemctl start disable-transparent-huge-pages | |
systemctl enable disable-transparent-huge-pages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment