Introduction of DRBD+heartbeat + LVS + keepalived+ mysql
The following is an introduction to DRBD+heartbeat + LVS + keepalived+ mysql, hoping to give you some help in practical application. Load balancing involves a lot of things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
DRBD+heartbeat + LVS + keepalived+ mysql
Hardware: master * 2: install drbd, heartbeat,mysql
Slave*3: installing mysql
Keepalived host * 2: install LVS and keepalived (real server is slave)
Application Host * 3
IP: two master have one HA VIP1
Two keepalived hosts have one lvs VIP2
Write operation:
Application host (AS)-> VIP1- > dev/drbd (the drbd of the two master will be synchronized in real time)
Mysql replication operation:
0) start slave
1) three slave will start an I / O thread to send a request to vip1, requesting master to send binlog
2) master will set up an I / O thread to send binlog to three slave
3) the Ibank O thread in step 1 will save the changed statements to the relay log-relay log
4) slave will open another Imax O read process to read relay log.
Read operation:
Three AS- > VIP2- > according to lVS algorithm (RR or WRR)-> a certain slave
That is, reading and writing separate master from slave.
Some key configurations:
Drbd: / etc/drbd.conf, you need to configure the drbd device name, such as the local disk name of / dev/drbd0, node1, and node2
IP of node1 and node2: 7788
Keepalived: configure vrrp, virtual serverIP configure DR mode, real servers adds IP for slave, and a script check.slave.pl that integrates monitoring slave's health
LVS: ipvsadm-L can see the load status of multiple real server. Routing algorithm RR is used in situations where the performance of each real server is about the same. You, me and one, WRR weighting algorithm, do more if you have strong performance.
Heartbeat related commands:
# crm_resource-- list # View all resources, there is a set of resources
Resource Group: group_1
IPaddr_192_168_21_1 (ocf::heartbeat:IPaddr)
Httpd_2 (lsb:httpd)
Master / Slave switching:
[root@orasrv1 crm] # crm_standby-v true
[root@orasrv1 crm] # curl http://192.168.21.1/
Orasrv2.xlk.com
# you can also switch by specifying a node
# assuming that node 2 is primary, you can execute a command on node 1 to switch it to standby.
# crm_standby-v true-U orasrv2.xlk.com
Rhcs handoff:
C, switch a service
You can switch an application service from one node to another in the following ways:
Clusvcadm-r-m
For example, you want to switch the service of node web1 to web2.
[root@web1 /] # clusvcadm-r WebServer-m web2.shbztech.com
After reading the above introduction about DRBD+heartbeat + LVS + keepalived+ mysql, if there is anything else you need to know, you can find out what you are interested in in the industry information or find our professional technical engineer to answer, the technical engineer has more than ten years of experience in the industry.