! Configuration File for keepalived
global_defs {
notification_email { #通知的email,需要系統支持發送email
}
notification_email_from [email protected]
smtp_server 192.168.200.1 #用於發送通知電子郵件的遠程SMTP服務器。
smtp_connect_timeout 30 #SMTP服務器連接超時(以秒爲單位)。
router_id LVS_DEVEL #標識信息,一個名字而已
vrrp_mcast_group4 224.0.0.18 #用於IPv4 VRRP廣告的組播組,默認值:224.0.0.18
vrrp_mcast_group6 ff02 :: 12 #用於IPv6 VRRP廣告的組播組,默認值:ff02 :: 12
vrrp_garp_master_refresh 60 #在MASTER期間刷新免費ARP的最小時間間隔,默認值:0,不刷新
vrrp_garp_master_refresh_repeat 2 #在MASTER時一次發送的免費ARP消息數,默認值:1
vrrp_garp_interval 0.001 #接口發送免費ARP報文的時間間隔(毫秒)十進制,秒(分辨率usecs) 默認值:0)
vrrp_gna_interval 0.000001 #接口上主動發送的NA消息之間的延遲時間(毫秒)十進制,秒(分辨率usecs)(默認值:0)。
# Checking all the addresses in a received VRRP advert can be time
# consuming. Setting this flag means the check won't be carried out
# if the advert is from the same master router as the previous advert
# received.
# (default: don't skip)
vrrp_skip_check_adv_addr
# Enforce strict VRRP protocol compliance. This will prohibit:
# 0 VIPs
# unicast peers
# IPv6 addresses in VRRP version 2
# 通過ip addr可以看到vip已經順利掛載,但是無法ping通,並且防火牆都已關閉:
#原因是keepalived.conf配置中默認vrrp_strict 打開了,需要把它註釋掉。
# 重啓keepalived即可ping通。
vrrp_strict
# The following options can be used if vrrp, checker or bfd processes
# are timing out. This can be seen by a backup vrrp instance becoming
# master even when the master is still running because the master or
# backup system is too busy to process vrrp packets.
# --
# Set the vrrp child process priority (Negative values increase priority)
vrrp_priority <-20 to 19>
# Set the checker child process priority
checker_priority <-20 to 19>
# Set the BFD child process priority
bfd_priority <-20 to 19>
# Set the default VRRP version to use
# (default: 2 , but IPv6 instances will use version 3)
vrrp_version <2 or 3>
}
vrrp_instance VI_1 {
state MASTER #角色是master
interface ens6 #vip 綁定端口
virtual_router_id 51 #讓master 和backup在同一個虛擬路由裏,id 號必須相同;
priority 100 #優先級,誰的優先級高誰就是master ;
advert_int 1 #心跳間隔時間
authentication {
auth_type PASS #認證方式
auth_pass 1111 #密碼
}
virtual_ipaddress { #虛擬ip,可以多個
192.168.200.16
}
}
LVS的配置:
LVS配置後面再來補充