云計(jì)算
kvm gfs虛擬平臺(tái)的搭建
實(shí)驗(yàn)拓?fù)鋱D:
實(shí)驗(yàn)需求
為了搭建kvm虛擬平臺(tái),我們需要?jiǎng)?chuàng)建一個(gè)條帶復(fù)制卷,為虛擬主機(jī)提供搭建環(huán)境和分布式存儲(chǔ)功能,
gfs 群集的搭建
在gfs上我們需要為每個(gè)node添加一塊硬盤(pán),將他們作為條帶復(fù)制卷的加載空間。
環(huán)境搭建
1、為4臺(tái)node節(jié)點(diǎn),每臺(tái)添加一塊20g的移動(dòng)硬盤(pán),并且在客戶(hù)端上開(kāi)啟虛擬化引擎
2、修改node節(jié)點(diǎn)的名稱(chēng)
分別修改為node1、node2、node3、node4
[root@localhost ~]#hostnamectl set-hostname node1[root@localhost ~]# su3、將四臺(tái)服務(wù)器上的磁盤(pán)格式化,并掛載
在這里我們使用腳本執(zhí)行掛載
#進(jìn)入opt目錄[root@node1 ~]# cd /opt#磁盤(pán)格式化、掛載腳本[root@node1 opt]# vim a.sh#! /bin/bashecho the disks exist list:fdisk -l |grep \\\'磁盤(pán) /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` quitdo 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;; esacdone#給于腳本執(zhí)行權(quán)限[root@node1 opt]# chmod x a.sh將腳本通過(guò)scp推送到其他三臺(tái)服務(wù)器上
scp a.sh root@192.168.45.134:/optscp a.sh root@192.168.45.130:/optscp a.sh root@192.168.45.136:/opt在四臺(tái)服務(wù)器上執(zhí)行腳本,并完成
這個(gè)只是樣本
[root@node1 opt]# ./a.shthe disks exist list:==================================================1) sdb2) quitchose which disk you want to create:1 //選擇要格式化的盤(pán)welcome to fdisk (util-linux 2.23.2).changes will remain in memory only, until you decide to write them.be careful before using the write command.device does not contain a recognized partition tablebuilding a new dos disklabel with disk identifier 0x37029e96.command (m for help): partition type: p primary (0 primary, 0 extended, 4 free) e extendedselect (default p): partition number (1-4, default 1): first sector (2048-41943039, default 2048): using default value 2048last sector, sectors or size{k,m,g} (2048-41943039, default 41943039): using default value 41943039partition 1 of type linux and of size 20 gib is setcommand (m for help): the partition table has been altered!calling ioctl() to re-read partition table.syncing disks.4、設(shè)置hosts文件
在第一臺(tái)node1上修改
#在文件末尾添加vim /etc/hosts192.168.45.133 node1192.168.45.130 node2192.168.45.134 node3192.168.45.136 node4通過(guò)scp將hosts文件推送給其他服務(wù)器和客戶(hù)端
#將/etc/hosts文件推送給其他主機(jī)[root@node1 opt]# scp /etc/hosts root@192.168.45.130:/etc/hostsroot@192.168.45.130\\\'s hosts 100% 242 23.6kb/s 00:00 [root@node1 opt]# scp /etc/hosts root@192.168.45.134:/etc/hostsroot@192.168.45.134\\\'s hosts 100% 242 146.0kb/s 00:00 [root@node1 opt]# scp /etc/hosts root@192.168.45.136:/etc/hostsroot@192.168.45.136\\\'s hosts 在其他服務(wù)器上查看推送情況
關(guān)閉所有服務(wù)器和客戶(hù)端的防火墻
[root@node1 ~]# systemctl stop firewalld.service [root@node1 ~]# setenforce 0在客戶(hù)端和node服務(wù)器上搭建yum倉(cāng)庫(kù)
#進(jìn)入yum文件路徑[root@node1 ~]# cd /etc/yum.repos.d/#創(chuàng)建一個(gè)空文件夾[root@node1 yum.repos.d]# mkdir abc#將centos-文件全部移到到abc下[root@node1 yum.repos.d]# mv centos-* abc#創(chuàng)建私有yum源[root@node1 yum.repos.d]# vim glfs.repo[demo]name=demobaseurl=http://123.56.134.27/demogpgcheck=0enable=1[gfsrepo]name=gfsrepobaseurl=http://123.56.134.27/gfsrepogpgcheck=0enable=1#重新加載yum源[root@node1 yum.repos.d]# yum list安裝必要軟件包
[root@node1 yum.repos.d]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma在四臺(tái)服務(wù)器上啟動(dòng)glusterd,并設(shè)置為開(kāi)機(jī)自啟動(dòng)
[root@node1 yum.repos.d]# systemctl start glusterd.service [root@node1 yum.repos.d]# systemctl enable glusterd.service添加節(jié)點(diǎn)信息
[root@node1 yum.repos.d]# gluster peer probe node2peer probe: success. [root@node1 yum.repos.d]# gluster peer probe node3peer probe: success. [root@node1 yum.repos.d]# gluster peer probe node4peer probe: success. 在其他服務(wù)器上查看節(jié)點(diǎn)信息
[root@node1 yum.repos.d]# gluster pee