This article describes the installation configuration of Atlas, as well as the use of keepalive software to implement Altas ha To avoid a database service outage due to Atlas failure:
A: Introduction to the Environment
Atlas Master:192.168.1.12/24
Atlas from:192.168.1.81/24
Atlas vip:192.168.1.230/24
Atlas write:
Master:192.168.1.225/24
Slave1:192.168.1.226/24
Slave2:192.168.1.227/24
Management node:192.168.1.12/24
Mha vip:192.168.1.231/24
Atlas read:
Slave2:192.168.1.227/24
Slave3:192.168.1.228/24
Two: Install Atlas, server and bayi server to perform the same operation
# yum-y Install OpenSSL openssl-devel# wget https://github.com/Qihoo360/Atlas/releases/download/2.1/ atlas-2.1.el6.x86_64.rpm# RPM-IVH atlas-2.1.el6.x86_64.rpm# cd/usr/local/mysql-proxy/conf/#/usr/local/mysql-proxy /bin/encrypt 123456/izxz+0groa=
# grep-v ' ^# '/usr/local/mysql-proxy/conf/test.cnf |grep-v ' ^$ '
[Mysql-proxy]admin-username = Adminadmin-password = Adminproxy-backend-addresses = 192.168.1.231:3306proxy-read-only-backend-addresses = 192.168.1.227:3306,192.168.1.228:3306pwds = Root:/iZxz+0GRoA = Daemon = Truekeepalive = Trueevent-threads = 8log-level = Messagelog-path =/usr/local/mysql-proxy/logproxy-address = 0. 0.0.0:1234admin-address = 0.0.0.0:2345
#/usr/local/mysql-proxy/bin/mysql-proxyd Test Start
Ok:mysql-proxy of Test is started
# NETSTAT-NTPL |grep Mysql-proxy
TCP 0 0 0.0.0.0:2345 0.0.0.0:* LISTEN 29643/mysql-proxy
TCP 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN 29643/mysql-proxy
# tail-f/usr/local/mysql-proxy/log/test.log
2014-10-29 11:12:11: (message) Mysql-proxy 0.8.2 started-instance:test2014-10-29 11:12:11: (message) Proxy listening on Port 0.0.0.0:12342014-10-29 11:12:11: (message) added Read/write backend:192.168.1.231:33062014-10-29 11:12:11: ( Message) added Read-only backend:192.168.1.227:33062014-10-29 11:12:11: (Message) chassis-unix-daemon.c:138: [Angel] We try to keep pid=29643 alive2014-10-29 11:12:11: (message) added read-only backend:192.168.1.228:33062014-10-29 11:12:1 1: (message) Chassis-event-thread.c:235:starting 8 threads
#/usr/local/mysql/bin/mysql-h 192.168.1.12-p 1234-u root-p123456
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4D/65/wKioL1RQnraRQElvAAVhsfdIFeE913.jpg "title=" Picture 1.png "alt=" Wkiol1rqnrarqelvaavhsfdifee913.jpg "/>
#/usr/local/mysql/bin/mysql-h 192.168.1. A - P 2345-uadmin-padmin
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4D/65/wKiom1RQnn3DMFxSAAZhA29duaA866.jpg "title=" Picture 2.png "alt=" Wkiom1rqnn3dmfxsaazha29duaa866.jpg "/>
Three: Installation keepalived
For example, in this case,thebayi Server performs the same operation
# cd/usr/local/src/# wget http://www.keepalived.org/software/keepalived-1.2.13.tar.gz# TAR-ZXVPF Keepalived-1.2.13.tar.gz # CD keepalived-1.2.13#./configure--prefix=/usr/local/keepalived && make && Make install
Four: Configure the server keepalive
1:keepalive master configuration file
# cat/usr/local/keepalived/etc/keepalived/keepalived.conf
! Configuration File for keepalivedglobal_defs {router_id lvs_devel}vrrp_script monitor_atlas {script '/usr/local/script S/monitor_atlas.sh "Interval 2 weight 2}vrrp_instance vi_1{State MASTER interface eth0 virtual_router_id Wuyi mcast_s RC_IP 192.168.1.12 Priority Advert_int 1 Authentication {auth_type PASS auth_pass password_123} track_script {Moni Tor_atlas} virtual_ipaddress {192.168.1.230}}
2: Monitor the Atlas script
# cat/usr/local/scripts/monitor_atlas.sh
#!/bin/bashif [$ (ps-ef |grep ' mysql-proxy ' |grep-v ' grep ' |wc-l)-eq "0"];then/usr/local/mysql-proxy/bin/mysql-p Roxyd Test Start Sleep 5 if [$ (ps-ef |grep ' mysql-proxy ' |grep-v ' grep ' |wc-l)-eq "0"];then killall-9 Keepalived Service Network Restart Fifi
# chmod +x/usr/local/scripts/monitor_atlas.sh
Five: Configure the bayi server keepalive
1:keepalive master configuration file
# cat/usr/local/keepalived/etc/keepalived/keepalived.conf
! Configuration File for keepalivedglobal_defs {router_id lvs_devel}vrrp_script monitor_atlas {script '/usr/local/script S/monitor_atlas.sh "Interval 2 weight 2}vrrp_instance vi_1{State BACKUP interface eth0 virtual_router_id Wuyi MCAST_SR C_IP 192.168.1.81 Priority Advert_int 1 Authentication {auth_type PASS auth_pass password_123} track_script {Monito R_atlas} virtual_ipaddress {192.168.1.230}}
2: Monitor the Atlas script
# cat/usr/local/scripts/monitor_atlas.sh
#!/bin/bashif [$ (ps-ef |grep ' mysql-proxy ' |grep-v ' grep ' |wc-l)-eq "0"];then/usr/local/mysql-proxy/bin/mysql-p Roxyd Test Start Sleep 5 if [$ (ps-ef |grep ' mysql-proxy ' |grep-v ' grep ' |wc-l)-eq "0"];then killall-9 Keepalived Service Network Restart Fifi
# chmod +x/usr/local/scripts/monitor_atlas.sh
Six: Start keepalive service and test
1:12 Server
#/usr/local/keepalived/sbin/keepalived-d-f/usr/local/keepalived/etc/keepalived/keepalived.conf
# tail-f/var/log/messages
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4D/65/wKiom1RQnzTDRG2aAAo4YBIJ5v0036.jpg "title=" Picture 3.png "alt=" Wkiom1rqnztdrg2aaao4ybij5v0036.jpg "/>
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4D/65/wKioL1RQn5WQTUJxAAWMEqUK7C0455.jpg "title=" Picture 4.png "alt=" Wkiol1rqn5wqtujxaawmequk7c0455.jpg "/>
2:81 Server
#/usr/local/keepalived/sbin/keepalived-d-f/usr/local/keepalived/etc/keepalived/keepalived.conf
# tail-f/var/log/messages
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/65/wKioL1RQn7CBa77yAAvAmEp_8JM346.jpg "title=" Picture 5.png "alt=" Wkiol1rqn7cba77yaavamep_8jm346.jpg "/>
3: Connect the Atlas test
#/usr/local/mysql/bin/mysql-h 192.168.1.230-p 1234-uroot-p123456
Mysql> select User,host,password from Mysql.user;
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4D/65/wKioL1RQn83jpdR-AAnzAXLp0Hs421.jpg "title=" Picture 6.png "alt=" Wkiol1rqn83jpdr-aanzaxlp0hs421.jpg "/>
#/usr/local/mysql/bin/mysql-h 192.168.1.230-p 2345-uadmin-padmin
Mysql> SELECT * from Backends;
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4D/65/wKiom1RQn47T6dMTAAZN75tM-YU288.jpg "title=" Picture 7.png "alt=" Wkiom1rqn47t6dmtaazn75tm-yu288.jpg "/>
4: Failure test
Shutdown keepalive service on server
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/65/wKiom1RQn7KxMkbVAAD6QyPbNY4942.jpg "title=" Picture 8.png "alt=" Wkiom1rqn7kxmkbvaad6qypbny4942.jpg "/>
the keepalive of the Bayi server will automatically take over the VIP service
# tail-f/var/log/messages
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/4D/65/wKiom1RQn8igfc58AATHfv8ywW8481.jpg "title=" Picture 9.png "alt=" Wkiom1rqn8igfc58aathfv8yww8481.jpg "/>
This article from "Chop Month" blog, declined reprint!
MySQL Middleware agent Atlas