MySQL+Heartbeat+DRBD架构部署(3)

检查:出现虚拟VIP才算部署heartbeat成功
[root@MYSQL_M ~]# ip addr |grep 10.0.0
    inet 10.0.0.3/24 brd 10.0.0.255 scope global eth0
    inet 10.0.0.103/24 brd 10.0.0.255 scope global secondary eth0
[root@MYSQL_M ~]#
============================
[root@MYSQL_S ha.d]# ip addr |grep 10.0.0
    inet 10.0.0.4/24 brd 10.0.0.255 scope global eth0
    inet 10.0.0.104/24 brd 10.0.0.255 scope global secondary eth0
[root@MYSQL_S ha.d]#

出现上面的VIP,代表Heartbeat部署没问题

5、对磁盘进行分区,这里模拟大于2T硬盘进行分区
###MYSQL_M
parted /dev/sdb mklabel gpt
yes
parted /dev/sdb mkpart primary 0 600
Ignore
parted /dev/sdb p
parted /dev/sdb mkpart primary 600 1024
Ignore
parted /dev/sdb p
###MYSQL_S
parted /dev/sdb mklabel gpt                  ##创建一个分区表
yes
parted /dev/sdb mkpart primary 0 1024 ##创建一个主分区
Ignore
parted /dev/sdb p
parted /dev/sdb mkpart primary 1024 1500
Ignore
parted /dev/sdb p
===========================
[root@MYSQL_M ~]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start  End    Size  File system  Name    Flags
 1      17.4kB  600MB  600MB              primary
 2      600MB  1024MB  424MB              primary
[root@MYSQL_M ~]#
===============================
[root@MYSQL_S ha.d]# parted /dev/sdb p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1611MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start  End    Size    File system  Name    Flags
 1      17.4kB  1024MB  1024MB              primary
 2      1024MB  1500MB  476MB                primary
[root@MYSQL_S ha.d]#
================================

6、正式开始部署DRBD。两台服务器都要部署。操作相同
mkdir -p /home/lvnian/tools/
cd /home/lvnian/tools/
export LC_ALL=C
echo $LC_ALL
cd /home/lvnian/tools/
wget
ll drbd-8.4.4.tar.gz
tar xf drbd-8.4.4.tar.gz
cd drbd-8.4.4
./configure --prefix=/application/drbd-8.4.4  --with-km --with-heartbeat --sysconfdir=/etc/
make KDIR=/usr/src/kernels/$(uname -r)
make install

##加载drbd到内核
lsmod |grep drbd
modprobe drbd
lsmod |grep drbd

#这个加载,在重启之后失效,可以把它放在rc.local中。但也可以用heartbeat挂载

##设置开机自启动挂载drbd
echo 'modprobe drbd' >>/etc/rc.local

##配置drbd.conf 两个服务去的配置文件时一样的
cat>/etc/drbd.conf <<eof
global {
  usage-count no;
}
common {
  syncer {
rate 10M;
    verify-alg crc32c;
  }
}
resource data {
  protocol C;
  disk{
  on-io-error  detach;
  }
  on MYSQL_M {
    device    /dev/drbd0;
    disk      /dev/sdb1;
    address  10.0.0.3:7788;
    meta-disk  /dev/sdb2[0];
  }
  on MYSQL_S {
    device    /dev/drbd0;
    disk      /dev/sdb1;
    address  10.0.0.4:7788;
    meta-disk  /dev/sdb2[0];
  }
}
eof
cat /etc/drbd.conf
#######初始化话meta data分区
drbdadm create-md data
##drbd 启动
mkdir -p /application/drbd-8.4.4/var/run/drbd
drbdadm up data
cat /proc/drbd
##################################################33
报错:
[root@DRBD2 ~]# drbdadm up data
/application/drbd-8.4.4/var/run/drbd: No such file or directory
/application/drbd-8.4.4/var/run/drbd: No such file or directory
[root@DRBD2 ~]#
解决:
mkdir -p /application/drbd-8.4.4/var/run/drbd
drbdadm up data

#指定其中一台为主drbd(注意。选其中一台为主)

drbdadm -- --overwrite-data-of-peer primary data

#格式化分区:
mkfs.ext4 -b 4096 /dev/drbd0
tune2fs -c -1 /dev/drbd0

#挂载分区:

mkdir /data

mount /dev/drbd0 /data  ##用drbd0挂载,而不是用/dev/sdb2物理分区挂载。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d562918b166a630bdea8d1b0ecd85d2e.html