High Availability ha
Highavailable
1, the need heartbeat mechanism to detect whether the back-end RS provide services.
A) detection down, need to remove the RS from LVs
B probe send from down to up, need to add RS again from LVS.
2, Lvs DR, need to master (HA)
Keepalived: Provides highly available
VRRP protocol to realize the drift of IP
Zookeeper:
The difference between keepalived and zookeeper is that master hangs up, and when Master is back up, it can take over. keepalived Installation:
At least two servers need to be installed
Yuminstall keepalived
keepalived configuration file
At least two servers
1. Address:/etc/keepalived/keepalived.conf
2, help manual: Mankeepalived.conf
3, before editing, need to back up: cp–akeepalived.conf Keepalived.conf.bak
4. Edit:
! Configuration File for Keepalived
Global_defs {
Notification_email {
root@localhost# send a reminder message can have more than one destination address
Goldbin@126.com
}
Notification_email_from root@localhost# send the From address of the mail, can write at will, the email address does not exist does not matter
Smtp_server 127.0.0.1# Mail Service address, general write local
Smtp_connect_timeout 30
router_id Lvs_devel
}
Vrrp_instance Vi_1 {
State BACKUP #MASTER Lord and from
Interface Eth0 #VIP需要绑定的网卡名称
VIRTUAL_ROUTER_ID 51
Priority 101# Priority Master priority is at least higher than from 50, master 101 from <=50
Advert_int 1
Authentication {
Auth_type Pass
Auth_pass 1111
}
virtual_ipaddress {
192.168.223.100/24 Dev eth0 label eth0:0 #设置VIP
}
}
Virtual_server 192.168.223.100 {#设置虚拟lvs服务, VIP PORT
Delay_loop 6
Lb_algo rr# Scheduling Algorithm WRR
The pattern of Lb_kind Dr#lvs
Nat_mask 255.255.255.0
Persistence_timeout 50 The same IP address in 50 seconds LVs forward to the same back-end server
Protocol TCP
Real_server 192.168.223.111 {#设置真实服务器的心跳机制 RID PORT
Weight weight
Http_get {#心跳检测的方式
URL {
path/#心跳检查的地址
Status_code 200# The status returned by the heartbeat check
}
Connect_timeout 2 #超时时间
Nb_get_retry 3# repeat Check 3 times
Delay_before_retry, check again every 1 seconds.
}
}
Real_server 192.168.223.112 {#第二个真实服务器设置
Weight 1
Http_get {
URL {
Path/
Status_code 200
}
Connect_timeout 2
Nb_get_retry 3
Delay_before_retry 1
}
}
}
keepalived Startup and Logging
Service keepalived Start
Tail/var/log/message View the log.
Install mail:yum–y Install Mail
Turn off a real server's Tomcat:killall Java
To view messages on the Lvs_master machine: Mail
Thinking:
1, Nginx +keepalived high availability (do not need LVS).