Keepalived 安装与配置

下载:http://www.keepalived.org/

what is keepalived?

Keepalived is a routing software written in C. The main goal of this project is to provide simple and robust facilities for loadbalancing and high-availability to Linux system and Linux based infrastructures. Loadbalancing framework relies on well-known and widely used Linux Virtual Server (IPVS) kernel module providing Layer4 loadbalancing. Keepalived implements a set of checkers to dynamically and adaptively maintain and manage loadbalanced server pool according their health. On the other hand high-availability is achieved by VRRP protocol. VRRP is a fundamental brick for router failover. In addition, Keepalived implements a set of hooks to the VRRP finite state machine providing low-level and high-speed protocol interactions. Keepalived frameworks can be used independently or all together to provide resilient infrastructures.

下载源代码

./configure --prefix=/opt/keepalived

报错

configure: error: Popt libraries is required

安装popt开发包

yum install popt-devel

安装后configure输出信息

Keepalived configuration
------------------------
Keepalived version : 1.1.10
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto
Use IPVS Framework : No
IPVS sync daemon support : No
Use VRRP Framework : Yes
Use LinkWatch : No
Use Debug flags : No

我上面的IPVS都是no,为no不支持LVS.

看网上的说法

  1. Use IPVS Framework       : Yes  #使用ipvs框架,如果是做keepalive+ha可不要
  2. IPVS sync daemon support : Yes  #对ipvs同步的支持
  3. Use VRRP Framework       : Yes  #keepalive的核心,必须有!

看网上说法要想IPVS为yes,要带上

--with-kernel-dir=/usr/src/kernels/2.6.18-164.el5-i686/

  1. #ln -s /usr/src/kernels/2.6.18-53.el5PAE-i686/  /usr/src/linux //生成一个链接文件
  2. 如果/usr/src/kernels没有2.6.18-194.el5,则需要编译
  3. #yum -y install kernel-devel
  4. #yum -y update kernel
  5. #cp /usr/src/kernels/2.6.18-274.el5/include/net/ip_vs.h        /usr/inclide/net/  //这个很重要,否则在安装ipvsadm的时候会提示缺少*.h文件

我暂时没有支持IPVS.

  1. 安装完成之后,方了方便起见,请执行以下操作:
  2. 1、将安装目录里的/usr/local/keepalive/etc/rc.d/init.d/keepalived 复制到/etc/init.d (这里的安装目录改成自己的)
  3. 2、将安装目录里的配置文件/usr/local/keepalive/etc/keepalived/keepalived.conf 复制到/etc/keepalived/里。

keepalived默认配置文件

! Configuration File for keepalived

global_defs {
   notification_email { 通知email
     [email protected]
     [email protected]
     [email protected]
   }
   notification_email_from [email protected]
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL   #节点名标识,主要用于通知中
}

vrrp_instance VI_1 {

  state MASTER          #配置为主服务器


  interface eth0        #通讯网卡


  virtual_router_id 100 #路由标识


  priority 200          #优先级,0-254


  advert_int 5          #通知间隔,实际部署时可以设置小一点,减少延时


  


  authentication {


    auth_type PASS


    auth_pass 123456    #验证密码,用于通讯主机间验证


  }

    virtual_ipaddress {
        192.168.200.16
        192.168.200.17
        192.168.200.18
    }
}

virtual_server 192.168.200.100 443 {
    delay_loop 6
    lb_algo rr
    lb_kind NAT
    nat_mask 255.255.255.0
    persistence_timeout 50
    protocol TCP

    real_server 192.168.201.100 443 {
        weight 1
        SSL_GET {
            url {
              path /
              digest ff20ad2481f97b1754ef3e12ecd3a9cc
            }
            url {
              path /mrtg/
              digest 9b3a0c85a887a256d6939da88aabd8cd
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

virtual_server 10.10.10.2 1358 {
    delay_loop 6
    lb_algo rr
    lb_kind NAT
    persistence_timeout 50
    protocol TCP

    sorry_server 192.168.200.200 1358

    real_server 192.168.200.2 1358 {
        weight 1
        HTTP_GET {
            url {
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url {
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url {
              path /testurl3/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }

    real_server 192.168.200.3 1358 {
        weight 1
        HTTP_GET {
            url {
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334c
            }
            url {
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334c
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

virtual_server 10.10.10.3 1358 {
    delay_loop 3
    lb_algo rr
    lb_kind NAT
    nat_mask 255.255.255.0
    persistence_timeout 50
    protocol TCP

    real_server 192.168.200.4 1358 {
        weight 1
        HTTP_GET {
            url {
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url {
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url {
              path /testurl3/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }

    real_server 192.168.200.5 1358 {
        weight 1
        HTTP_GET {
            url {
              path /testurl/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url {
              path /testurl2/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            url {
              path /testurl3/test.jsp
              digest 640205b7b0fc66c1ea91c463fac6334d
            }
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
        }
    }
}

参考:

http://my.oschina.net/zyc1016/blog/138574

时间: 2024-08-08 09:42:01

Keepalived 安装与配置的相关文章

Keepalived安装与配置

一.简介 Keepalived是一个免费开源的,用C编写的类似于layer3, 4 & 7交换机制软件,具备我们平时说的第3层.第4层和第7层交换机的功能.主要提供loadbalancing(负载均衡)和 high-availability(高可用)功能,负载均衡实现需要依赖Linux的虚拟服务内核模块(ipvs),而高可用是通过VRRP协议实现多台机器之间的故障转移服务. 上图是Keepalived的功能体系结构,大致分两层:用户空间(user space)和内核空间(kernel space

keepalived安装和配置(debian)

一.keepalived介绍及搭建环境说明 1.The keepalived The keepalived server implements the vrrpd routing demon which enables routing failover for a pair (or set) of routers (or LVS directors) and the keepalived demon which sets up and does the health checking of vi

keepalived安装与配置,组建高可用服务器

一.准备环境 linux系统:CentOS7 keepalived版本:keepalived-1.3.5.tar.gz keepalived下载地址:http://www.keepalived.org/download.html 在CentOS7系统中安装keepalived(主.从服务器都要安装): 关闭CentOS7防火墙 关闭selinux策略 下载keepalived依赖包gcc.openssl yum install gcc yum install openssl-devel 二.安装

keepalived安装及配置

一.keepalived安装 keepalived是一个检测服务器状态的脚本,在高可用机制上经常可以看到它的身影. 在Linux中安装keepalived: 1.在网上直接下载相应的压缩包,推荐链接 https://www.keepalived.org/software/ ,在这里可以选择自己需要的版本下载 2.将下载后的压缩包解压,如下图 3.进入解压后的文件夹中,执行 ./configure 如果报下图所示警告 解决方案:执行 yum install -y openssl openssl-d

Linux下Keepalived 安装与配置

一.环境说明 1.操作系统内核版本:2.6.9-78.ELsmp 2.Keepalived软件版本:keepalived-1.1.20.tar.gz 二.环境配置 1.主Keepalived服务器IP地址 192.168.111.223 2.备Keepalived服务器IP地址  192.168.111.100 3.Keepalived虚拟IP地址  192.168.111.150 三.软件下载地址 http://www.keepalived.org/software/keepalived-1.

高性能集群软件Keepalived的介绍以及安装与配置

Keepalived介绍: Keepalived是Linux下一个轻量级的高可用解决方案:起初是为LVS设计的,专门用来监控集群系统中各个服务节点的状态.它根据TCP/IP参考模型的第三.第四和第五层交换机机制检测每个服务节点的状态,如果某个服务节点出现异常,或工作出现故障,Keepalived将检测到,并将出现故障的服务节点从集群系统中剔除,而在故障节点恢复正常后,Keepalived又可以自动将此服务节点重新加入服务器集群中,这些工作全部自动完成,不需要人工干涉,需要人工完成的只是修复出现故

Keepalived安装配置

1.安装依赖包 yum -y install libnl libnl-devel yum install -y libnfnetlink libnfnetlink-devel rpm -ivhlibnfnetlink-1.0.0-1.el6.x86_64.rpm libnfnetlink-devel-1.0.0-1.el6.x86_64.rpm 2.安装Keepalived cd /app tar -zxfkeepalived-1.3.5.tar.gz cd/app/keepalived-1.3

Keepalived 的安装和配置

keepalived主要用作RealServer的健康状态检查以及LoadBalance主机和BackUP主机之间failover的实现.keepalived主要目的在于,其自身启动一个服务,能够实现工作在双节点或多个节点上,并且可以在内核生效的ipvs规则其中当前持有资源的节点被称为活跃节点,另外的节点被称为备节点被称为 Master/Backup. VRRP(如果有学习过TCP\IP,这一块很好理解): 虚拟路由器冗余协议(VRRP)是一种选择协议,它可以把一个虚拟路由器的责任动态分配到局域

MYSQL + MHA +keepalive + VIP安装配置(三)--keepalived安装配置

一.概述 keepalived介绍:Keepalived的作用是检测web服务器的状态,如果有一台web服务器死机,或工作出现故障,Keepalived将检测到,并将有故障的web 服务器从系统中剔除,当web服务器工作正常后Keepalived自动将web服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人 工做的只是修复故障的web服务器. 二.环境 ? 1 2 3 vip:192.168.1.203\204 mysql-master:192.168.1.231 mysql-