Keepalived 一

5 篇文章 0 订阅
2 篇文章 0 订阅
本文介绍了如何使用yum安装Keepalived,并展示了Keepalived的配置文件解析,包括全局配置、VRRP配置等。在启动和检查Keepalived服务的过程中,遇到的问题及日志输出进行了分析,显示了配置文件中虚拟IP地址和健康检查的相关设置。
摘要由CSDN通过智能技术生成

 

1、yum install -y keepalived

[root@nginx local]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

2、查看配置文件,配置文件详解

keepalived.conf 是keepalived 的配置文件。

 1、! Configuration File for keepalived   注视 # 或者 ! 开头表示注视。

2、"{ block }" "{" 作为语句块

3、 include filepath,include 命令 包括其他的文件,filepath 可以是绝对路径后者相对路径

4、顶级语句块

TOP HIERACHY
       Keepalived configuration file is articulated around a set of configura-
       tion blocks.  Each block is focusing and targetting a  specific  daemon
       family feature. These features are:

       GLOBAL CONFIGURATION

       BFD CONFIGURATION

       VRRPD CONFIGURATION

       LVS CONFIGURATION
GLOBAL CONFIGURATION
       contains  subblocks of Global definitions, Linkbeat interfaces,
       Static track groups,  Static  addresses,  Static  routes,  and
       Static rules

启动查看状态

[root@nginx ~]# systemctl start keepalived

 查看状态

[root@nginx ~]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; disabled; vendor preset: disabled)
   Active: active (running) since 日 2020-11-15 22:29:49 EST; 2s ago
  Process: 3701 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 3702 (keepalived)
   CGroup: /system.slice/keepalived.service
           └─3702 /usr/sbin/keepalived -D

11月 15 22:29:49 nginx.fandong.com Keepalived_vrrp[3704]: Default interface eth0 does not exist and no interface specified. Skipping static address 192.168.200.18.
11月 15 22:29:49 nginx.fandong.com Keepalived_vrrp[3704]: (VI_1): No VIP specified; at least one is required
11月 15 22:29:49 nginx.fandong.com Keepalived_healthcheckers[3703]: Opening file '/etc/keepalived/keepalived.conf'.
11月 15 22:29:49 nginx.fandong.com Keepalived_healthcheckers[3703]: Activating healthchecker for service [192.168.200.100]:443
11月 15 22:29:49 nginx.fandong.com Keepalived_healthcheckers[3703]: Activating healthchecker for service [10.10.10.2]:1358
11月 15 22:29:49 nginx.fandong.com Keepalived_healthcheckers[3703]: Activating healthchecker for service [10.10.10.2]:1358
11月 15 22:29:49 nginx.fandong.com Keepalived_healthcheckers[3703]: Activating healthchecker for service [10.10.10.3]:1358
11月 15 22:29:49 nginx.fandong.com Keepalived_healthcheckers[3703]: Activating healthchecker for service [10.10.10.3]:1358
11月 15 22:29:50 nginx.fandong.com Keepalived[3702]: Keepalived_vrrp exited with permanent error CONFIG. Terminating
11月 15 22:29:50 nginx.fandong.com Keepalived[3702]: Stopping
[root@nginx keepalived]# cat keepalived.conf 
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 192.168.200.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
   vrrp_skip_check_adv_addr
   vrrp_strict
   vrrp_garp_interval 0
   vrrp_gna_interval 0
}

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.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
    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
    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
        }
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值