<>keepalived要点
1、检查机器健康状况 2、绑定Virtual IP 到外网网卡,外网卡需要配置IP,网卡上不配置IP无法绑定VIP 3、故障转移(Virtual
IP切换、切换时执行脚本) 4、配置keepalived的集群部分,会自动补充ipvsadm的配置(需安装ipvsadm)
<>安装
## 允许vrrp协议通过防火墙 firewall-cmd --direct --permanent --add-rule ipv4 filter
INPUT 0 --in-interface[网卡] --destination 224.0.0.18 --protocol vrrp -j ACCEPT
## 224.0.0.18是vrrp组播IP ## 安装依赖 yum install -y gcc gcc-c++ openssl-devel ##
LVS调度程序 lvs_sched rr | wrr | lc | wlc | lblc | sh | mh | dh | fo | ovf | lblcr
| sed | nq
<>配置文件(keepalived.conf)
! Configuration File for keepalived ## 全局函数 global_defs { } ## vrrp
同步组,实现多个VRRP实例捆绑 vrrp_sync_group <STRING> { group { <STRING> ## vrrp实例1
<STRING> ## vrrp实例2 } notify_master /path to you script ## 切换为master时执行脚本
notify_backup /path to you script ## 切换为backup时执行脚本 } ## vrrp实例设置,定义VIP绑定位置
vrrp_instance <instance_name> { ## VRRP实例定义 state BACKUP ## 主从状态,MASTER,BACKUP
interface ens33 ## 网卡接口 virtual_router_id 51 ## 虚拟路由ID priority 100 ## 优先级
advert_int 1 ## --MASTER与BACKUP节点间同步检查的时间间隔,单位为秒 authentication { ## VRRP验证
auth_type PASS auth_pass 1111 } virtual_ipaddress { ## VIP,上限20个 10.0.2.99 } }
## LVS集群 virtual_server 10.0.2.99 80 { ## LVS 虚拟服务定义 delay_loop 2 ##
健康检查时间间隔,单位s lb_algo rr ## lvs负载均衡调度算法设置 lb_kind DR ## lvs负载均衡模式设置 DR NAT TUN
protocol TCP ## 协议 persistence_timeout 50 ## 会话保持时间,单位s 保持时间结束再进行负载调度
real_server [ip] [port] { weight 1 TCP_CHECK { ## 服务器检测方式设置 connect_timeout 8
## 连接超时 nb_get_retry 3 ## 重连次数 delay_before_retry 3 ## 重连间隔时间 connect_port 80
## 健康检查的端口的端口 } } real_server [ip] [port] { weight 1 TCP_CHECK { ## 服务器检测方式设置
connect_timeout 8 ## 连接超时 nb_get_retry 3 ## 重连次数 delay_before_retry 3 ## 重连间隔时间
connect_port 80 ## 健康检查的端口的端口 } } }

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信