GFS cluster deployment using KVM virtualization platforms (example !!!)

lab environment

4 GFS do GlusterFS cluster node server provides storage services to the KVM virtualization client do
Server Role IP addresses disk space
gfs-node1 192.168.142.152 40G+40G
gfs-node2 192.168.142.154 40G+40G
gfs-node3 192.168.142.162 40G+40G
gfs-node4 192.168.142.163 40G+40G
kvm-client 192.168.142.163 40G

The first step: GFS node server deployment

1. Four GFS node server for each server to add a new disk

Here Insert Picture Description
2. Use a script to deploy GFS key node

#!/bin/bash
systemctl stop firewalld.service
setenforce 0

#格式化磁盘
echo "the disks exist list:"
fdisk -l |grep '磁盘 /dev/sd[a-z]'
echo "=================================================="
PS3="chose which disk you want to create:"
select VAR in `ls /dev/sd*|grep -o 'sd[b-z]'|uniq` quit
do
    case $VAR in
    sda)
        fdisk -l /dev/sda
        break ;;
    sd[b-z])
        #create partitions
        echo "n
                p

                w"  | fdisk /dev/$VAR

        #make filesystem
        mkfs.xfs -i size=512 /dev/${VAR}"1" &> /dev/null
 #mount the system
        mkdir -p /data/${VAR}"1" &> /dev/null
        echo -e "/dev/${VAR}"1" /data/${VAR}"1" xfs defaults 0 0\n" >> /etc/fstab
        mount -a &> /dev/null
        break ;;
    quit)
        break;;
    *)
        echo "wrong disk,please check again";;
    esac
done
#授予执行权限
chmod +x a.sh

#执行脚本
./a.sh

#注意修改主机地址!!!
cat >>/etc/hosts<<-EOF
192.168.142.152 node1
192.168.142.154 node2
192.168.142.162 node3
192.168.142.163 node4
192.168.142.163 kvm
EOF

#创建yum源仓库
#进入yum仓库目录
cd /etc/yum.repos.d

#创建备份文件夹
mkdir bak

#移动使用文件到备份文件夹
mv C* bak

#清除yum缓存
yum clean all

#创建私有yum源
cat >GLFS.repo<<-EOF
[demo]
name=demo
baseurl=http://123.56.134.27/demo
gpgcheck=0
enable=1

[gfsrepo]
name=gfsrepo
baseurl=http://123.56.134.27/gfsrepo
gpgcheck=0
enable=1
EOF

#重新加载yum源
yum list

#安装必要软件包
yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma

#启动glusterd服务
systemctl start glusterd.service

#设定开机自启动glusterd服务
systemctl enable glusterd.service

#设定时间同步阿里时间服务器
ntpdate ntp1.aliyun.com

3. deployed four nodes, node operations on node1

#添加其他节点信息
gluster peer probe node2
gluster peer probe node3
gluster peer probe node4

#创建分布式卷
gluster volume create dis-volume replica 2 node1:/data/sdb1 node2:/data/sdb1 node3:/data/sdb1 node4:/data/sdb1 force 

#启动分布式卷
gluster volume start dis-volume

Step two: KVM client deployment operations

1. debugging client environment, the least memory 4G, open virtualization engine
Here Insert Picture Description
2. Mount the GFS to the client

#创建挂载目录
mkdir /data

#挂载分布式卷到客户端目录
mount.glusterfs node1:dis-vol /data

#查看磁盘分区信息
df -hT

#远程挂载微软宿主机上的镜像,后面再用
mount.cifs //192.168.142.1/ISO /mnt

3. Install KVM

#安装桌面环境组件包
yum groupinstall "GNOME Desktop" -y

#安装KVM模块
yum install qemu-kvm -y

#安装KVM调试工具
yum install qemu-kvm-tools -y

#安装构建虚拟机的命令行工具
yum install virt-install -y

#安装qemu组件,创建磁盘,启动虚拟机
yum install qemu-img -y

#安装网络支持工具
yum install bridge-utils -y

#安装虚拟机管理工具
yum install libvirt -y

#安装图像化管理虚拟机
yum install virt-manager -y

#查看CPU是否支持虚拟化(虚拟机需要配置中开启虚拟化功能)
egrep '(vmx|svm)' /proc/cpuinfo

#查看kvm模块是否安装
lsmod | grep kvm

#开启libvirtd服务
systemctl start libvirtd

#查看libvirtd服务状态
systemctl status libvirtd

#开机自启动libvirtd服务
systemctl enable libvirtd

4. Deploy linux virtual machine environment

#切换至挂载点
cd /data

#创建备份目录
mkdir vdisk viso

#后台复制镜像
cp -r /mnt/CentOS-7-x86_64-DVD-1708.iso /data/viso/ &

#切换网卡配置目录
cd /etc/sysconfig/network-scripts/

#复制ens33 网卡配置文件作为桥接网卡的模板
cp -p ifcfg-ens33 ifcfg-br0

#编辑ens33 网卡配置文件
vim ifcfg-ens33
#尾行追加桥接
BRIDGE=br0

#编辑桥接 网卡配置文件
vim ifcfg-br0

#替换类型为bridge桥接模式
TYPE=bridge

#修改为静态模式
BOOTPROTO=static

#改名
NAME=br0

#改驱动名称
DEVICE=br0

#追加IP地址,掩码和网关
IPADDR=192.168.142.164
NETMASK=255.255.255.0
GATEWAY=192.168.142.1

#重启网络服务
service network restart 

The third step: KVM graphical management

1. Open a terminal and type the following command as root switch graphical management interface

#打开终端输入一下命令切换图形化管理界面
virt-manager

2. Create the deployment of virtualized environments

创建存储池,双击QEMU/KVM,选择“存储”选项卡,然后单击“+”按钮新建存储池。
单击“前进”按钮,根据提示输入或浏览用以设置存储目录,如/data_kvm/store,最后单击“完成”按钮即可

Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description

Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture Description

Here Insert Picture DescriptionHere Insert Picture Description

Here Insert Picture DescriptionHere Insert Picture Description

Here is complete GFS + KVM deployment of all, Thanks for reading !!!

Guess you like

Origin blog.51cto.com/14449521/2460626