Haproxy for MariaDB loadbalance / Haproxy untuk loadbalance MariaDB
Haproxy for MariaDB loadbalance / Haproxy untuk loadbalance MariaDB
for install and configurations haproxy here
ip haproxy 10.10.0.20
mariadb-1 10.10.0.23
mariadb-2 10.10.0.25
add two user for check status and user haproxy on mariadb host 1 and 2
on mariadb1
root@mariadb1# mysql -u root -p -e "INSERT INTO mysql.user (Host,User) values ('10.10.0.20','ha_check'); FLUSH PRIVILEGES;"
root@mariadb1# mysql -u root -p -e "GRANT ALL PRIVILEGES ON *.* TO 'haproxy_user'@'10.10.0.20' IDENTIFIED BY 'user_password' WITH GRANT OPTION; FLUSH PRIVILEGES"
on mariadb2
root@mariadb2# mysql -u root -p -e "INSERT INTO mysql.user (Host,User) values ('10.10.0.20','ha_check'); FLUSH PRIVILEGES;"
root@mariadb2# mysql -u root -p -e "GRANT ALL PRIVILEGES ON *.* TO 'haproxy_user'@'10.10.0.20' IDENTIFIED BY 'user_password' WITH GRANT OPTION; FLUSH PRIVILEGES"
edit /etc/haproxy/haproxy.cfg
listen mysql-cluster
bind :3306
mode tcp
option mysql-check user ha_check
balance roundrobin
server mariadb-1 10.10.0.23:3306 check
server mariadb-2 10.10.0.25:3306 check
restart
#service haproxy restart
root@haproxy# mysql -h 127.0.0.1 -u haproxy_user -p -e "show variables like 'server_id'"
for install and configurations haproxy here
ip haproxy 10.10.0.20
mariadb-1 10.10.0.23
mariadb-2 10.10.0.25
add two user for check status and user haproxy on mariadb host 1 and 2
on mariadb1
root@mariadb1# mysql -u root -p -e "INSERT INTO mysql.user (Host,User) values ('10.10.0.20','ha_check'); FLUSH PRIVILEGES;"
root@mariadb1# mysql -u root -p -e "GRANT ALL PRIVILEGES ON *.* TO 'haproxy_user'@'10.10.0.20' IDENTIFIED BY 'user_password' WITH GRANT OPTION; FLUSH PRIVILEGES"
on mariadb2
root@mariadb2# mysql -u root -p -e "INSERT INTO mysql.user (Host,User) values ('10.10.0.20','ha_check'); FLUSH PRIVILEGES;"
root@mariadb2# mysql -u root -p -e "GRANT ALL PRIVILEGES ON *.* TO 'haproxy_user'@'10.10.0.20' IDENTIFIED BY 'user_password' WITH GRANT OPTION; FLUSH PRIVILEGES"
edit /etc/haproxy/haproxy.cfg
listen mysql-cluster
bind :3306
mode tcp
option mysql-check user ha_check
balance roundrobin
server mariadb-1 10.10.0.23:3306 check
server mariadb-2 10.10.0.25:3306 check
restart
#service haproxy restart
root@haproxy# mysql -h 127.0.0.1 -u haproxy_user -p -e "show variables like 'server_id'"
Komentar
Posting Komentar