Skip to content

Instantly share code, notes, and snippets.

@nownabe
Last active April 29, 2019 16:11
Show Gist options
  • Save nownabe/27ffdd8fed6a3f1707e8 to your computer and use it in GitHub Desktop.
Save nownabe/27ffdd8fed6a3f1707e8 to your computer and use it in GitHub Desktop.
Vagrantfile for Percona XtraDB Cluster on CentOS 7
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen hastats *:80
mode http
maxconn 64
timeout connect 5000
timeout client 10000
timeout server 10000
stats enable
stats show-legends
stats uri /haproxy?hastats
stats auth admin:p@ssw0rd
listen mysql *:3306
mode tcp
option mysql-check user haproxy
balance roundrobin
server pxcnode-01 10.6.3.101 check
server pxcnode-02 10.6.3.102 check
server pxcnode-03 10.6.3.103 check
# -*- mode: ruby -*-
# vi: set ft=ruby :
PXC_CLUSTER_SIZE = 3
IP = "10.6.3.%d"
Vagrant.configure(2) do |config|
config.vm.box = "centos7"
config.vm.box_url = "https://f0fff3908f081cb6461b407be80daf97f07ac418.googledrive.com/host/0BwtuV7VyVTSkUG1PM3pCeDJ4dVE/centos7.box"
config.vm.provider(:virtualbox){|v| v.functional_vboxsf = false }
(1..PXC_CLUSTER_SIZE).each do |i|
config.vm.define vm_name = "pxcnode-%02d" % i do |c|
c.vm.hostname = vm_name
ip = IP % [i+100]
c.vm.network :private_network, ip: ip
c.vm.provision "shell", inline: <<-EOS
sudo setenforce 0
sudo systemctl stop firewalld
sudo yum makecache fast
sudo yum update -y
sudo yum install -y epel-release
sudo yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
sudo yum install -y Percona-XtraDB-Cluster-56
sudo cat <<EOF | sudo tee /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
user=mysql
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://#{(1..PXC_CLUSTER_SIZE).to_a.map {|j| IP % [j+100]}.join(",")}
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
wsrep_node_address=#{ip}
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=pxcdemo
wsrep_sst_auth="sstuser:s3cret"
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
EOF
EOS
end
end
end
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "centos7"
config.vm.provider(:virtualbox) {|v| v.functional_vboxsf = false}
config.vm.network "private_network", ip: "10.6.3.100"
config.vm.provision "shell", inline: <<-EOS
sudo setenforce 0
sudo systemctl stop firewalld
sudo yum makecache fast
sudo yum update -y
sudo yum install -y epel-release
sudo yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
sudo yum install -y Percona-XtraDB-Cluster-client-56 Percona-XtraDB-Cluster-devel-56
sudo yum install -y haproxy
sudo yum install -y gcc gcc-c++ openssl-devel readline-devel zlib-devel curl-devel libyaml-devel
sudo git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
sudo git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
echo 'export RBENV_ROOT="/usr/local/rbenv"' | sudo tee /etc/profile.d/rbenv.sh
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' | sudo tee -a /etc/profile.d/rbenv.sh
echo 'eval "$(rbenv init -)"' | sudo tee -a /etc/profile.d/rbenv.sh
source /etc/profile.d/rbenv.sh
sudo -i rbenv install 2.1.5
sudo -i rbenv global 2.1.5
sudo -i gem install bundle
sudo -i gem install rails
sudo -i rbenv rehash
EOS
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment