global_common.conf 100% 2621 2.6KB/s 00:00
mysql.res 100% 238 0.2KB/s 00:00
可以发现drbd.d目录下的所有文件已经复制node2上了
##注意要先把防火墙给关掉先
11、在node1上面启动mysql
[root@node1 ~]# drbdadm create-md mysql
You want me to create a v08 style flexible-size internal meta data block.
There appears to be a v08 flexible-size internal meta data block
already in place on /dev/sdb at byte offset 2147479552
Do you really want to overwrite the existing meta-data?
[need to type 'yes' to confirm] yes
md_offset 2147479552
al_offset 2147446784
bm_offset 2147381248
Found xfs filesystem
2097052 kB data area apparently used
2097052 kB left usable by current configuration
Even though it looks like this would place the new meta data into
unused space, you still need to confirm, as this is only a guess.
Do you want to proceed?
[need to type 'yes' to confirm] yes
initializing activity log
initializing bitmap (64 KB) to all zero
Writing meta data...
New drbd meta data block successfully created.
[root@node1 ~]# modprobe drbd
[root@node1 ~]# lsmod | grep drbd
drbd 396875 0
libcrc32c 12644 4 xfs,drbd,nf_nat,nf_conntrack
[root@node1 ~]# drbdadm up mysql
[root@node1 ~]# drbdadm -- --force primary mysql
查看node1的状态:
[root@node1 ~]# cat /proc/drbd
version: 8.4.10-1 (api:1/proto:86-101)
GIT-hash: a4d5de01fffd7e4cde48a080e2c686f9e8cebf4c build by mockbuild@, 2017-09-15 14:23:22
1: cs:WFConnection ro:Primary/Unknown ds:UpToDate/DUnknown C r----s
ns:0 nr:0 dw:0 dr:912 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:2097052
You have new mail in /var/spool/mail/root
12、在对端节点执行:
[root@node2 ~]# drbdadm create-md mysql
You want me to create a v08 style flexible-size internal meta data block.
There appears to be a v08 flexible-size internal meta data block
already in place on /dev/sdb at byte offset 2147479552
Do you really want to overwrite the existing meta-data?
[need to type 'yes' to confirm] yes
md_offset 2147479552
al_offset 2147446784
bm_offset 2147381248
Found xfs filesystem
2097052 kB data area apparently used
2097052 kB left usable by current configuration
Even though it looks like this would place the new meta data into
unused space, you still need to confirm, as this is only a guess.
Do you want to proceed?
[need to type 'yes' to confirm] yes
initializing activity log
initializing bitmap (64 KB) to all zero
Writing meta data...
New drbd meta data block successfully created.
[root@node2 ~]# modprobe drbd
[root@node2 ~]# drbdadm up mysql
在从上面可以查看数据同步的状态:
[root@node2 ~]# cat /proc/drbd
version: 8.4.10-1 (api:1/proto:86-101)
GIT-hash: a4d5de01fffd7e4cde48a080e2c686f9e8cebf4c build by mockbuild@, 2017-09-15 14:23:22
1: cs:SyncTarget ro:Secondary/Primary ds:Inconsistent/UpToDate C r-----
ns:0 nr:237568 dw:237568 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:1859484
[=>..................] sync'ed: 11.6% (1859484/2097052)K
finish: 0:00:39 speed: 47,512 (47,512) want: 102,400 K/sec
可以看到数据正在同步
13、格式化并挂载:
[root@node1 ~]# mkfs.xfs /dev/drbd1
meta-data=/dev/drbd1 isize=512 agcount=4, agsize=131066 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=524263, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
You have new mail in /var/spool/mail/root
[root@node1 ~]# mount /dev/drbd1 /mnt
[root@node1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 18G 2.3G 16G 13% /
devtmpfs 226M 0 226M 0% /dev
tmpfs 237M 0 237M 0% /dev/shm
tmpfs 237M 4.6M 232M 2% /run
tmpfs 237M 0 237M 0% /sys/fs/cgroup
/dev/sda1 1014M 197M 818M 20% /boot
tmpfs 48M 0 48M 0% /run/user/0
/dev/drbd1 2.0G 33M 2.0G 2% /mnt
注####要想使得从可以挂载,我们必须,先把主切换成丛,然后再到从上面挂载:
14、查看资源链接的状态可以发现是Connected,正常的
[root@node1 ~]# drbdadm cstate mysql
Connected
15、查看资源角色命令
[root@node1 ~]# drbdadm role mysql
Primary/Secondary
[root@node1 ~]# ssh node2 "drbdadm role mysql"
Secondary/Primary
[root@node1 ~]# cat /proc/drbd
version: 8.4.10-1 (api:1/proto:86-101)
GIT-hash: a4d5de01fffd7e4cde48a080e2c686f9e8cebf4c build by mockbuild@, 2017-09-15 14:23:22
1: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r-----
ns:2099100 nr:0 dw:2048 dr:2098449 al:9 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
注释:
Parimary 主:资源目前为主,并且可能正在被读取或写入,如果不是双主只会出现在两个节点中的其中一个节点上
Secondary 次:资源目前为次,正常接收对等节点的更新
Unknown 未知:资源角色目前未知,本地的资源不会出现这种状态
16、查看硬盘状态:
[root@node1 ~]# drbdadm dstate mysql
UpToDate/UpToDate
本地和对等节点的硬盘有可能为下列状态之一:
注:
Diskless 无盘:本地没有块设备分配给DRBD使用,这表示没有可用的设备,或者使用drbdadm命令手工分离或是底层的I/O错误导致自动分离
Attaching:读取无数据时候的瞬间状态
Failed 失败:本地块设备报告I/O错误的下一个状态,其下一个状态为Diskless无盘
Negotiating:在已经连接的DRBD设置进行Attach读取无数据前的瞬间状态