DRBD磁盘镜像
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DRBD磁盘镜像相关的知识,希望对你有一定的参考价值。
1、添加硬盘,然后分区fdisk -l fdisk /dev/sdb partprob /dev/sdb
2、主备节点FQDN
主:hostname drbd1.company.com
备:hostname drbd2.company.com
写入/etc/hosts文件:
192.168.0.182 drbd1.company.com 192.168.0.183 drbd2.company.com
3、yum安装drbd
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm yum install drbd83-utils kmod-drbd83 modprobe drbd lsmod | grep drbd echo "modprobe drbd" >>/etc/rc.local
4、配置drbd(主备相同)
配置例子文件:/usr/share/doc/drbd83-utils-8.3.16/drbd.conf.example
全局配置:
vim /etc/drbd.d/global_common.conf
global { usage-count no; } common { protocol C; handlers { pri-on-incon-degr "/usr/lib/drbd/notify-pri-on-incon-degr.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f"; pri-lost-after-sb "/usr/lib/drbd/notify-pri-lost-after-sb.sh; /usr/lib/drbd/notify-emergency-reboot.sh; echo b > /proc/sysrq-trigger ; reboot -f"; local-io-error "/usr/lib/drbd/notify-io-error.sh; /usr/lib/drbd/notify-emergency-shutdown.sh; echo o > /proc/sysrq-trigger ; halt -f"; } startup { wfc-timeout 0; degr-wfc-timeout 120; } disk { on-io-error detach; } net { cram-hmac-alg "sha1"; shared-secret "nfs-drbd"; } syncer { rate 30M; } }
资源文件:
vim /etc/drbd.d/redisk.res
resource redisk { on drbd1.company.com { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.182:7789; meta-disk internal; } on drbd2.company.com { device /dev/drbd0; disk /dev/sdb1; address 192.168.0.183:7789; meta-disk internal; } }
5、drbd初始化与启动
主备节点执行:
drbdadm create-md redisk drbdadm up redisk service drbd start
主节点执行,设置为primary:
drbdadm -- --overwrite-data-of-peer primary redisk
查看节点状态:
cat /proc/drbd drbd-overview
6、同步完成后,在主节点创建文件系统,格式化(备节点数据不能访问)
mkfs.ext4 /dev/drbd0 mkdir /drbd mount /dev/drbd0 /drbd/
7、主备切换
主:
umount /drbd/ drbdadm secondary redisk
备:
drbdadm primary redisk mkdir /drbd mount /dev/drbd0 /drbd/
以上是关于DRBD磁盘镜像的主要内容,如果未能解决你的问题,请参考以下文章