drbd报错
[root@dbmaster ~]# drbdadm create-md r0 WARN: You are using the 'drbd-peer-outdater' as fence-peer program. If you use that mechanism the dopd heartbeat plugin program needs to be able to call drbdsetup and drbdmeta with root privileges. You need to fix this with these commands: chgrp haclient /lib/drbd/drbdsetup-84 chmod o-x /lib/drbd/drbdsetup-84 chmod u+s /lib/drbd/drbdsetup-84 chgrp haclient /usr/sbin/drbdmeta chmod o-x /usr/sbin/drbdmeta chmod u+s /usr/sbin/drbdmeta md_offset 1072689152 al_offset 1072656384 bm_offset 1072623616 Found xfs filesystem 1047552 kB data area apparently used 1047484 kB left usable by current configuration Device size would be truncated, which would corrupt data and result in 'access beyond end of device' errors. You need to either * use external meta data (recommended) * shrink that filesystem first * zero out the device (destroy the filesystem) Operation refused. Command 'drbdmeta 0 v08 /dev/sdb1 internal create-md' terminated with exit code 40应该是该分区有残留的文件
解决
[root@dbmaster ~]# dd if=/dev/zero of=/dev/sdb1 bs=1M count=1 记录了1+0 的读入 记录了1+0 的写出 1048576字节(1.0 MB)已复制,0.00339429 秒,309 MB/秒 [root@dbmaster ~]# drbdadm create-md r0 --== Thank you for participating in the global usage survey ==-- The server's response is: you are the 14097th user to install this version WARN: You are using the 'drbd-peer-outdater' as fence-peer program. If you use that mechanism the dopd heartbeat plugin program needs to be able to call drbdsetup and drbdmeta with root privileges. You need to fix this with these commands: chgrp haclient /lib/drbd/drbdsetup-84 chmod o-x /lib/drbd/drbdsetup-84 chmod u+s /lib/drbd/drbdsetup-84 chgrp haclient /usr/sbin/drbdmeta chmod o-x /usr/sbin/drbdmeta chmod u+s /usr/sbin/drbdmeta initializing activity log initializing bitmap (32 KB) to all zero Writing meta data... New drbd meta data block successfully created. success #使用dd命令清空,然后再执行进一步配置
[root@dbmaster ~]# systemctl start drbd.service [root@dbbackup ~]# systemctl enable drbd.service #启动服务 #如报错,试试如下,不报错跳过这步 [root@dbmaster ~]# groupadd haclient [root@dbmaster ~]# chgrp haclient /lib/drbd/drbdsetup-84 [root@dbmaster ~]# chmod o-x /lib/drbd/drbdsetup-84 [root@dbmaster ~]# chmod u+s /lib/drbd/drbdsetup-84 [root@dbmaster ~]# chgrp haclient /usr/sbin/drbdmeta [root@dbmaster ~]# chmod o-x /usr/sbin/drbdmeta [root@dbmaster ~]# chmod u+s /usr/sbin/drbdmeta #以上这几个操作,找了很多资料都没有提到要做,还特意提醒不用做,可能环境不同吧,不做一直报错 [root@dbmaster ~]# drbdadm primary --force r0 #主上操作 [root@dbmaster ~]# drbdadm role r0 Primary/Secondary #查看状态 [root@dbbackup ~]# drbdadm role r0 Secondary/Primary #backup机器查看状态 [root@dbbackup ~]# drbdadm dstate r0 UpToDate/UpToDate #查看数据同步状态,如上为一致,还有Inconsistent状态为数据不一致正在同步挂载DRBD磁盘
现在dbmaster上操作 [root@dbmaster ~]# mkfs.ext4 /dev/drbd0 mke2fs 1.42.9 (28-Dec-2013) 文件系统标签= OS type: Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 65536 inodes, 261871 blocks 13093 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=268435456 8 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Allocating group tables: 完成 正在写入inode表: 完成 Creating journal (4096 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 [root@dbmaster ~]# mkdir /nfs [root@dbmaster ~]# mount /dev/drbd0 /nfs 现在是dbbackup上操作,主要是检测备端是否能够正常挂载和使用: [root@dbmaster ~]# umount /nfs #主上将设备卸载 [root@dbmaster ~]# drbdadm secondary all #切换为被状态 [root@dbbackup ~]# drbdadm primary r0 #被设为主状态 [root@dbbackup ~]# mkdir /nfs [root@dbbackup ~]# mount /dev/drbd0 /nfs [root@dbbackup ~]# df -Th 文件系统 类型 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root xfs 17G 4.5G 13G 27% / devtmpfs devtmpfs 470M 0 470M 0% /dev tmpfs tmpfs 487M 0 487M 0% /dev/shm tmpfs tmpfs 487M 14M 473M 3% /run tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sr0 iso9660 4.2G 4.2G 0 100% /media/cdrom /dev/sda1 xfs 1014M 251M 764M 25% /boot tmpfs tmpfs 98M 0 98M 0% /run/user/0 /dev/drbd0 ext4 991M 2.6M 922M 1% /database 再按相同的方法将状态切换回来好的,这下简单测试了下,先告一段落
部署heartbeat