|
|
|
@ -80,3 +80,54 @@ service mysql start
|
|
|
|
|
|
|
|
|
|
# Maybe need on most advanced node:
|
|
|
|
|
# sed -i -e 's/safe_to_bootstrap: 0/safe_to_bootstrap: 1/g' /var/lib/mysql/grastate.dat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########################
|
|
|
|
|
# haproxy
|
|
|
|
|
|
|
|
|
|
# for code.forksand.com, insert on sql1 (or any of them):
|
|
|
|
|
# http://galeracluster.com/documentation-webpages/haproxy.html
|
|
|
|
|
USE mysql;
|
|
|
|
|
|
|
|
|
|
# This fails. Not a good way to create users either.
|
|
|
|
|
CREATE USER 'haproxy'@'10.42.1.163' IDENTIFIED BY 'password';
|
|
|
|
|
FLUSH PRIVILEGES;
|
|
|
|
|
SHOW GRANTS FOR 'haproxy'@'10.42.1.163';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pen proxy instead of haproxy
|
|
|
|
|
# To run manually:
|
|
|
|
|
pen -l pen.log -p pen.pid localhost:3306 10.42.1.171:3306 10.42.1.172:3306 10.42.1.173:3306 10.42.1.174:3306
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useradd pen
|
|
|
|
|
echo "d /var/run/pen 0755 pen pen -" > /etc/tmpfiles.d/pen.conf
|
|
|
|
|
systemd-tmpfiles --create
|
|
|
|
|
|
|
|
|
|
mkdir -p /etc/pen
|
|
|
|
|
cat > /etc/pen/galera.cfg <<EOF
|
|
|
|
|
server 0 address 10.42.1.171 port 3306
|
|
|
|
|
server 2 address 10.42.1.172 port 3306
|
|
|
|
|
server 3 address 10.42.1.173 port 3306
|
|
|
|
|
server 4 address 10.42.1.174 port 3306
|
|
|
|
|
debug 1
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
cat > /lib/systemd/system/pen-galera.service <<EOF
|
|
|
|
|
[Unit]
|
|
|
|
|
Description=Pen load balancer (galera)
|
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
User=pen
|
|
|
|
|
Type=forking
|
|
|
|
|
PIDFile=/var/run/pen/galera.pid
|
|
|
|
|
ExecStart=/usr/bin/pen -u pen -C /var/run/pen/galera.ctl -F /etc/pen/galera.cfg -p /var/run/pen/galera.pid 127.0.0.1:3306
|
|
|
|
|
Restart=on-failure
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
systemctl restart pen-galera
|
|
|
|
|
systemctl enable pen-galera.service
|
|
|
|
|