Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Linux under HAProxy + Keepalived dual-availability program     - redis configuration in detail (English) (Database)

- FFmpeg compiled with only H264 decoding library (Programming)

- Java Concurrency: synchronized (Programming)

- 64-bit Windows Server 2012 R2 install Oracle 10g Second Edition (Database)

- Git large file storage will help handle large binary files (Linux)

- Recovery from MySQL master data consistency summary (Database)

- Use DB2 federated access Oracle (Database)

- Python exception summary (Programming)

- Ora-00020: maximum number of processes (500) exceeded (Database)

- PHP interview questions of design patterns (Programming)

- PULL operation mechanism parsing XML Comments (Programming)

- CentOS RedHat YUM Source Extensions Supplement (including 32-bit, 64-bit) (Linux)

- Debian 8 Jessie install LAMP server tutorial (Server)

- Zabbix monitors Nginx status (Server)

- Flow control message transmission between RAC (Database)

- Linux Mint 17 set up the Ruby environment (Linux)

- Use Ansible to bulk manage remote servers (Server)

- How to force Linux users to change the initial password the first time you log in (Linux)

- How to install and use the Snort in Ubuntu 15.04 (Linux)

- 10046 trace only open for a particular SQL statement (Database)

 
         
  Linux under HAProxy + Keepalived dual-availability program
     
  Add Date : 2018-11-21      
         
         
         
  Keepalived role is to detect the web server status, if there is a web server crashes, or job fails, Keepalived will be detected and faulty web server is removed from the system, when the web server is working Keepalived automatically web server was added to the server farm, the work all done automatically, without human intervention, the need to manually do is repair the failed web server.

HAProxy provide high availability, load balancing, and proxy TCP and HTTP-based applications, support for virtual hosts, it is free, fast and reliable a solution. HAProxy especially for those who load oversized web sites that usually they need to maintain or seven treatment sessions. HAProxy run on current hardware, can support thousands of concurrent connections. And its mode of operation so that it can be very simple and safe integration into your current architecture, while protecting your web server is not exposed to the network.

System environment: CenOS 6.5x86_64 Desktop install the selinux and iptables is set to disabled

The main software used:
haproxy-1.5.14.tar.gz
keepalived-1.1.17.tar.gz
nginx-1.7.8.tar.gz

I: the installation process, respectively keepalived on two machines HA:
#tar -zxvf keepalived-1.2.17.tar.gz
#ln -s /usr/src/kernels/2.6.18-128.el5-i686/ / usr / src / linux
#cd keepalived-1.2.17
[Root @ test25 keepalived-1.2.17] # / configure -. With-kernel-dir = / usr / src / kernels / 2.6.32-279.el6.x86_64 /
[Root@test25keepalived-1.2.17] #make
[Root@test25keepalived-1.2.17] #make install
cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/
cp / usr / local / etc / sysconfig / keepalived / etc / sysconfig /
mkdir / etc / keepalived /
cp / usr / local / etc / keepalived / keepalived.conf / etc / keepalived /
cp / usr / local / sbin / keepalived / usr / sbin /
 
Modify the configuration file as follows:
Master:
# Vim / etc / keepalived / keepalived.conf
# Catkeepalived.conf
! ConfigurationFile for keepalived
vrrp_scriptcheck_haproxy {
        script "/etc/keepalived/check_haproxy.sh"
        interval 2
        weight 2
}
global_defs {
            notification_email {
            root @ localhost
}
        notification_email_fromkeepalived@server62.example.com
        smtp_server 127.0.0.1
        smtp_connect_timeout 30
        router_id LVS_DEVEL
}
vrrp_instanceVI_1 {
        state MASTER
        interface eth0
        virtual_router_id 151
        priority 100
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 1111
        }
virtual_ipaddress {
        192.168.1.201
    }
track_script {
        check_haproxy
    }
}
 
BACKUP:
 
# Catkeepalived.conf
 
! ConfigurationFile for keepalived
vrrp_scriptcheck_haproxy {
        script "/etc/keepalived/check_haproxy.sh"
        interval 2
        weight 2
    }
 
global_defs {
        notification_email {
        root @ localhost
    }
        notification_email_fromkeepalived@server63.example.com
        smtp_server 127.0.0.1
        smtp_connect_timeout 30
        router_id LVS_DEVEL
    }
 
vrrp_instanceVI_1 {
        state BACKUP
        interface eth0
        virtual_router_id 151
        priority 50
        advert_int 1
        authentication {
            auth_type PASS
            auth_pass 1111
        }
 
virtual_ipaddress {
        192.168.1.201
    }
track_script {
        check_haproxy
    }
}
 

Host:
#vi /etc/keepalived/check_haproxy.sh
#! / Bin / bash
A = `ps -C haproxy --no-header | wc -l`
if [$ A -eq 0]; then
/ Usr / local / haproxy / sbin / haproxy -f / usr / local / haproxy / conf / haproxy.cfg
echo "haproxy start"
sleep 3
if [ `ps -C haproxy --no-header | wc -l`-eq 0]; then
/etc/init.d/keepalived stop
echo "keepalived stop"
fi
fi
 
Preparation of machine:
#! / Bin / bash
A = `ip a | grep 10.2.32.201 | wc -l`
B = `ps -ef | grep haproxy | grep -v grep | awk '{print $ 2}'`
if [$ A -gt 0]; then
/ Usr / local / haproxy / sbin / haproxy -f / usr / local / haproxy / conf / haproxy.cfg
else
kill -9 $ B
fi
 
# Two machines were executed: chmod 755 /etc/keepalived/check_haproxy.sh

haproxy installation (primary and secondary are the same):
#tar -zxvf haproxy-1.5.14.tar.gz
#cd haproxy-1.5.14
#make TARGET = linux26 PREFIX = / usr / local / haproxy
#makeinstall PREFIX = / usr / local / haproxy
# Cd / usr / local / haproxy /
#mkdir conf
#mkdir logs
#vi haproxy.cfg
global
log127.0.0.1 local0
log127.0.0.1 local1 notice
maxconn 4096
chroot / usr / local / haproxy
uid 99
gid 99
daemon
#debug
#quiet
nbproc 1
pidfile / usr / local / haproxy / logs / haproxy.pid


defaults
log global
mode http
option httplog
option dontlognull
retries 3
#redispatch
maxconn 65535
optionredispatch
timeout connect5000
timeout client50000
timeout server50000
stats uri / haproxy
stats auth admin: admin
 
listen www.linuxidc.com *: 80
cookie SERVERID rewrite
mode http
balance roundrobin
option httpchkHEAD /index.html HTTP / 1.0
server web1 10.2.32.99:80 cookie app1inst1 weight 5check inter 2000 rise 2 fall 5
server web2 10.2.32.110:80 cookie app1inst2 weight 3check inter 2000 rise 2 fall 5

 


II: After the first master and slave, both machines were started:
/etc/init.d/keepalivedstart (if you have not started haproxy, this command will automatically start haproxy)

[Root @ test100 haproxy] # ps -ef | grephaprox
root 30344 1 0 11:43? 00:00:00 /bin/bash/etc/keepalived/check_haproxy.sh
nobody 30349 1 0 11:43 00:? 00: 00 / usr / local / haproxy / sbin / haproxy -f /usr/local/haproxy/conf/haproxy.cfg
[Root @ test100 haproxy] # ps -ef | grepkeepali
root 30337 1 0 11:43? 00:00:00 keepalived -D
root 30339 30337 1 11:43? 00:00:00 keepalived -D
root 30340 30337 1 11:43? 00:00:00 keepalived -D
root 30372 2876 0 11:43 pts / 0 00:00:00 grep keepali

III: Test:
1. again on both HA were executed ip ad sh | grep 10.2.32
the Lord:
inet10.2.32.100 / 24 brd 10.2.32.255 scope global eth0
inet10.2.32.201 / 32 scope global eth0

Preparation:
inet10.2.32.101 / 24 brd 10.2.32.255 scope global eth0

2. haproxy stopped on the main, three seconds after keepalived will automatically start again

3. The Lord stopped keepalived, standby machine to take over the service immediately
Preparation: ip ad sh | grep 10.2.32
inet10.2.32.101 / 24 brd 10.2.32.255 scope global eth0
inet10.2.32.201 / 32 scope global eth0
     
         
         
         
  More:      
 
- Git uses a standard process (Linux)
- Netapp storage routine inspections and information gathering (Linux)
- Windows SmartGit installation (Linux)
- Simple to use Linux GPG (Linux)
- MongoDB collection data migration to MySQL database (Database)
- ELKstack log analysis platform (Server)
- Java garbage collection (Programming)
- Redis is installed in Ubuntu 14.04 (Database)
- Comparison of C # and Java (Programming)
- Using iptables achieve NAT (Linux)
- Django1.5 Custom User Model (Programming)
- Python Socket Network Programming (Programming)
- CentOS6 installation configuration rsh (Server)
- Docker manage data (Linux)
- Vim Common Command Summary (Linux)
- Struts2 dynamic call DMI and error Solution (Programming)
- Du and df show disk space usage inconsistent Causes and Treatment (Linux)
- IDS Intrusion Detection System built (Linux) (Linux)
- Java annotations entry automatically generates SQL statements (Programming)
- Learning UNIX good habits (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.