LVS-DR + Keepalived Web Server dual-host hot standby configuration

Source: Internet
Author: User

LVS-DR + Keepalived Web Server dual-host hot standby configuration

Keepalived is a software similar to the layer3, 4 & 7 switching mechanism, that is, layer 3rd, layer 4th, and layer 7th switching. Keepalived is automatically completed without manual interference.

Scheduling Server:
It must be done on the basis of LVS.

Reference https://www.bkjia.com/Linux/2018-03/151514.htm

One Network Card:
Vmnet1: 192.168.80.100
The master and slave schedulers perform the following three steps: loading and installing the ipvsadm package
: Http://www.keepalived.org/download.html
[Root @ lss ~] # Modprobe ip_vs
[Root @ lss ~] # Rpm-ivh/mnt/Packages/ipvsadm-1.27-7.el7.x86_64.rpm
--------- Keepalived installation configuration (master and slave must be configured )----
[Root @ lss ~] # Yum-y install popt-devel kernel-devel openssl-devel
WinSCP uploads keepalived to the Master/Slave Server

[Root @ lss ~] # Tar fx keepalived-1.4.2.tar.gz-C/opt
[Root @ lss opt] # cd/opt/keepalived-1.4.2/
[Root @ lss keepalived-1.4.2] # yum-y install \
Gcc \
Gcc-c ++ \
Make
[Root @ lss keepalived-1.4.2] #./configure -- prefix =/
[Root @ lss keepalived-1.4.2] # make & make install
[Root @ lss keepalived] # cp-r/opt/keepalived-1.4.2/keepalived/etc/init. d
[Root @ lss keepalived] # systemctl enable keepalived
------------------------------ Modify the configuration file (Master Scheduler )-------------
[Root @ lss keepalived] # vi/etc/keepalived. conf
! Configuration File for keepalived
Global_defs {
Icationication_email {br/> acassen@firewall.loc
Failover@firewall.locbr> sysadmin@firewall.loc
}
Notification_email_from Alexandre.Cassen@firewall.loc
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
Priority110
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
}
}
}
[Root @ lss keepalived] # service keepalived start
[Root @ lss keepalived] # ip addr show dev ens33 // verify that the virtual address is bound
Inet 192.168.80.188/32 scope global ens33
[Root @ lss keepalived] # ipvsadm-L
[Root @ lss keepalived] # tail-f/var/log/messages // disable the Service server and the master scheduler to verify the hot backup and health check results.
The master state indicates the MASTER server.
Backup state indicates the BACKUP server

--------------------------------- Modify the configuration file (slave Scheduler )-----------------
[Root @ LSS03 ~] # Modprobe ip_vs
[Root @ LSS03 ~] # Rpm-ivh/mnt/Packages/ipvsadm-1.27-7.el7.x86_64.rpm
[Root @ LSS03 ~] # Yum-y install \
Gcc \
Gcc-c ++ \
Make
[Root @ LSS03 ~] # Tar fx keepalived-1.4.2.tar.gz-C/opt
[Root @ LSS03 ~] # Keepalived-1.4.2/cd/opt/
[Root @ LSS03 keepalived-1.4.2] #./configure -- prefix =/
[Root @ LSS03 keepalived-1.4.2] # make & make install
[Root @ LSS03 keepalived-1.4.2] # cp-r keepalived/etc/init. d/keepalived/etc/init. d/
[Root @ LSS03 keepalived-1.4.2] # systemctl enable keepalived
[Root @ LSS03 keepalived-1.4.2] # vi/etc/keepalived. conf
! Configuration File for keepalived

Global_defs {
Notification_email {
Root@localhost.localdomain
}
Notification_email_from benet root@localhost.localdomain
Smtp_server 127.0.0.1
Smtp_connect_timeout 30
Router_id LVS_02 // Master/Slave is not the same
}

Vrrp_instance VI_1 {
State BACKUP // hot standby status of the slave Scheduler
Interface ens33
Virtual_router_id 51 // number. Both sides of the master and slave must be the same
Priority 105 // priority of the slave Scheduler
Advert_int 1
Authentication {// Master/Slave Hot Standby authentication information
Auth_type PASS
Auth_pass 6666
}
Virtual_ipaddress {// specify 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 // the Health Check Interval (in seconds.
Lb_algo rr // round robin (rr) Scheduling Algorithm
Lb_kind DR // direct routing (DR) Cluster Working Mode
Persistence_timeout 60 // connection persistence time (seconds). If you comment out the value, add "! "Requests from the same client are processed by the same server during this time.
Protocol TCP // The Application Service uses the TCP protocol.

Real_server 192.168.80.101 80 {// address and port of the first web Node
Weight 1 // node weight
TCP_CHECK {// Health Check Method
Connect_port 80 // check the target port
Connect_timeout 3 // connection timeout (seconds)
Nb_get_retry 3 // Number of Retries
Delay_before_retry 3 // Retry Interval (seconds)
}
}
Real_server 192.168.80.102 80 {// address and port of the second web Node
Weight 1
TCP_CHECK {
Connect_port 80
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}
}
}
# Service keepalived start
[Root @ LSS03 keepalived-1.4.2] # ip addr show dev ens33
[Root @ LSS03 keepalived-1.4.2] # tail-f/var/log/messages
The master state indicates the MASTER server.
Backup state indicates the BACKUP server

The following are WEB servers:
192.168.80.101 Server:
[Root @ lss01 ~] # Yum install-y httpd
[Root @ lss01 ~] # Vi/etc/httpd/conf/httpd. confServerName www.aa.com
[Root @ lss01 ~] # Vi/var/www/html/index.html
<H1> Server aa

192.168.80.102 Server:
[Root @ lss02 ~] # Yum install-y httpd
[Root @ lss02 ~] # Vi/etc/httpd/conf/httpd. conf
ServerName www.bb.com
[Root @ lss02 ~] # Vi/var/www/html/index.html
<H1> Server bb

This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151516.htm

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.