Install Haproxy Keppalived on CentOS 6.5

Haproxy/Keepalived Server1: 192.168.1.253
Haproxy/Keepalived Server2: 192.168.1.254
Haproxy/Keepalived VIP: 192.168.1.250

Haproxy/Keepalived Server1:

1. echo "net.ipv4.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
sysctl -p

yum -y install keepalived haproxy

2. cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.bak
vi /etc/keepalived/keepalived.conf
global_defs {
   notification_email {
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id centos65-2
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.250
    }
}
下面的都删除

1). Priority value will be higher on Master server
2). virtual_router_id should be same on both servers
3). By default single vrrp_instance support up to 20 virtual_ipaddress

3. service keepalived start; chkconfig keepalived on
ip addr show eth0

4. vi /etc/haproxy/haproxy.cfg
注释原有的frontend和backend
frontend web 192.168.1.250:8080
        default_backend web

listen stats 192.168.1.253:8080
        mode http
        stats enable
        stats uri /

backend web
        balance leastconn
        server web01 192.168.1.253:80 check
        server web02 192.168.1.254:80 check

service haproxy start; chkconfig haproxy on

Haproxy/Keepalived Server2:

1. echo "net.ipv4.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
sysctl -p

yum -y install keepalived haproxy

2. cp /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.bak
vi /etc/keepalived/keepalived.conf
global_defs {
   notification_email {
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id centos65
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 90
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
        192.168.1.250
    }
}
下面的都删除

3. service keepalived start; chkconfig keepalived on
ip addr show eth0

4. vi /etc/haproxy/haproxy.cfg
注释原有的frontend和backend
frontend web 192.168.1.250:8080
        default_backend web

listen stats 192.168.1.254:8080
        mode http
        stats enable
        stats uri /

backend web
        balance leastconn
        server web01 192.168.1.253:80 check
        server web02 192.168.1.254:80 check

service haproxy start; chkconfig haproxy on

时间: 2024-12-29 01:40:06

Install Haproxy Keppalived on CentOS 6.5的相关文章

Install Nginx/PHP-FPM on CentOS/RHEL

Install Nginx, PHP 5.5.15 and PHP-FPM on Fedora 20/19/18/17, CentOS 7/6.5/5.10, Red Hat (RHEL) 7/6.5/5.10 1. Change to root user. su 2. Install needed repositories CentOS 7/6.5/5.10 and Red Hat (RHEL) 7/6.5/5.10 Remi repository  ## Remi Dependency on

Install .Net Core For CentOS 6.5(最后失败了)

Install .NET Core SDK Before you start, please remove any previous versions of .NET Core from your system. In order to install .NET Core 1.1 on CentOS or Oracle Linux, first you need to get the prerequisites and then you download the .NET Core SDK bi

[转载]How to Install Firefox 33 on CentOS, Redhat and Other Linux Distributions

FROM: http://tecadmin.net/install-firefox-on-linux/ Firefox 33 has been released for Systems and Android on October 13, 2014 with various bug fixes and updates. Below is the list of few changes which is made in Firefox 33. Read more details about thi

How to install redis server on CentOS 7 / RHEL 7

How to install redis server on CentOS 7 / RHEL 7 October 4, 2014 by sharad chhetri Leave a Comment In this tutorial we will learn, how to install redis server on CentOS 7 / RHEL 7 . The abbreviation of redis is REmote DIctionary Server. It is one the

Install CDH5.11 on CentOS 7

##1)Environment initialization Note:At least three nodes,  the Master node at least 6G of memory,  and the other two at least 4G of memory |--------------|-----------|-------------|----------------|-----------|--------------------|-------------| | Ho

cuda install for caffe at centos 总结

cuda install at centos 全过程. 2015年5月15日,亲测通过. wget http://developer.download.nvidia.com/compute/cuda/repos/rhel6/x86_64/cuda-repo-rhel6-7.0-28.x86_64.rpm rpm -ivh cuda-repo-rhel6-7.0-28.x86_64.rpm wget http://pkgs.repoforge.org/rpmforge-release/rpmfor

Install Open vSwitch on CentOS

转载:http://cloud-mate.org/2015/06/installing-open-vswitch-centos-cloudstack/ June 5, 2015  Stuart Nelson  CloudStack, Openstack Installing Open vSwitch on CentOS 6.6 I would like to use Open vSwitch on my KVM nodes in my CloudStack deployment. I will

How to install VNC server on CentOS 6

参考: https://rbgeek.wordpress.com/2012/06/26/how-to-install-vnc-server-on-centos-6/ VNC is a protocol that is used to share the desktop with other users/computers over the network/Internet.In order to share a desktop, VNC server must be install and co

PostgreSQL 11 install with jit on CentOS 7.5 X64

1.system infoCentOS Linux release 7.5.1804 X86_64 2.disable selinux and firewalld install require os packages-# yum install -y epel-release-# yum install -y gcc gcc-c++ readline-devel zlib-devel libicu-devel 4.llvm install1).cmake-# wget https://cmak