Skip to content

Instantly share code, notes, and snippets.

@iliabylich
Last active August 29, 2015 14:17
Show Gist options
  • Save iliabylich/8d40e948edcdf355cc02 to your computer and use it in GitHub Desktop.
Save iliabylich/8d40e948edcdf355cc02 to your computer and use it in GitHub Desktop.
pxc base setup
# 85.159.215.71 / 192.168.168.47 / pxc1
# 178.79.171.179 / 192.168.169.82 / pxc2
# 213.52.128.96 / 192.168.170.100 / pxc3
# 85.159.209.205 / 192.168.171.36 / pxc4
# 80.85.85.243 / 192.168.168.7 / lb
# Adding percona repo
apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
echo "deb http://repo.percona.com/apt trusty main" > /etc/apt/sources.list.d/percona.list
echo "deb-src http://repo.percona.com/apt trusty main" >> /etc/apt/sources.list.d/percona.list
apt-get update
# Upgrading the system (not necessary)
apt-get upgrade -y
# Install percona server, root/root
apt-get install -y percona-xtradb-cluster-client-5.5
apt-get install -y percona-xtradb-cluster-galera-2.x
apt-get install -y percona-xtradb-cluster-server-5.5
# Populate configs
echo '
[mysqld]
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_cluster_address=gcomm://pxc1,pxc2,pxc3,pxc4
wsrep_slave_threads=8
wsrep_sst_method=xtrabackup-v2 # for > 5.5.33-23.7.6
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
wsrep_sst_auth=root:root
wsrep_node_address=pxc1 # pxc2/pxc3/pxc4
wsrep_cluster_name=test_cluster
wsrep_node_name=node1
' >> /etc/mysql/my.cnf
/etc/init.d/mysql bootstrap-pxc
# or next time
service mysql start
# Utils:
show status like 'wsrep%';
show status like 'wsrep_cluster_size';
grant all on *.* to root@'192.168.%' identified by 'root';
mysql -proot -e"show status like 'wsrep%';"
service mysql start
tail -n100 /var/log/mysql/error.log
# /etc/hosts
# internal
192.168.168.47 pxc1
192.168.169.82 pxc2
192.168.170.100 pxc3
192.168.171.36 pxc4
192.168.168.7 pxc-lb
# external
85.159.215.71 pxc1
178.79.171.179 pxc2
213.52.128.96 pxc3
85.159.209.205 pxc4
80.85.85.243 pxc-lb
# lb config
# Only once
mysql -uroot -proot -e"grant process on *.* to 'clustercheckuser'@'localhost' identified by 'clustercheckpassword!';"
mysql -uroot -proot -e"flush privileges;"
clustercheck
# each node
apt-get install -y xinetd
echo 'mysqlchk 9200/tcp' >> /etc/services
service xinetd restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment