add
This commit is contained in:
28
4-广西移动项目/高可用配置/NFS存储/keepalived-1.conf
Normal file
28
4-广西移动项目/高可用配置/NFS存储/keepalived-1.conf
Normal 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
|
||||
}
|
||||
}
|
||||
28
4-广西移动项目/高可用配置/NFS存储/keepalived-2.conf
Normal file
28
4-广西移动项目/高可用配置/NFS存储/keepalived-2.conf
Normal 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
|
||||
}
|
||||
}
|
||||
12
4-广西移动项目/高可用配置/NFS存储/nfs_check.sh
Normal file
12
4-广西移动项目/高可用配置/NFS存储/nfs_check.sh
Normal 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
|
||||
10
4-广西移动项目/高可用配置/master高可用/apiserver_check.sh
Normal file
10
4-广西移动项目/高可用配置/master高可用/apiserver_check.sh
Normal 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
|
||||
28
4-广西移动项目/高可用配置/master高可用/keepalived-1.conf
Normal file
28
4-广西移动项目/高可用配置/master高可用/keepalived-1.conf
Normal 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
|
||||
}
|
||||
}
|
||||
28
4-广西移动项目/高可用配置/master高可用/keepalived-2.conf
Normal file
28
4-广西移动项目/高可用配置/master高可用/keepalived-2.conf
Normal 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
|
||||
}
|
||||
}
|
||||
28
4-广西移动项目/高可用配置/master高可用/keepalived-3.conf
Normal file
28
4-广西移动项目/高可用配置/master高可用/keepalived-3.conf
Normal 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
|
||||
}
|
||||
}
|
||||
12
4-广西移动项目/高可用配置/master高可用/kubelet-check.sh
Normal file
12
4-广西移动项目/高可用配置/master高可用/kubelet-check.sh
Normal 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
|
||||
5
4-广西移动项目/高可用配置/readme.txt
Normal file
5
4-广西移动项目/高可用配置/readme.txt
Normal 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
|
||||
33
4-广西移动项目/高可用配置/前端负载均衡/haproxy.cfg
Normal file
33
4-广西移动项目/高可用配置/前端负载均衡/haproxy.cfg
Normal 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.
|
||||
10
4-广西移动项目/高可用配置/前端负载均衡/haproxy_check.sh
Normal file
10
4-广西移动项目/高可用配置/前端负载均衡/haproxy_check.sh
Normal 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
|
||||
28
4-广西移动项目/高可用配置/前端负载均衡/keepalived-1.conf
Normal file
28
4-广西移动项目/高可用配置/前端负载均衡/keepalived-1.conf
Normal 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
|
||||
}
|
||||
}
|
||||
28
4-广西移动项目/高可用配置/前端负载均衡/keepalived-2.conf
Normal file
28
4-广西移动项目/高可用配置/前端负载均衡/keepalived-2.conf
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user