当前位置:网站首页>Heartbeat 与DRBD 配置过程
Heartbeat 与DRBD 配置过程
2022-06-30 19:50:00 【星哥玩云】
我的PC机都只有1个网卡,所以我用串口使双机通讯;
192.168.119.1是我的路由器的IP,作为一个域外的服务器,检测域内服务器是否正常;
首先配置host文件:
127.0.0.1 localhost 127.0.1.1 Ubuntu-Bing
192.168.119.102 ubuntu-Bing 192.168.119.103 Lab-Server
拷贝配置文件:
cp /usr/local/ha/share/doc/authkeys /usr/local/ha/etc/ha.d cp /usr/local/ha/share/doc/ha.cf /usr/local/ha/etc/ha.d cp /usr/local/ha/share/doc/haresources /usr/local/ha/etc/ha.d
ha.d文件:
debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local0 keepalive 2 deadtime 30 warntime 10 initdead 120 baud 19200 serial /dev/ttyS0 # Linux auto_failback on node ubuntu-Bing node Lab-Server ping 192.168.119.1 respawn hacluster /usr/lib/ocf/resource.d/heartbeat/pingd -m 100 -d 5s apiauth pingd gid=haclient uid=hacluster
compression bz2 compression_threshold 2
resource.d目录下 drbddisk 脚本
#!/bin/bash # # This script is intended to be used as resource script by heartbeat # # Copright 2003-2008 LINBIT Information Technologies # Philipp Reisner, Lars Ellenberg # ###
DEFAULTFILE="/etc/default/drbd" DRBDADM="/sbin/drbdadm"
if [ -f $DEFAULTFILE ]; then . $DEFAULTFILE fi
if [ "$#" -eq 2 ]; then RES="$1" CMD="$2" else RES="all" CMD="$1" fi
## EXIT CODES # since this is a "legacy heartbeat R1 resource agent" script, # exit codes actually do not matter that much as long as we conform to # http://wiki.linux-ha.org/HeartbeatResourceAgent # but it does not hurt to conform to lsb init-script exit codes, # where we can. # http://refspecs.linux-foundation.org/LSB_3.1.0/ #LSB-Core-generic/LSB-Core-generic/iniscrptact.html ####
drbd_set_role_from_proc_drbd() { local out if ! test -e /proc/drbd; then ROLE="Unconfigured" return fi
dev=$( $DRBDADM sh-dev $RES ) minor=${dev#/dev/drbd} if [[ $minor = *[!0-9]* ]] ; then # sh-minor is only supported since drbd 8.3.1 minor=$( $DRBDADM sh-minor $RES ) fi if [[ -z $minor ]] || [[ $minor = *[!0-9]* ]] ; then ROLE=Unknown return fi
if out=$(sed -ne "/^ *$minor: cs:/ { s/:/ /g; p; q; }" /proc/drbd); then set -- $out ROLE=${5%/**} : ${ROLE:=Unconfigured} # if it does not show up else ROLE=Unknown fi }
case "$CMD" in start) # try several times, in case heartbeat deadtime # was smaller than drbd ping time try=6 while true; do $DRBDADM primary $RES && break let "--try" || exit 1 # LSB generic error sleep 1 done ;; stop) # heartbeat (haresources mode) will retry failed stop # for a number of times in addition to this internal retry. try=3 while true; do $DRBDADM secondary $RES && break # We used to lie here, and pretend success for anything != 11, # to avoid the reboot on failed stop recovery for "simple # config errors" and such. But that is incorrect. # Don't lie to your cluster manager. # And don't do config errors... let --try || exit 1 # LSB generic error sleep 1 done ;; status) if [ "$RES" = "all" ]; then echo "A resource name is required for status inquiries." exit 10 fi ST=$( $DRBDADM role $RES ) ROLE=${ST%/**} case $ROLE in Primary|Secondary|Unconfigured) # expected ;; *) # unexpected. whatever... # If we are unsure about the state of a resource, we need to # report it as possibly running, so heartbeat can, after failed # stop, do a recovery by reboot. # drbdsetup may fail for obscure reasons, e.g. if /var/lock/ is # suddenly readonly. So we retry by parsing /proc/drbd. drbd_set_role_from_proc_drbd esac case $ROLE in Primary) echo "running (Primary)" exit 0 # LSB status "service is OK" ;; Secondary|Unconfigured) echo "stopped ($ROLE)" exit 3 # LSB status "service is not running" ;; *) # NOTE the "running" in below message. # this is a "heartbeat" resource script, # the exit code is _ignored_. echo "cannot determine status, may be running ($ROLE)" exit 4 # LSB status "service status is unknown" ;; esac ;; *) echo "Usage: drbddisk [resource] {start|stop|status}" exit 1 ;; esac
exit 0
先配置好DRBD服务,然后再启动heartbeat服务;测试Heartbeat!
停止主服务器的heartbeat服务,然后查看/mnt/drbd下是否可以看到文件!如果可以,说明成功了!
边栏推荐
- Audio and video architecture construction in the super video era | science and Intel jointly launched the second season of "architect growth plan"
- DNS服务器搭建、转发、主从配置
- pycharm从安装到全副武装,学起来才嗖嗖的快,图片超多,因为过度详细!
- dataloader 源码_DataLoader
- TorchDrug--药物属性预测
- Advanced skills of testers: a guide to the application of unit test reports
- GeoServer安装
- mysql主从同步
- Client请求外部接口标准处理方式
- RP原型资源分享-购物类App
猜你喜欢

NLP技能树学习路线-(一)路线总览

S7-1500 PLC之间进行TCP通信的具体方法和步骤详解(图文)

超视频时代的音视频架构建设|Science和英特尔联袂推出“架构师成长计划”第二季

GeoServer安装

Advanced skills of testers: a guide to the application of unit test reports

企业中台规划和IT架构微服务转型

【450. 删除二叉搜索树中的节点】

Data intelligence - dtcc2022! China database technology conference is about to open

Tencent conference application market was officially launched, with more than 20 applications in the first batch
![Network planning | [five transport layers and six application layers] knowledge points and examples](/img/4f/31acce51b584bed5ef56b2093c4db3.png)
Network planning | [five transport layers and six application layers] knowledge points and examples
随机推荐
腾讯会议应用市场正式上线,首批入驻超20款应用
VR全景拍摄为什么要加盟?巧借资源实现共赢
C language: hashtable
Taihu Lake "China's healthy agricultural products · mobile phone live broadcast" enters Taihu Lake
屏幕显示技术进化史
PostgreSQL heap堆表 存储引擎实现原理
Go语言学习教程(十三)
Why must a digital transformation strategy include continuous testing?
广州股票开户选择手机办理安全吗?
CADD课程学习(1)-- 药物设计基础知识
Advanced skills of testers: a guide to the application of unit test reports
Transport layer uses sliding window to realize flow control
Idle fish is hard to turn over
暑期实训21组第一周个人工作总结
Enterprise middle office planning and it architecture microservice transformation
传输层 使用滑动窗口实现流量控制
Wechat applets - basics takes you to understand the life cycle of applets (2)
操作系统面试题汇总(不定期更新)
【ICLR 2021】半监督目标检测:Unbiased Teacher For Semi-Supervised Object Detection
arthas调试 确定问题工具包