Mysql middleware proxy Atlas

Source: Internet
Author: User
This document introduces the installation and configuration of atlas and the implementation of altas ha by using keepalive software to avoid database service interruptions due to atlas faults. 1. Environment Description Atlas master: 192.168.1.1224Atlas slave: 192.168.1.8124Atlasvip: 192.168.1.23024Atlaswrite: master

This document introduces the installation and configuration of atlas and the implementation of altas ha by using keepalive software to avoid database service interruptions due to atlas faults. 1. Environment Description Atlas master: 192.168.1.12/24 Atlas slave: 192.168.1.81/24 Atlasvip: 192.168.1.230/24 Atlaswrite: master

This article introduces the installation and configuration of atlas and the implementation of altas ha using keepalive software to avoid Database Service Interruption Due to atlas failure:

I. Environment Introduction

Atlas master: 192.168.1.12/24

Atlas slave: 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

Ii. Install atlas and perform the same operations on server 12 and server 81.

# 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:11: (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://www.68idc.cn/help/uploads/allimg/151213/0K14V043-0.jpg "title =" image 1.png "alt =" wKioL1RQnraRQElvAAVhsfdIFeE913.jpg "/>

#/Usr/local/mysql/bin/mysql-h 192.168.1.12-P 2345-uadmin-padmin

650) this. width = 650; "src =" http://www.68idc.cn/help/uploads/allimg/151213/0K14Q626-1.jpg "title =" image 2.png "alt =" wKiom1RQnn3DMFxSAAZhA29duaA866.jpg "/>

3. Install keepalived.

Take 12 servers as an example. 81 servers perform 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

4. Configure the 12-server keepalive

1: keepalive master configuration file

# Cat/usr/local/keepalived/etc/keepalived. conf

! Configuration File for keepalivedglobal_defs { router_id  LVS_DEVEL}vrrp_script Monitor_Atlas { script "/usr/local/scripts/monitor_atlas.sh" interval 2  weight 2  }vrrp_instance VI_1{  state MASTER  interface eth0 virtual_router_id 51  mcast_src_ip 192.168.1.12 priority 100   advert_int 1 authentication { auth_type PASS auth_pass password_123} track_script { Monitor_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-proxyd 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


5. Configure keepalive on server 81.

1: keepalive master configuration file

# Cat/usr/local/keepalived/etc/keepalived. conf

! Configuration File for keepalivedglobal_defs { router_id  LVS_DEVEL}vrrp_script Monitor_Atlas { script "/usr/local/scripts/monitor_atlas.sh" interval 2  weight 2  }vrrp_instance VI_1{  state BACKUP interface eth0 virtual_router_id 51  mcast_src_ip 192.168.1.81 priority 90   advert_int 1 authentication { auth_type PASS auth_pass password_123} track_script { Monitor_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-proxyd 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


6. Start the keepalive service and test it.

Server

#/Usr/local/keepalived/sbin/keepalived-D-f/usr/local/keepalived/etc/keepalived. conf

# Tail-f/var/log/messages

650) this. width = 650; "src =" http://www.68idc.cn/help/uploads/allimg/151213/0K14Q547-2.jpg "title =" image 3.png "alt =" wKiom1RQnzTDRG2aAAo4YBIJ5v0036.jpg "/>

650) this. width = 650; "src =" http://www.68idc.cn/help/uploads/allimg/151213/0K14R618-3.jpg "title =" image 4.png "alt =" wKioL1RQn5WQTUJxAAWMEqUK7C0455.jpg "/>

2: 81 servers

#/Usr/local/keepalived/sbin/keepalived-D-f/usr/local/keepalived/etc/keepalived. conf

# Tail-f/var/log/messages

650) this. width = 650; "src =" http://www.68idc.cn/help/uploads/allimg/151213/0K14U552-4.jpg "title =" image 5.png "alt =" wKioL1RQn7CBa77yAAvAmEp_8JM346.jpg "/>

3: connecting to 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://www.68idc.cn/help/uploads/allimg/151213/0K14R5W-5.jpg "title =" image 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://www.68idc.cn/help/uploads/allimg/151213/0K14S600-6.jpg "title =" image 7.png "alt =" wKiom1RQn47T6dMTAAZN75tM-YU288.jpg "/>

4: Fault Test

12. Disable the keepalive service on the server.

650) this. width = 650; "src =" http://www.68idc.cn/help/uploads/allimg/151213/0K14R296-7.jpg "title =" image 8.png "alt =" wKiom1RQn7KxMkbVAAD6QyPbNY4942.jpg "/>

81 the keepalive of the server automatically takes over the vip service

# Tail-f/var/log/messages

650) this. width = 650; "src =" http://www.68idc.cn/help/uploads/allimg/151213/0K14Q4H-8.jpg "title =" image 9.png "alt =" wKiom1RQn8igfc58AATHfv8ywW8481.jpg "/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.