2013-04-17 22:15:10 +02:00
|
|
|
#!/bin/sh
|
|
|
|
umount /mnt
|
|
|
|
yes | mdadm --create /dev/md0 --raid-devices=2 --level=1 /dev/xvdb /dev/xvdc
|
2016-07-19 03:37:50 +02:00
|
|
|
# Add disk to mdadm.conf so it will be enabled on boot
|
|
|
|
mdadm --examine --scan | sed 's/ metadata=1.2//; s/ name.*//; s|md/0|md0|' >> /etc/mdadm/mdadm.conf
|
2013-04-22 17:06:54 +02:00
|
|
|
|
2013-04-17 22:15:10 +02:00
|
|
|
blockdev --setra 4096 /dev/xvdb
|
|
|
|
blockdev --setra 4096 /dev/xvdc
|
|
|
|
blockdev --setra 4096 /dev/md0
|
2013-04-22 17:06:54 +02:00
|
|
|
echo deadline > /sys/block/xvdb/queue/scheduler
|
|
|
|
echo deadline > /sys/block/xvdc/queue/scheduler
|
|
|
|
|
2013-04-17 22:15:10 +02:00
|
|
|
mkfs.xfs /dev/md0
|
2016-07-19 03:37:50 +02:00
|
|
|
|
|
|
|
echo "/dev/md0 /srv xfs nofail,noatime,barrier 1 1" >> /etc/fstab
|
2013-04-17 22:15:10 +02:00
|
|
|
mount /srv
|
|
|
|
|
2019-01-05 05:00:46 +01:00
|
|
|
# TODO use systemctl instead of pg_ctlcluster on CentOS
|
2016-07-19 03:37:50 +02:00
|
|
|
pg_ctlcluster 9.5 main stop
|
2013-04-17 22:15:10 +02:00
|
|
|
mv /var/lib/postgresql /srv
|
|
|
|
ln -s /srv/postgresql/ /var/lib
|
2013-05-08 22:54:25 +02:00
|
|
|
|
|
|
|
mv /tmp /srv
|
|
|
|
mkdir /tmp
|
|
|
|
mount --bind /srv/tmp /tmp
|
2016-07-19 03:37:50 +02:00
|
|
|
echo "/srv/tmp /tmp bind nofail,defaults,bind 0 0" >> /etc/fstab
|
2019-01-05 05:00:46 +01:00
|
|
|
# TODO use systemctl instead of pg_ctlcluster on CentOS
|
2016-07-19 03:37:50 +02:00
|
|
|
pg_ctlcluster 9.5 main start
|
|
|
|
|
|
|
|
# Disable /mnt line for /dev/xvdb
|
|
|
|
umount /mnt
|
|
|
|
sed -i 's|^/dev/xvdb|#/dev/xvdb|' /etc/fstab
|
|
|
|
|
|
|
|
# Update the initrd so we can use the new array post-boot
|
|
|
|
update-initramfs -u
|