這邊最少須要三臺機器,全部機器關閉防火牆和Selinux,全部機器須要兩塊硬盤,linux
systemctl stop firewalld systemctl disable firewalld setenforce 0 sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config
添加hosts文件,其實經過IP地址也能作集羣,可是不建議這種方式,由於咱們經過域名你就是替換節點ip地址只要是域名不變,咱們的glusterfs集羣還能使用centos
cat >> /etc/hosts<<'EOF' 192.168.1.253 glusterfs01 192.168.1.238 glusterfs02 192.168.1.244 glusterfs03 EOF
格式化硬盤,咱們這邊採用/dev/sdb 這個硬盤bash
fdisk /dev/sdb Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p 而後一路回車,建立磁盤分區 mkfs.xfs /dev/sdb1 建立掛載點: mkdir -p /guiji mount -t auto /dev/sdb1 /guiji
搭建ntp時間服務器的教程,請移動到這裏
##安裝Glusterfs 服務服務器
添加安裝源,若是不添加沒法安裝glusterfs-servertcp
yum install centos-release-gluster
安裝glusterfs服務ide
yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma glusterfs-geo-replication glusterfs-devel
啓動glusterfs服務測試
systemctl start glusterd systemctl enable glusterd
將節點加入到glusterfs集羣中,須要到三臺機器節點上都執行下面命令ui
gluster peer probe gluster01 gluster peer probe gluster02 gluster peer probe gluster03
注意若是沒有配置hosts主機名這個地方是不能進行解析的,
在glusterfs01機器上查看gluster集羣code
[root@glusterfs01 gv0]# gluster peer status Number of Peers: 2 Hostname: glusterfs02 Uuid: 2ff8038e-bd5b-4dbe-a33e-6eb756314a50 State: Peer in Cluster (Connected) Hostname: glusterfs03 Uuid: b77cd401-a8c3-4c5d-8ab7-e2a1ab72aac3 State: Peer in Cluster (Connected)
在三臺機器上都建立以下目錄orm
mkdir -p /guiji/pv1
而後在其中任何一臺機器上執行下面這個命令
gluster volume create gv0 replica 3 glusterfs01:/guiji/pv1 glusterfs02:/guiji/pv1 glusterfs03:/guiji/pv1 gluster volume start gv0
注意: 這個地方默認是不能夠直接使用掛載點開建立的,須要在掛載點下面建立子目錄
查看確認卷已經啓動
[root@glusterfs01 ~]# gluster volume info Volume Name: gv0 Type: Replicate Volume ID: 24650e7b-e14a-416d-a151-c2588a26e795 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 3 = 3 Transport-type: tcp Bricks: Brick1: glusterfs01:/guiji/gv0 Brick2: glusterfs02:/guiji/gv0 Brick3: glusterfs03:/guiji/gv0 Options Reconfigured: transport.address-family: inet nfs.disable: on performance.client-io-threads: off
字段解讀:
Volume Name: 建立的這個glusterfs卷的名稱,客戶端掛在的時候回使用到這個內容 Type: Replicate 存儲的類型,這個爲副本類型 status: 當前這個卷的狀態 Number of Bricks: 存儲的狀態
查看狀態
[root@glusterfs01 ~]# gluster volume status Status of volume: gv0 Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick glusterfs01:/guiji/gv0 49152 0 Y 20554 Brick glusterfs02:/guiji/gv0 49152 0 Y 19241 Brick glusterfs03:/guiji/gv0 49152 0 Y 19278 Self-heal Daemon on localhost N/A N/A Y 20577 Self-heal Daemon on glusterfs03 N/A N/A Y 19301 Self-heal Daemon on glusterfs02 N/A N/A Y 19264 Task Status of Volume gv0 ------------------------------------------------------------------------------ There are no active volume tasks
安裝軟件,支持掛在glusterfs格式的文件
yum install centos-release-gluster -y yum install -y glusterfs-6.0-1* glusterfs-fuse-6.0-1*
在客戶端也須要配置hosts解析
cat >> /etc/hosts<<'EOF' 192.168.1.253 glusterfs01 192.168.1.238 glusterfs02 192.168.1.244 glusterfs03 EOF
掛在glusterfs提供的目錄
mount -t glusterfs glusterfs01:/gv0 /mnt
而後寫入數據測試
touch /mnt/{1..10}
而後去glusterfs上面檢查文件存不存在,因該是存在的