In previous experiments, manual configuration was used to synchronize data between two mysql database servers. mysql-cluster is used to simplify the configuration process and expand a large number of nodes with ease, for more information about mysql-cluster, see the official mysql website ?? Long? P plan: LD1 (Server Load balancer): 192
In previous experiments, manual configuration was used to synchronize data between two mysql database servers. mysql-cluster is used to simplify the configuration process and expand a large number of nodes with ease, for more information about mysql-cluster, see the official mysql website ?? Long? /Span>
IP address planning:
LD1 (Server Load balancer): 192.168.1.41
LD2: 192.168.1.42
SQL1: 192.168.1.21
SQL2: 192.168.1.22
NDB1: 192.168.1.11
NDB2: 192.168.1.12
MGM: 192.168.1.196
VIP: 192.168.1.200
Experiment principle: two SQL statements, two NDB statements, and two LDf commands are used to achieve high availability, and LD schedules SQL statements to achieve load balancing.
First, in the two LD (Server Load balancer settings, the two are roughly the same, so only one of them is set here, And the location to be modified is marked)
[Root @ localhost ~] # Yum-y install ipvsadm kernel-devel openssl-devel
[Root @ localhost ~] #Ln-S/usr/src/kerneLs/2.6.18-194. el5-i686 // usr/src/linux
[Root @ localhost ~] # Wget http://www.keepalivEd. Org/software/keepalived-1.2.1.tar.gz
[Root @ localhost ~] # Ls keepalived-1.2.1.tar.gz
Keepalived-1.2.1.tar.gz
[Root @ localhost ~] # Tar zxvf keepalived-1.2.1.tar.gz
[Root @ localhost ~] #CdKeepalived-1.2.1
[Root @ localhost keepalived-1.2.1] #./configure // after the end, the following content appears to indicate that you can compile and install
Keepalived configuration
------------------------
Keepalived version: 1.2.1
Compiler: gcc
Compiler flags:-g-O2-DETHERTYPE_IPV6 = 0x86Dd
ExTrA Lib:-lpopt-lssl-lcrypto
Use IPVS Framework: Yes
IPVS syNcDaemonSuPport: Yes
Use VRRP Framework: Yes
Use Debug flags: No
[Root @ localhost keepalived-1.2.1] # make & make install
[Root @ localhost ~] #Mkdir/Etc/keepalived
[Root @ localhost ~] #Cp/Usr/local/etc/keepalived. conf/etc/keepalived. conf
[Root @ localhost ~] # Cp/usr/local/etc/sysconfig/keepalived
[Root @ localhost ~] # Cp/usr/local/sbin/keepalived/usr/sbin/keepalived
[Root @ localhost ~] # Cp/usr/local/etc/rc. d/init. d/keepalived/etc/init. d/keepalived
[Root @ localhost ~] # Vi/etc/keepalived/cc. conf
! Configuration File for keepalived
Global_defs {
NotifiCatIon_email {
38205036@qq.com
}
Notification_email_from AlExAndre. Cassen @ fireWall. Loc
Smtp_server 192.168.1.196
Smtp_connect _TimeOut 30
Router _IdLVS_DEVEL
}
Vrrp _Sync_ Group VGM {
Group {
V_MYSQL
}
}
Vrrp_instance V_MYSQL {
StatE MASTER // The slave node is changed to BACKUP
Interface eth0
Lvs_sync_daemon_interface eth0
Virtual_router_id 51
Priority 100 // on the slave node, change it to 90
Advert_int 5
Authentication {
Auth_typePASS
Auth_pass 1111
}
Virtual_ipaddress {
192.168.1.200/24 dev eth0
}
}
Virtual_server 192.168.1.2003306 {
Delay_loop 6
Lb_algo rr
Lb_kind DR
Persistence_timeout 6
ProtoColTCP
Real_server 192.168.1.21 3306 {
Weight 1, 100
TCP_CHECK {
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
Connect_port 3306
}
}
Real_server 192.168.1.22 3306 {
Weight 1, 100
TCP_CHECK {
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
Connect_port 3306
}
}
}
Second: settings on SQL
A script must be run on both SQL nodes, and the configurations of the two nodes are basically the same.
[Root @ localhost ~] # Vi/etc/init. d/lvscdr // write ARP and VIP binding scripts (the two nodes are identical)
#! /Bin/bash
# Descrpption: start realserver DR
VIP = 192.168.1.200
#./Etc/rc. d/init. d/functions
Case "$1" in
Start)
Echo "start LVS of RealServer DR"
/Sbin/IfconfigLo: 0 $ VIP broadcast $ VIP netmask 255.255.255.255 up
/Sbin/route add-host $ VIP dev lo: 0
Echo "1">/proc/sys/net/ipv4/conf/lo/arp_ignore