HA site with keepalived glusterfs percona and haproxy

Puppet files will upload on github.

sudo su -
apt-get update && apt-get upgrade
apt-get install -qqy keepalived
vi /etc/keepalived/keepalived.conf on both nodes
service keepalived start
ip add show eth1
ip link set eth1 down
tail -f /var/log/syslog
ip link set eth1 up
tail -f /var/log/syslog

apt-get install -qqy haproxy
sed -i.orig 's/ENABLED=.*/ENABLED=1/' /etc/default/haproxy
cp /etc/haproxy/haproxy.cfg{,.orig}
vi /etc/haproxy/haproxy.cfg
vi /etc/rsyslog.d/udp.localhost.conf
service rsyslog restart
service haproxy start
check on browser 50 51 52




apt-get install -qqy apache2 php5 php5-gd php5-curl php5-mysql
cp /etc/apache2/ports.conf{,.orig}
vi /etc/apache2/ports.conf
service apache2 restart
netstat -nutlp
curl -I http://10.11.12.50 #check SRVNAME
curl -b "SRVNAME=server01" -I http://10.11.12.50
#sample
vi /etc/apache2/sites-available/wordpress.conf
a2ensite wordpress
a2dissite default
a2dissite 000-default
a2enmod rewrite
service apache2 reload


#storage

apt-get install -qqy xfsprogs
fdisk -l
mkfs.xfs -i size=512 /dev/sdb
[ "$(uname -n)" = "server01" ] && mkdir -p /data/glusterfs/var-www/brick01
[ "$(uname -n)" = "server02" ] && mkdir -p /data/glusterfs/var-www/brick02
cp /etc/fstab{,.orig}
vi /etc/fstab
mount -a
df -h


cp /etc/hosts{,.orig}
vi /etc/hosts
apt-get install -qqy glusterfs-server
ps -ef|grep glusterfs
gluster peer probe server02-private
gluster peer probe server01-private

gluster peer status

gluster volume create var-www replica 2 transport tcp server01-private:/data/glusterfs/var-www/brick01/brick server02-private:/data/glusterfs/var-www/brick02/brick
gluster volume start var-www
gluster volume info
echo "$(uname -n)-private:/var-www /var/www glusterfs defaults,_netdev,fetch-attempts=5 0 0" >> /etc/fstab
mount -a


service apache2 stop
mv /var/www{,.orig}
mkdir /var/www
mount /var/www
service apache2 start
df -h


apt-cache search percona
export DEBIAN_FRONTEND=noninteractive
apt-get install -qqy percona-xtradb-cluster-server percona-xtradb-cluster-galera-2.x
service mysql stop
cp -p /etc/mysql/mysql.cnf{,.orig}
vi /etc/mysql/my.cnf

# on db01
service mysql bootstrap-pxc # on db01
ps -ef|grep mysql
mysql -e "CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'sstuser';"
mysql -e "GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';"
mysql -e "GRANT PROCESS ON *.* TO 'clustercheckuser'@'localhost' IDENTIFIED BY 'clustercheckpassword!';"
mysql -e "flush privileges;"
mysql -e "show status like 'wsrep_cluster%';"
service mysql start # node db02 db03


cp /etc/services{,.orig}
echo 'mysqlchk 9200/tcp # mysqlchk' >> /etc/services
apt-get install -qqy xinetd
view /etc/haproxy/haproxy.cfg

# wordpress

  mysql -e 'CREATE DATABASE wordpress;'
  mysql -e 'CREATE USER wordpress IDENTIFIED BY "wordpress";'
  mysql -e 'GRANT ALL PRIVILEGES ON wordpress.* TO wordpress'
  mysql -e 'FLUSH PRIVILEGES;'

cd /var/tmp/
wget https://wordpress.org/latest.tar.gz
tar xf latest.tar.gz -C /var/www
chown -R www-data. /var/www/wordpress