新增三台centos7機器,最小化安裝
ip配置設定是 服務端192.168.1.7 192.168.1.8 用戶端192.168.1.9
主機名分别為 gluster01 gluster02 client01
hostnamectl set-hostname gluster01
hostnamectl set-hostname gluster02
hostnamectl set-hostname client01
配置所有機器網絡,要求能通路外網(略)
關閉防火牆和selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/enforcing/disabled/g' /etc/selinux/config
修改所有機器的hosts檔案,添加對應的ip主機名解析
vi /etc/hosts
192.168.1.7 gluster01
192.168.1.8 gluster02
192.168.1.9 client01
配置yum源
cd /etc/yum.repos.d/
yum -y install epel-release
安裝服務端
yum install centos-release-gluster -y
yum install -y glusterfs glusterfs-server glusterfs-fuse
systemctl start glusterd
systemctl enable glusterd
在節點gluster01上,配置整個GlusterFS叢集,把各個節點加入到叢集
gluster peer probe gluster01
gluster peer probe gluster02
檢視叢集狀态
gluster peer status
在兩個服務節點上建立資料存儲目錄
mkdir -p /usr/local/share/models
在gluster01上建立GlusterFS磁盤
加上replica 2 就是2個節點中,每個節點都要把資料存儲一次,就是一個資料存儲2份,每個節點一份
如果不加replica 2,就是2個節點的磁盤空間整合成一個硬碟
gluster volume create models replica 2 gluster01:/usr/local/share/models gluster02:/usr/local/share/models force
啟動叢集
gluster volume start models
安裝用戶端
yum install -y glusterfs glusterfs-fuse
mkdir -p /mnt/models
挂載
mount -t glusterfs -o rw gluster01:models /mnt/models/
df檢視
檔案系統 1K-塊 已用 可用 已用% 挂載點
/dev/sda2 18244432 1012448 16282176 6% /
devtmpfs 491416 0 491416 0% /dev
tmpfs 500680 0 500680 0% /dev/shm
tmpfs 500680 6792 493888 2% /run
tmpfs 500680 0 500680 0% /sys/fs/cgroup
/dev/sda1 194235 95079 84820 53% /boot
tmpfs 100136 0 100136 0% /run/user/0
gluster01:models 18244352 1012480 16282112 6% /mnt/model
其他操作指令
删除GlusterFS磁盤
# gluster volume stop models 先停止
# gluster volume delete models 再删除
解除安裝GlusterFS磁盤
gluster peer detach gluster02
ACL通路控制
gluster volume set models auth.allow 192.168.1.*,192.168.2.*
添加GlusterFS節點
# gluster peer probe gluster03
# gluster peer probe gluster04
# gluster volume add-brick models gluster03:/data/gluster gluster04:/data/gluster
遷移GlusterFS資料
# gluster volume remove-brick models gluster01:/usr/local/share/models gluster03:/usr/local/share/models start
# gluster volume remove-brick models gluster01:/usr/local/share/models gluster03:/usr/local/share/models status
# gluster volume remove-brick models gluster01:/usr/local/share/models gluster03:/usr/local/share/models commit
修複GlusterFS資料(在節點1當機的情況下)
# gluster volume replace-brick models gluster01:/usr/local/share/models gluster03:/usr/local/share/models commit -force
# gluster volume heal models full
本文轉自super李導51CTO部落格,原文連結:http://blog.51cto.com/superleedo/2056732 ,如需轉載請自行聯系原作者