一、部署GFS分布式存储
实验步骤:
准备环境(以node1为例,其他节点步骤略,请自行配置)
(1)按照表中所示,为node节点添加相应数量和大小的磁盘,并重启系统
(2)为所有节点的新磁盘分区
用fdisk命令为每个磁盘分区
node1-4:
[root@localhost ~]# fdisk /dev/sdb
[root@localhost ~]# fdisk /dev/sdc
[root@localhost ~]# fdisk /dev/sdd
[root@localhost ~]# fdisk /dev/sde
(2)为每个节点的每个磁盘格式化
node1-4:
[root@localhost ~]# mkfs -t ext4 /dev/sdb1
[root@localhost ~]# mkfs -t ext4 /dev/sdc1
[root@localhost ~]# mkfs -t ext4 /dev/sdd1
[root@localhost ~]# mkfs -t ext4 /dev/sde1
(3)创建挂载点
node1-4:
[root@localhost ~]# mkdir /b1
[root@localhost ~]# mkdir /c1
[root@localhost ~]# mkdir /d1
[root@localhost ~]# mkdir /e1
(4)挂载磁盘
node1-4:
[root@localhost ~]# mount /dev/sdb1 /b1
[root@localhost ~]# mount /dev/sdc1 /c1
[root@localhost ~]# mount /dev/sdd1 /d1
[root@localhost ~]# mount /dev/sde1 /e1
(5)修改fstab文件,使挂载永久生效
[root@localhost ~]# vi /etc/fstab
在末尾添加
/dev/sdb1 /b1 ext4 defaults 0 0
/dev/sdc1 /c1 ext4 defaults 0 0
/dev/sdd1 /d1 ext4 defaults 0 0
/dev/sde1 /e1 ext4 defaults 0 0
2:在所有节点上关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
3:在所有节点上修改hosts文件
node1-4:
[root@localhost ~]# vi /etc/hosts
192.168.1.10 node1
192.168.1.11 node2
192.168.1.12 node3
192.168.1.13 node4
192.168.1.61 kvm
4:在所有节点安装软件
(1)配置yum仓库
将GFS所需的rpm仓库的gfsrepo目录拷贝到linux系统的/opt下,并修改仓库文件(暂时注释)
node1-4:
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Media.repo
#[c7-media]
#name=CentOS-$releasever - Media
#baseurl=file:///media/cdrom/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[gfsrepo]
name=GFS
baseurl=file:///root/GFS
gpgcheck=0
enabled=1
[root@localhost ~]# yum clean all
(2)在所有节点上安装gfs
node1-4:
[root@localhost ~]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
5:在所有节点上启动GFS
node1-4:
[root@localhost ~]# systemctl start glusterd.service
[root@localhost ~]# systemctl enable glusterd.service
6:添加节点(只在node1节点上)
[root@localhost ~]# gluster peer probe node1
peer probe: success. Probe on localhost not needed
[root@localhost ~]# gluster peer probe node2
peer probe: success.
[root@localhost ~]# gluster peer probe node3
peer probe: success.
[root@localhost ~]# gluster peer probe node4
peer probe: success.
二、kvm(兼GFS客户端)
实验环境:
关机状态设置虚拟机CPU
修改hosts解析文件:
[root@localhost ~]# vi /etc/hosts
192.168.1.10 node1
192.168.1.11 node2
192.168.1.12 node3
192.168.1.13 node4
192.168.1.61 kvm
安装所需软件:
yum -y install groupinstall "desktop" qemu-kvm.x86_64 qemu-kvm-tools.x86_64 qemu-img.x86_64 bridge-utils.x86_64 libvirt virt-manager glusterfs glusterfs-fuse
查看cpu是否支持虚拟化:
cat /proc/cpuinfo | grep vmx
检查kvm模块是否安装:
lsmod | grep kvm
安装完成后还需要开启 libvirtd 服务,以开启相关支持:
systemctl start libvirtd
systemctl enable libvirtd
桥接模式
宿主机:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
添加修改以下内容:
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
#GATEWAY=192.168.10.254
#DNS1=192.168.10.254
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
#IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.61
PREFIX=24
IPV6INIT=no
BRIDGE=br0
vim /etc/sysconfig/network-scripts/ifcfg-br0
添加修改以下内容:
TYPE=bridge
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
#GATEWAY=192.168.10.254
#DNS1=192.168.10.254
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
#IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=192.168.1.61
PREFIX=24
IPV6INIT=no
重启网卡服务生效:
systemctl restart network
确认IP信息
ifconfig
启动软件
virt-manager
创建挂载目录,并挂载卷
mkdir /kvmdata
mount -t glusterfs node1:models /kvmdata/
查看挂载卷
df -h
创建存储池目录
mkdir /kvmdata/data
mkdir /kvmdata/iso(放系统镜像)