forked from cosmin/elasticpony
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_mysql.sh
executable file
·44 lines (32 loc) · 1.17 KB
/
install_mysql.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
VOLUME=$1
if [ -z $VOLUME ]; then
echo "You must specify the volume, like /dev/xvdf"
exit 1;
fi
# stops mysql from asking for a root pw
echo "*** Installing MySQL (with no root password) ***"
sudo DEBIAN_FRONTEND=noninteractive aptitude install -y mysql-server
echo "*** Creating XFS filesystem and moving mysql configuration ***"
sudo apt-get 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 -m 000 /vol
sudo mount /vol
sudo /etc/init.d/mysql stop
sudo mkdir /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/mysql start
echo "*** Done. Mysql is now running on EBS backed volume at $VOLUME ***"