DRBD使用LVM逻辑卷作为后端设备创建XFS文件系统在线添加磁盘扩容操作过程(推荐)

DRBD使用LVM逻辑卷作为后端设备创建XFS文件系统在线添加磁盘扩容操作过程(推荐)

0.服务器环境信息
drbd1    192.168.111.132    CentOS 7
drbd2    192.168.111.190    CentOS 7
1、禁用SELinux
在两个节点执行:
# setenforce 0
永久关闭
可以修改配置文件/etc/selinux/config,将其中SELINUX设置为disabled。

 
[root@localhost ~]# cat /etc/selinux/config   
   
# This file controls the state of SELinux on the system.  
# SELINUX= can take one of these three values:  
#     enforcing - SELinux security policy is enforced.  
#     permissive - SELinux prints warnings instead of enforcing.  
#     disabled - No SELinux policy is loaded.  
#SELINUX=enforcing  
SELINUX=disabled  
# SELINUXTYPE= can take one of three two values:  
#     targeted - Targeted processes are protected,  
#     minimum - Modification of targeted policy. Only selected processes are protected.   
#     mls - Multi Level Security protection.  
SELINUXTYPE=targeted
 
# sestatus  
SELinux status:                 disabled

关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动

设置主机名:

hostnamectl set-hostname drbd1

hostnamectl set-hostname drbd2

2、安装DRBD
在两个节点执行:
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
# yum install drbd90-utils kmod-drbd90
# lsmod | grep -i drbd
# modprobe drbd
# echo drbd > /etc/modules-load.d/drbd.conf

3、配置DRBD

在两个节点执行:
# mv /etc/drbd.d/global_common.conf /etc/drbd.d/global_common.conf.orig
# vi /etc/drbd.d/global_common.conf

global {
 usage-count no;
}
common {
 net {
  protocol C;
 }
}


# vi /etc/drbd.d/drbd0.res

resource drbd0 {
        disk /dev/drbdvg/drbdlv;
        device /dev/drbd0;
        meta-disk internal;
        on drbd1 {
                address 192.168.111.132:7789;
        }
        on drbd2 {
                address 192.168.111.190:7789;
        }
}

# pvcreate /dev/sdb
# vgcreate drbdvg /dev/sdb
# lvcreate -l 100%VG -n drbdlv drbdvg
# lvscan
# drbdadm create-md drbd0

# systemctl start drbd
# drbdadm status

在主节点执行:
# drbdadm primary drbd0 --force

# mkfs.xfs /dev/drbd0
# mount /dev/drbd0 /mnt
# touch /mnt/file{1..5}
# ls -l /mnt/
# df -hT
# vgdisplay
# pvdisplay
# lvdisplay

4、在线扩容
在两个节点执行:
# lsblk
# pvcreate /dev/sdc
# pvdisplay
# vgdisplay
# vgextend drbdvg /dev/sdc
# lvs
# lvdisplay
# lvextend -l+100%FREE /dev/drbdvg/drbdlv
# lvs
等待数据同步完成
# watch drbdadm status
在主节点执行:
# drbdadm resize drbd0

# xfs_growfs /mnt
# df -hT
扩容完成,等待扩容数据同步完成
# watch drbdadm status

同步完成后可以进行切换测试
在主节点执行:
# umount /mnt/
在从节点执行:
# mount /dev/drbd0 /mnt
# ls -l /mnt/
# df -hT
# touch /mnt/file{11..15}
# ls -l /mnt/
# umount /mnt
在主节点执行:
# mount /dev/drbd0 /mnt
# ls -l  /mnt

——全文完——

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值