天天看點

GlusterFS 安裝 on centos71 準備工作2 安裝Gluster FS Server3 配置Gluster FS Server叢集4 配置GFS Volume5 配置GFS Client

1 準備工作

1.1 基礎設施

編号 IP OS 主機名 角色 說明
A 192.168.1.101 CentOS7.4 ddc_node01 GFS Client Gluster FS用戶端節點
B 192.168.1.102 ddc_node02
C 192.168.1.103 ddc_node03
D 192.168.1.104 ddc_node04 GFS Server Master Gluster FS伺服器主節點
E 192.168.1.105 ddc_node05 GFS Server Slave Gluster FS伺服器從節點

1.2 關閉防火牆

$ systemctl stop firewalld.service  && systemctl disable firewalld.service           

1.3 關閉selinux

$ vi /etc/selinux/config
# 修改SELINUX=disabled           

1.4 時間同步

保證時區和時間都要一緻。

1.5 配置hosts檔案

如果安裝配置過程中要使用主機名,就需要配置每個節點的hosts檔案。

2 安裝Gluster FS Server

2.1 在D,E節點上安裝Gluster FS Server

$ yum install -y centos-release-gluster
$ yum install -y glusterfs glusterfs-server 
$ yum install -y glusterfs-fuse glusterfs-rdma           

2.2 啟動 gluster FS Server并設定開機啟動

$ systemctl start glusterd.service && systemctl enable glusterd.service           

3 配置Gluster FS Server叢集

3.1 新節點加入叢集

在GFS Server Maseter節點(192.168.1.104)上執行指令:

$ gluster peer probe ddc_node05    # 在Master節點上将Slave節點加入到叢集中。           

3.2 從叢集中删除節點

$ gluster peer detach 192.168.1.105           

可以從任意GFS Server節點上删除叢集中的其它節點,但不能删除執行指令時的目前節點。

3.3 檢視叢集狀态

在GFS Server任意節點上執行指令:

$ gluster peer status           

會顯示目前叢集的slave節點數量:

Number of Peers: 1           

4 配置GFS Volume

4.1 在所有GFS Server節點上建立資料存儲目錄

$ mkdir -p /data/gluster/app1-mysql           

4.2 建立GFS volume

在任意GFS Server節點上執行指令:

$ gluster volume create app1-mysql-vol replica 2 A:/data/gluster/app1-mysql B:/data/gluster/app1-mysql force           

建立成功後會顯示:

volume create: mysql-vol: success: please start the volume to access data           

4.3 啟動 Volume:

$ gluster volume start  app1-mysql-vol           

啟動成功後會顯示

volume start:  app1-mysql-vol: success           

4.4 檢視 Volume 狀态

$ gluster volume info           

會顯示目前所有volume的資訊:

Volume Name: app1-mysql-vol
Type: Replicate
Volume ID: e539ff3b-2278-4f3f-a594-1f101eabbf1e
Status: Created
Number of Bricks: 1 x 2 = 2
......
Options Reconfigured:
performance.readdir-ahead: on           

4.5 删除 Volume

$ gluster volume stop app1-mysql-vol        # 停止名為app1-mysql-vol的GFS Volume
$ gluster volume delete app1-mysql-vol     # 删除名為app1-mysql-vol的GFS Volume           

5 配置GFS Client

GFS 用戶端節點必須能連通GFS伺服器節點

5.1 安裝用戶端

$ yum install -y glusterfs glusterfs-fuse           

5.2 将用戶端目錄挂載到GFS Volume

a, 在GFS Client節點上(例如192.168.1.102),建立一個本地目錄:
$ mkdir -p /var/data/app1-mysql           
b, 将本地目錄挂載到GFS Volume:
$ mount.glusterfs 192.168.1.104:/app1-mysql-vol /var/data/app1-mysql           

5.3 檢視挂載情況

在GFS用戶端節點上執行指令:

$ df -h           

會顯示目前挂載資訊

檔案系統   容量  已用   可用  已用%挂載點
/dev/mapper/ddc_node02-root   50G  1.2G50G   12% /
devtmpfs  32G 0   3.9G0% /dev
tmpfs3.9G0   3.9G0% /dev/shm
tmpfs3.9G  13M   3.9G1% /run
tmpfs3.9G0   3.9G0% /sys/fs/cgroup
......
tmpfs 783M 0   783M0%   /run/user/1002
192.168.1.104:app1-mysql-vol  50G 0   3.9G  1%  /var/data/app1-mysql # 挂載到GFS Volume的本地目錄           

5.4 取消挂載

$ umount /var/data/app1-mysql           

以上介紹了最基本的GFS安裝配置過程,更多GFS使用方法和優化方式,後續會繼續整理。

你現在的氣質裡,藏着你走過的路,讀過的書,愛過的人。

繼續閱讀