首页
导航
统计
留言
更多
壁纸
直播
关于
推荐
星的导航页
星的云盘
谷歌一下
腾讯视频
Search
1
Ubuntu安装 kubeadm 部署k8s 1.30
88 阅读
2
rockylinux 9.3详细安装drbd+keepalived
73 阅读
3
kubeadm 部署k8s 1.30
72 阅读
4
rockylinux 9.3详细安装drbd
68 阅读
5
ceshi
52 阅读
默认分类
日记
linux
docker
k8s
golang
prometheus
ELK
Jenkins
登录
/
注册
Search
标签搜索
k8s
linux
docker
drbd+keepalivde
ansible
dcoker
webhook
星
累计撰写
41
篇文章
累计收到
46
条评论
首页
栏目
默认分类
日记
linux
docker
k8s
golang
prometheus
ELK
Jenkins
页面
导航
统计
留言
壁纸
直播
关于
推荐
星的导航页
星的云盘
谷歌一下
腾讯视频
搜索到
1
篇与
的结果
2023-07-17
rockylinux 9.3详细安装drbd+keepalived
drbd参考上一篇博客先明确主服务器的keepalivde的配置drbd关闭时执行的脚本 keepalivde关闭时执行的脚本 故障恢复主服务器自动抢回vip的脚本 脚本记得给执行权限从服务器的keepalivde的配置主服务器失效后,从服务器自动挂载,并且成为主服务器,vip也会跟随过来。 原主服务器正常后,主服务器自动降为从服务器,并且取消挂载,vip也会自动转移走。两台主机操作drbdadm status #确定drbd正常工作 dnf install -y keepalivedalpha节点操作/etc/keepalived/keepalived.conf! Configuration File for keepalived global_defs { notification_email { root@localhost } notification_email_from keepalived@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id DRBD_HA_MASTER } vrrp_script chk_drbd { script "/etc/keepalived/check_drbd.sh" interval 5 } vrrp_instance VI_1 { state MASTER interface ens160 virtual_router_id 51 priority 150 advert_int 1 authentication { auth_type PASS auth_pass 1111 } track_script { chk_drbd } notify_stop /etc/keepalived/notify_stop.sh ### keepalived服务关闭执行的脚本 notify_master /etc/keepalived/notify_master.sh ### 重新拿回 master 的脚本 virtual_ipaddress { 192.168.110.88 ### vip 请选择一个没有在占用的IP地址 } }通过上面的配置文件,这里需要编写三个脚本,如下:/etc/keepalived/check_drbd.sh#!/bin/bash # Author:hukey systemctl is-active --quiet drbd if [ $? -ne 0 ]; then systemctl start drbd if [ $? -ne 0 ]; then umount /mnt drbdadm secondary drbd0 systemctl stop keepalived fi fi/etc/keepalived/notify_stop.sh#!/bin/bash # Author:hukey time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_stop------\n" >> /etc/keepalived/logs/notify_stop.log umount /mnt drbdadm secondary drbd0 /usr/sbin/fuser -k /mnt &>> /etc/keepalived/logs/notify_stop.log /bin/umount /mnt &>> /etc/keepalived/logs/notify_stop.log echo -e "\n" >> /etc/keepalived/logs/notify_stop.log/etc/keepalived/notify_master.sh#!/bin/bash # Author:hukey time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_master------\n" >> /etc/keepalived/logs/notify_master.log systemctl start drbd &>> /etc/keepalived/logs/notify_master.log for (( i=1; i <=3; i++)) do drbdadm status | egrep -q 'Primary' if [ $? -ne 0 ]; then mount /mnt drbdadm primary drbd0 /bin/mount /dev/drbd0 /mnt &>> /etc/keepalived/logs/notify_master.log break else sleep 3 fi done echo -e "\n" >> /etc/keepalived/logs/notify_master.脚本所需目录和命令yum install -y psmisc mkdir -pv /etc/keepalived/logs------------------------alpha节点操作完毕------------------------bravo节点操作/etc/keepalived/keepalived.conf! Configuration File for keepalived global_defs { notification_email { root@localhost } notification_email_from keepalived@localhost smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id DRBD_HA_BACKUP } vrrp_instance VI_1 { state BACKUP interface ens160 virtual_router_id 51 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 1111 } notify_master /etc/keepalived/notify_master.sh notify_backup /etc/keepalived/notify_backup.sh virtual_ipaddress { 192.168.110.88 } }/etc/keepalived/notify_master.sh#!/bin/bash # Author:hukey time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_master------\n" >> /etc/keepalived/logs/notify_master.log systemctl start drbd &>> /etc/keepalived/logs/notify_master.log for (( i=1; i <=3; i++)) do drbdadm status | egrep -q 'Primary' if [ $? -ne 0 ]; then drbdadm primary drbd0 mount /dev/drbd0 /mnt /bin/mount /dev/drbd0 /mnt &>> /etc/keepalived/logs/notify_master.log break else sleep 3 fi done echo -e "\n" >> /etc/keepalived/logs/notify_master.log/etc/keepalived/notify_backup.sh#!/bin/bash # Author:hukey time=`date "+%F %H:%M:%S"` echo -e "$time ------notify_backup------\n" &>> /etc/keepalived/logs/notify_backup.log umount /mnt drbdadm secondary drbd0 /usr/sbin/fuser -k /data &>> /etc/keepalived/logs/notify_backup.log /bin/umount /dev/drbd0 &>> /etc/keepalived/logs/notify_backup.log echo $time echo -e "\n" &>> /etc/keepalived/logs/notify_backup.log启动服务 两台主机操作#开机自启 systemctl enable drbd keepalived systemctl restart drbd keepalived启动后查看 alpha 节点 VIP 和 目录是否挂载:注意: 如果发现 vip 或者 drbd 没有挂载,检查一下配置文件是否有问题。测试1.关闭 alpha 节点 keepalived 服务systemctl stop keepalived2.查看 bravo 节点是否升级为主节点3.alpha开启节点 keepalived 服务 bravo 节点关闭keepalived 服务如果vip会自动漂移和会自动挂载就说明成功了还有一个可以测试的,主服务器systemctl stop drbd,五秒后使用systemctl status drbd查看,如果已经启动说明脚本基本没问题。最后drbd+keepalived就完成了,还可以加上nfs。nfs比较简单就不写了。。。
2023年07月17日
73 阅读
13 评论
0 点赞