MySQL + KeepAlived + LVS single-point write master/Master synchronization high-availability architecture Experiment

Source: Internet
Author: User

MySQL + KeepAlived + LVS Single Point write master synchronization high availability architecture Experiment (I) actual environment server name · ip OS MySQLodd.example.com 192.168.1.116 RHEL-5.8 5.5.16even.example.com 192.168.1.115 RHEL-5.8 5.5.16 (ii) advantages and disadvantages, easy to implement and high availability. You can switch between services and the system based on the availability. ● you can set the write VIP and read VIP respectively, prepare for read/write splitting ● you can add multiple slave servers later, disadvantages of Server Load balancer: The Defined sorry_server will be replaced immediately after the Server Load balancer is started or restored. Therefore, if you want to replace or not replace the specified conditions, you must use other methods. For example: temporary changes to MySQL ports, etc. ● expansion is not very convenient ● switching takes about 1 s (3) applicable scenarios this solution applies to scenarios where only two database servers are available and database read/write splitting is not yet implemented situation, read, and write are configured with VIP. This solution can facilitate the management and maintenance of a single database and switch jobs, such as modifying the table structure of a large table and upgrading the database. (4) solution architecture diagram (v) Deployment STEP (1) For MySQL installation, refer to my previous article: three major installation methods for MySQL 5.5: [binary, source code compilation, and RPM package] installation steps and comparison of advantages and disadvantages http://www.bkjia.com/database/201304/202705.html (2) MySQL master/Master synchronization configuration refer to my previous article. HA: MySQL master/Master synchronization Configuration http://www.bkjia.com/database/201305/207858.html (3) LVS installed on odd even: # wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz # Ln-s/usr/src/kernels/2.6.18-308. el5xen-i686 // usr/src/linux # tar-zxv-f ipvsadm-1.24.tar.gz # cd ipvsadm-1.24 # make install (KeepAlived) installed on odd even: # wget http://www.keepalived.org/software/keepalived-1.1.19.tar.gz # Tar-zxv-f keepalived-1.1.19.tar.gz # cd keepalived-1.1.19 #. /configure -- prefix =/usr/local/keepalived # make install # cp/usr/local/keepalived/sbin/keepalived/usr/sbin/# cp/usr/local/ keepalived/etc/sysconfig/# cp/usr/local/keepalived/etc/rc. d/init. d/keepalived/etc/init. d/# mkdir/etc/keepalived configure KeepAlived in ODD [plain] global_defs {icationication_ema Il {linwaterbin@gmail.com} fill bychjzh@gmail.com smtp_server limit 30 router_id LVS1} route test {group {loadbalance} vrrp_instance loadbalance {state BACKUP interface eth0 route eth0 virtual_router_id 51 priority 150 advert_int 1 authentication {auth_type auth_pass 1111} virtual_ipaddress {192.168.1.12 8 dev eth0 label eth0: 1} virtual_server 192.168.1.128 3306 {delay_loop 6 255.rr limit DR Limit 20 protocol TCP sorry_server 192.168.1.115 3306 real_server 192.168.1.116 3306 {weight 3 TCP_CHECK {connect_timeout 3 then 3 then 3 connect_port 3306} EVEN: most of them are the same as ODD and only have two locations: ● state BACKUP ● priority 150 kernel odd even realsever configured on odd even [pla In] #! /Bin/bash # description: Config realserver lo and apply noarp SNS_VIP = 192.168.1.128/etc/rc. d/init. d/functions case "$1" in start) ifconfig lo: 0 $ SNS_VIP netmask 255.255.255.255 broadcast $ SNS_VIP/sbin/route add-host $ SNS_VIP dev lo: 0 echo "1">/proc/sys/net/ipv4/conf/lo/arp_ignore echo "2">/proc/sys/net/ipv4/conf/lo/arp_announce echo "1">/proc/sys/net/ipv4/conf/all/arp_ignore echo "2">/proc/s Ys/net/ipv4/conf/all/arp_announce sysctl-p>/dev/null 2> & 1 echo "RealServer Start OK"; stop) ifconfig lo: 0 down route del $ SNS_VIP>/dev/null 2> & 1 echo "0">/proc/sys/net/ipv4/conf/lo/arp_ignore echo "0">/ proc/sys/net/ipv4/conf/lo/arp_announce echo "0">/proc/sys/net/ipv4/conf/all/arp_ignore echo "0">/proc/ sys/net/ipv4/conf/all/arp_announce echo "RealServer Stoped ";; *) echo "Usage: $0 {star T | stop} "exit 1 esac exit 0 then start KeepAlived and realsever in odd even #/etc/rc. d/init. d/realserver. sh start #/etc/rc. d/init. d/keepalived start # echo "/etc/rc. d/init. d/realserver. sh start ">/etc/rc. local # echo "/etc/rc. d/init. d/keepalived start ">/etc/rc. the local configuration is almost done here. Next let's take a look at the test (6) simple test to stop the ODD MySQL Server, and see if it can automatically switch to sorry_server [plain] before it is stopped: [root @ odd keepalived] # ipvsadm-ln IP Virtual Serv Er version 1.2.1 (size = 4096) Prot LocalAddress: Port Scheduler Flags-> RemoteAddress: Port Forward Weight ActiveConn InActConn TCP 192.168.1.128: 3306 rr persistent 20-> 192.168.1.116: 3306 Local 3 0 0 stop: [mysql @ odd ~] $ Mysqladmin shutdown 130508 00:53:50 mysqld_safe mysqld from pid file/home/mysql/data/odd.example.com. after pid ended [1] + Done mysqld_safe is stopped: [root @ odd keepalived] # ipvsadm-ln IP Virtual Server version 1.2.1 (size = 4096) Prot LocalAddress: port Scheduler Flags-> RemoteAddress: Port Forward Weight ActiveConn InActConn TCP 192.168.1.128: 3306 rr persistent 20-> 192.168.1.115: 3306 Route 1 0 0 success !!

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.