NodeA
vi /etc/keepalived/keepalived.conf
systemctl enable keepalived && systemctl start keepalived && systemctl status keepalived
! Configuration File for keepalived
global_defs {
notification_email {
13802883042@139.com
}
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id NodeA
}
vrrp_script chk {
# script "/apps/sh/#app#_check.sh"
interval 2
weight -1
}
vrrp_instance VI_1 {
state MASTER
# 修改网卡
interface ens192
virtual_router_id 186
# 优先级
priority 100
advert_int 1
smtp alert
track_interface {
ens192
}
# track_script {
# chk
# }
authentication {
auth_type PASS
auth_pass kePw@019
}
virtual_ipaddress {
192.168.40.114/24 dev ens192 label ens192:1
}
}
vi /etc/haproxy/haproxy.cfg
systemctl enable haproxy && systemctl restart haproxy && systemctl status haproxy
global
chroot /var/lib/haproxy
log 127.0.0.1 local2
maxconn 65536
user haproxy
group haproxy
nbproc 1
ulimit-n 231097
pidfile /var/run/haproxy.pid
daemon
defaults
log global
mode http
option httplog
option dontlognull
option forwardfor
option redispatch
retries 3
maxconn 65535
timeout connect 5s
timeout client 30s
timeout server 30s
timeout check 1s
timeout http-request 10s
timeout http-keep-alive 10s
listen Stats
bind *:10000
mode http
stats enable
stats uri /stats
stats show-node
stats show-legends
stats auth admin:Admin@139
frontend http_web
bind 0.0.0.0:30432
mode http
log global
option httplog
option httpclose
default_backend vip_1_servers
backend vip_1_servers
balance leastconn
http-request set-header Host cdn.service.com
server nodeA 192.168.40.11:80 maxconn 10000 check inter 3000 fall 3 rise 5
server nodeB 192.168.40.15:80 check inter 3000 fall 3 rise 5
NodeB
vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
13802883042@139.com
}
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id NodeB
}
vrrp_script chk {
# script "/apps/sh/#app#_check.sh"
interval 2
weight -1
}
vrrp_instance VI_1 {
state BACKUP
interface ens192
virtual_router_id 186
priority 98
advert_int 1
smtp alert
track_interface {
ens192
}
# track_script {
# chk
# }
authentication {
auth_type PASS
auth_pass kePw@019
}
virtual_ipaddress {
192.168.40.114/24 dev ens192 label ens192:1
}
}
vi /etc/haproxy/haproxy.cfg
global
chroot /var/lib/haproxy
log 127.0.0.1 local2
maxconn 65536
user haproxy
group haproxy
nbproc 1
ulimit-n 231097
pidfile /var/run/haproxy.pid
daemon
defaults
log global
mode http
option httplog
option dontlognull
option forwardfor
option redispatch
retries 3
maxconn 65535
timeout connect 5s
timeout client 30s
timeout server 30s
timeout check 1s
timeout http-request 10s
timeout http-keep-alive 10s
listen Stats
bind *:10000
mode http
stats enable
stats uri /stats
stats show-node
stats show-legends
stats auth admin:Admin@139
frontend http_web
bind 0.0.0.0:30432
mode http
log global
option httplog
option httpclose
default_backend vip_1_servers
backend vip_1_servers
balance leastconn
http-request set-header Host cdn.service.com
server nodeA 192.168.40.11:80 maxconn 10000 check inter 3000 fall 3 rise 5
server nodeB 192.168.40.15:80 check inter 3000 fall 3 rise 5