Skip to content

Instantly share code, notes, and snippets.

@tmoreira2020
Created December 8, 2011 22:05
Show Gist options
  • Save tmoreira2020/1448865 to your computer and use it in GitHub Desktop.
Save tmoreira2020/1448865 to your computer and use it in GitHub Desktop.
Install a MySQL server on a XFS partition using yum.
#!/bin/sh
VOLUME=$1
if [ -z $VOLUME ]; then
echo "You must specify the volume, like /dev/sdf"
exit 1;
fi
if [ ! -b $VOLUME ]; then
echo "Could not find volume $VOLUME"
exit 1;
fi
echo "*** Installing MySQL (with no root password) ***"
sudo DEBIAN_FRONTEND=noninteractive yum install -y mysql-server
echo "*** Creating XFS filesystem and moving mysql configuration ***"
sudo yum install -y xfsprogs
grep -q xfs /proc/filesystems || sudo modprobe xfs
sudo mkfs.xfs $VOLUME
echo "$VOLUME /vol xfs noatime 0 0" | sudo tee -a /etc/fstab
sudo mkdir -p -m 000 /vol
sudo mount /vol
sudo /etc/init.d/mysqld stop
sudo mkdir -p /vol/etc /vol/lib /vol/log
sudo mv /etc/mysql /vol/etc/
sudo mv /var/lib/mysql /vol/lib/
sudo mv /var/log/mysql /vol/log/
sudo mkdir /etc/mysql
sudo mkdir /var/lib/mysql
sudo mkdir /var/log/mysql
echo "/vol/etc/mysql /etc/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /etc/mysql
echo "/vol/lib/mysql /var/lib/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/lib/mysql
echo "/vol/log/mysql /var/log/mysql none bind" | sudo tee -a /etc/fstab
sudo mount /var/log/mysql
sudo /etc/init.d/mysqld start
echo "*** Done. Mysql is now running on EBS backed volume at $VOLUME ***"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment