This commit is contained in:
zeaslity
2024-10-30 16:30:51 +08:00
commit 437acbeb63
3363 changed files with 653948 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
! Configuration File for keepalived
global_defs {
router_id nfs-1 ##标识节点的字符串通常为本机hostname
}
vrrp_script chk_nfs {
script "/etc/nfs/nfs_check.sh" ##执行脚本位置
interval 2 ##检测时间间隔
weight -20 ##如果条件成立则权重减20
}
vrrp_instance VI_1 {
state MASTER ## 主节点为MASTER备份节点为BACKUP-该配置非常重要
interface ens5 ## 绑定虚拟IP的网络接口网卡可以使用ifconfig查看
virtual_router_id 110 ## 虚拟路由ID号主备节点一定要相同-该配置非常重要
mcast_src_ip 10.165.81.79 ## 本机ip地址
priority 100 ##优先级配置0-254的值,一般主节点的权重大于备份节点
nopreempt
advert_int 2 ## 组播信息发送间隔俩个节点必须配置一致默认1s
authentication { ## 认证匹配
auth_type PASS
auth_pass woshinibaba
}
track_script {
chk_nfs
}
virtual_ipaddress {
10.165.81.88 ## 虚拟ip
}
}

View File

@@ -0,0 +1,28 @@
! Configuration File for keepalived
global_defs {
router_id nfs-2 ##标识节点的字符串通常为本机hostname
}
vrrp_script chk_nfs {
script "/etc/nfs/nfs_check.sh" ##执行脚本位置
interval 2 ##检测时间间隔
weight -20 ##如果条件成立则权重减20
}
vrrp_instance VI_1 {
state BACKUP ## 主节点为MASTER备份节点为BACKUP-该配置非常重要
interface ens5 ## 绑定虚拟IP的网络接口网卡可以使用ifconfig查看
virtual_router_id 110 ## 虚拟路由ID号主备节点一定要相同-该配置非常重要
mcast_src_ip 10.165.81.80 ## 本机ip地址
priority 100 ##优先级配置0-254的值,一般主节点的权重大于备份节点
nopreempt
advert_int 2 ## 组播信息发送间隔俩个节点必须配置一致默认1s
authentication { ## 认证匹配
auth_type PASS
auth_pass woshinibaba
}
track_script {
chk_nfs
}
virtual_ipaddress {
10.165.81.88 ## 虚拟ip
}
}

View File

@@ -0,0 +1,12 @@
#!/bin/bash
COUNT=`netstat -ntlp | grep rpc | wc -l`
if [ $COUNT -eq 0 ];then
systemctl restart nfs-kernel-server.service
sleep 2
if [ `ps -C nfsd --no-header |wc -l` -eq 0 ];then
killall keepalived
fi
fi

View File

@@ -0,0 +1,10 @@
#!/bin/bash
COUNT=`ps -C haproxy --no-header |wc -l`
if [ $COUNT -eq 0 ];then
/usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg
sleep 2
if [ `ps -C haproxy --no-header |wc -l` -eq 0 ];then
killall keepalived
fi
fi

View File

@@ -0,0 +1,28 @@
! Configuration File for keepalived
global_defs {
router_id master-1 ##标识节点的字符串通常为本机hostname
}
vrrp_script chk_apiserver {
script "/etc/keepalived/apiserver_check.sh" ##执行脚本位置
interval 2 ##检测时间间隔
weight -20 ##如果条件成立则权重减20
}
vrrp_instance VI_1 {
state MASTER ## 主节点为MASTER备份节点为BACKUP-该配置非常重要
interface ens5 ## 绑定虚拟IP的网络接口网卡可以使用ifconfig查看
virtual_router_id 100 ## 虚拟路由ID号主备节点一定要相同-该配置非常重要
mcast_src_ip 10.165.81.68 ## 本机ip地址
priority 200 ##优先级配置0-254的值,一般主节点的权重大于备份节点
nopreempt
advert_int 2 ## 组播信息发送间隔俩个节点必须配置一致默认1s
authentication { ## 认证匹配
auth_type PASS
auth_pass woshinibaba
}
track_script {
chk_apiserver
}
virtual_ipaddress {
10.165.81.89 ## 虚拟ip
}
}

View File

@@ -0,0 +1,28 @@
! Configuration File for keepalived
global_defs {
router_id master-2 ##标识节点的字符串通常为本机hostname
}
vrrp_script chk_apiserver {
script "/etc/keepalived/apiserver_check.sh" ##执行脚本位置
interval 2 ##检测时间间隔
weight -20 ##如果条件成立则权重减20
}
vrrp_instance VI_1 {
state BACKUP ## 主节点为MASTER备份节点为BACKUP-该配置非常重要
interface ens5 ## 绑定虚拟IP的网络接口网卡可以使用ifconfig查看
virtual_router_id 100 ## 虚拟路由ID号主备节点一定要相同-该配置非常重要
mcast_src_ip 10.165.81.69 ## 本机ip地址
priority 150 ##优先级配置0-254的值,一般主节点的权重大于备份节点
nopreempt
advert_int 2 ## 组播信息发送间隔俩个节点必须配置一致默认1s
authentication { ## 认证匹配
auth_type PASS
auth_pass woshinibaba
}
track_script {
chk_apiserver
}
virtual_ipaddress {
10.165.81.89 ## 虚拟ip
}
}

View File

@@ -0,0 +1,28 @@
! Configuration File for keepalived
global_defs {
router_id master-3 ##标识节点的字符串通常为本机hostname
}
vrrp_script chk_apiserver {
script "/etc/keepalived/apiserver_check.sh" ##执行脚本位置
interval 2 ##检测时间间隔
weight -20 ##如果条件成立则权重减20
}
vrrp_instance VI_1 {
state BACKUP ## 主节点为MASTER备份节点为BACKUP-该配置非常重要
interface ens5 ## 绑定虚拟IP的网络接口网卡可以使用ifconfig查看
virtual_router_id 100 ## 虚拟路由ID号主备节点一定要相同-该配置非常重要
mcast_src_ip 10.165.81.70 ## 本机ip地址
priority 150 ##优先级配置0-254的值,一般主节点的权重大于备份节点
nopreempt
advert_int 2 ## 组播信息发送间隔俩个节点必须配置一致默认1s
authentication { ## 认证匹配
auth_type PASS
auth_pass woshinibaba
}
track_script {
chk_apiserver
}
virtual_ipaddress {
10.165.81.89 ## 虚拟ip
}
}

View File

@@ -0,0 +1,12 @@
#!/bin/bash
COUNT=`docker ps | grep kubelet | wc -l`
if [ $COUNT -eq 0 ];then
systemctl restart docker
sleep 15
if [ `docker ps | grep kubelet | wc -l` -eq 0 ];then
killall keepalived
fi
fi

View File

@@ -0,0 +1,5 @@
参考文档:
https://kubesphere.io/zh/docs/v3.3/installing-on-linux/high-availability-configurations/set-up-ha-cluster-using-keepalived-haproxy/#keepalived
https://blog.csdn.net/u010602865/article/details/122557108

View File

@@ -0,0 +1,33 @@
global
log /dev/log local0 warning
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
log global
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend web-http
bind *:80
mode tcp
option tcplog
default_backend web-https
backend web-http
mode tcp
option tcplog
option tcp-check
balance roundrobin
default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100
server web-http-1 10.165.81.66:80 check # Replace the IP address with your own.
server web-http-2 10.165.81.67:80 check # Replace the IP address with your own.

View File

@@ -0,0 +1,10 @@
#!/bin/bash
COUNT=`ps -C haproxy --no-header |wc -l`
if [ $COUNT -eq 0 ];then
/usr/local/haproxy/sbin/haproxy -f /etc/haproxy/haproxy.cfg
sleep 2
if [ `ps -C haproxy --no-header |wc -l` -eq 0 ];then
killall keepalived
fi
fi

View File

@@ -0,0 +1,28 @@
! Configuration File for keepalived
global_defs {
router_id web-1 ##标识节点的字符串通常为本机hostname
}
vrrp_script chk_haproxy {
script "/etc/keepalived/haproxy_check.sh" ##执行脚本位置
interval 2 ##检测时间间隔
weight -20 ##如果条件成立则权重减20
}
vrrp_instance VI_2 {
state MASTER ## 主节点为MASTER备份节点为BACKUP-该配置非常重要
interface ens5 ## 绑定虚拟IP的网络接口网卡可以使用ifconfig查看
virtual_router_id 110 ## 虚拟路由ID号主备节点一定要相同-该配置非常重要
mcast_src_ip 10.165.81.66 ## 本机ip地址
priority 100 ##优先级配置0-254的值,一般主节点的权重大于备份节点
nopreempt
advert_int 2 ## 组播信息发送间隔俩个节点必须配置一致默认1s
authentication { ## 认证匹配
auth_type PASS
auth_pass woshinibaba
}
track_script {
chk_haproxy
}
virtual_ipaddress {
10.165.81.86 ## 虚拟ip
}
}

View File

@@ -0,0 +1,28 @@
! Configuration File for keepalived
global_defs {
router_id web-2 ##标识节点的字符串通常为本机hostname
}
vrrp_script chk_haproxy {
script "/etc/keepalived/haproxy_check.sh" ##执行脚本位置
interval 2 ##检测时间间隔
weight -20 ##如果条件成立则权重减20
}
vrrp_instance VI_2 {
state BACKUP ## 主节点为MASTER备份节点为BACKUP-该配置非常重要
interface ens5 ## 绑定虚拟IP的网络接口网卡可以使用ifconfig查看
virtual_router_id 110 ## 虚拟路由ID号主备节点一定要相同-该配置非常重要
mcast_src_ip 10.165.81.67 ## 本机ip地址
priority 100 ##优先级配置0-254的值,一般主节点的权重大于备份节点
nopreempt
advert_int 2 ## 组播信息发送间隔俩个节点必须配置一致默认1s
authentication { ## 认证匹配
auth_type PASS
auth_pass woshinibaba
}
track_script {
chk_haproxy
}
virtual_ipaddress {
10.165.81.86 ## 虚拟ip
}
}