Lvs-dr+keepalived website Server dual-machine hot standby configuration

Source: Internet
Author: User
Tags website server

Keepalived is a software similar to the Layer3, 4 & 7 switch, which is what we normally call the 3rd, 4th, and 7th layers of exchange. The keepalived is auto-completed and does not require manual intervention.
Dispatch server:
It needs to be done on the basis of LVS.
Refer to the previous two sections:
One of the load Balancing clusters lvs-dr:http://blog.51cto.com/13572519/2084197
-lvs-nat:http://blog.51cto.com/13572519/2084181 of load Balancing cluster

A network card:
vmnet1:192.168.80.100
Master and Slave Scheduler do the following 3 steps: Load, install IPVSADM package
: http://www.keepalived.org/download.html
[Email protected] ~]# modprobe Ip_vs
[Email protected] ~]# rpm-ivh/mnt/packages/ipvsadm-1.27-7.el7.x86_64.rpm
---------keepalived Installation configuration (master, slave configuration)----
[Email protected] ~]# yum-y install popt-devel kernel-devel openssl-devel
WinSCP uploading keepalived to master server

[Email protected] ~]# tar FX keepalived-1.4.2.tar.gz-c/opt
[Email protected] opt]# cd/opt/keepalived-1.4.2/
[[email protected] keepalived-1.4.2]# yum-y install \
GCC \
gcc-c++ \
Make
[Email protected] keepalived-1.4.2]#/configure--prefix=/
[[email protected] keepalived-1.4.2]# make && make install
[Email protected] keepalived]# cp-r/opt/keepalived-1.4.2/keepalived/etc/keepalived//ETC/INIT.D
[Email protected] keepalived]# Systemctl enable keepalived
--------------------------------Modify the configuration file (main scheduler)-------------
[Email protected] keepalived]# vi/etc/keepalived/keepalived.conf
! Configuration File for Keepalived
Global_defs {
Notification_email {br/>[email protected]
[Email protected]Br/>[email protected]
Notification_email_from[email protected]
Smtp_server 192.168.200.1
Smtp_connect_timeout 30
router_id lvs_01
}

Vrrp_instance Vi_1 {
State MASTER
Interface Ens33
VIRTUAL_ROUTER_ID 51
Priority 110
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 6666
}
virtual_ipaddress {
192.168.80.188
}
}
Virtual_server 192.168.80.188 80 {
Delay_loop 6
Lb_algo RR
Lb_kind DR
Persistence_timeout 60
Protocol TCP
Real_server 192.168.80.101 80 {
Weight 1
Tcp_check {
Connect_port 80
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}
Real_server 192.168.80.102 80 {
Weight 1
Tcp_check {
Connect_port 80
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}
}
[[email protected]keepalived]# Service keepalived Start
[[email protected]keepalived]# IP addr Show Dev ens33//Verify that the virtual address is bound
inet 192.168.80.188/32 Scope Global ENS33
[[email protected]keepalived]# ipvsadm-l
[[email protected]keepalived]# tail-f/var/log/messages//Shutdown Verification for Business Server and main scheduler hot standby and Health check effect.
Master State represents the primary server
Backup state stands for standby server

---------------------------------Modify the configuration file (from the scheduler)-----------------
[[email protected]~]# modprobe Ip_vs
[[email protected]~]# rpm-ivh/mnt/packages/ipvsadm-1.27-7.el7.x86_64.rpm
[[email protected]~]# yum-y install \
GCC \
gcc-c++ \
Make
[[email protected]~]# Tar FX keepalived-1.4.2.tar.gz-c/opt
[[email protected]~]# cd/opt/keepalived-1.4.2/
[[email protected]keepalived-1.4.2]#./configure--prefix=/
[[email protected]keepalived-1.4.2]# make && make install
[[email protected]keepalived-1.4.2]# Cp-r keepalived/etc/init.d/keepalived/etc/init.d/
[[email protected]keepalived-1.4.2]# Systemctl Enable keepalived
[[email protected]keepalived-1.4.2]# vi/etc/keepalived/keepalived.conf
! Configuration File for Keepalived

Global_defs {
Notification_email {
[email protected]
}
Notification_email_from benet [email protected]
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
router_id lvs_02//Master or slave is not the same
}

Vrrp_instance Vi_1 {
State BACKUP//hot standby from Scheduler
Interface Ens33
VIRTUAL_ROUTER_ID 51//Number Master is the same as from both sides.
Priority 105//precedence from Scheduler
Advert_int 1
Authentication {//master, from hot standby authentication information
Auth_type PASS
Auth_pass 6666
}
virtual_ipaddress {//Specifies the cluster VIP address (virtual server address), you can specify multiple
192.168.80.188
}
}

Virtual_server 192.168.80.188 80 {//Virtual server address (VIP), Port
Delay_loop 6//Health check interval (seconds) is normal.
Lb_algo RR//polling (RR) scheduling algorithm
Lb_kind dr//Direct Routing (DR) cluster operating mode
Persistence_timeout 60//Connection hold time, (seconds), if commented out add a "!" At this time, the same client's request is handled by the same server
protocol TCP//application service is using the TCP protocol

Real_server 192.168.80.101 80 {//First Web node address, port
Weight 1///node weight
Tcp_check {//Health check
Connect_port 80//Check for Destination Port
Connect_timeout 3//Connection timeout (seconds)
Nb_get_retry 3//retry attempts
Delay_before_retry 3//retry interval (seconds)
}
}
Real_ Server 192.168.80.102 80 {//second Web node address, port
Weight 1
Tcp_check {
Connect_port
Connect_timeout 3
Nb_ Get_retry 3
Delay_before_retry 3
}
}
}
[ [email protected] keepalived-1.4.2 ]# service keepalived start
[[email  Protected] keepalived-1.4.2]# IP addr Show dev ens33
[[email protected] keepalived-1.4.2]# tail-f/var/log/messages
MASTER State represents the primary server
Backup state represents the standby server

Here is the Web server:
192.168.80.101 Server:
[email protected] ~]# yum install-y httpd
[email protected] ~]# vi/etc/httpd/conf/httpd.confservername www.aa.com
[email protected] ~]# vi/var/www/html/index.html

192.168.80.102 Server:
[email protected] ~]# yum install-y httpd
[email protected] ~]# vi/etc/httpd/conf/httpd.conf
ServerName www.bb.com
[email protected] ~]# vi/var/www/html/index.html

Lvs-dr+keepalived Web server dual-machine hot standby configuration

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.