Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Created March 13, 2019 21:44
Show Gist options
  • Save khaosdoctor/05866b759f0476c8a827776922d5ca02 to your computer and use it in GitHub Desktop.
Save khaosdoctor/05866b759f0476c8a827776922d5ca02 to your computer and use it in GitHub Desktop.
Enables swap so MySQL databases stop shutting down when using digital ocean droplets
#!/bin/bash
rm -rf /swapfile
sudo fallocate -l 4G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
free -m
echo "/swapfile none swap sw 0 0" >> /etc/fstab
sudo sysctl vm.swappiness=10
sudo sysctl vm.vfs_cache_pressure=50
echo "vm.swappiness=10" >> /etc/sysctl.conf
echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf
echo "Restarting Mysql"
sudo /etc/init.d/mysql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment