本文演示如何在CentOS7上安裝,配置和使用GlusterFS。node
編號 | IP | OS | 主機名 | 角色 | 說明 |
---|---|---|---|---|---|
A | 192.168.1.101 | CentOS7.4 | ddc_node01 | GFS Client | Gluster FS客戶端節點 |
B | 192.168.1.102 | CentOS7.4 | ddc_node02 | GFS Client | Gluster FS客戶端節點 |
C | 192.168.1.103 | CentOS7.4 | ddc_node03 | GFS Client | Gluster FS客戶端節點 |
D | 192.168.1.104 | CentOS7.4 | ddc_node04 | GFS Server Master | Gluster FS服務器主節點 |
E | 192.168.1.105 | CentOS7.4 | ddc_node05 | GFS Server Slave | Gluster FS服務器從節點 |
$ systemctl stop firewalld.service && systemctl disable firewalld.service
$ vi /etc/selinux/config # 修改SELINUX=disabled
保證時區和時間都要一致。mysql
若是安裝配置過程當中要使用主機名,就須要配置每一個節點的hosts文件。linux
$ yum install -y centos-release-gluster $ yum install -y glusterfs glusterfs-server $ yum install -y glusterfs-fuse glusterfs-rdma
$ systemctl start glusterd.service && systemctl enable glusterd.service
在GFS Server Maseter節點(192.168.1.104)上執行命令:sql
$ gluster peer probe ddc_node05 # 在Master節點上將Slave節點加入到集羣中。
在GFS Server Maseter節點(192.168.1.104)上執行命令:centos
$ gluster peer detach 192.168.1.105
能夠從任意GFS Server節點上刪除集羣中的其它節點,但不能刪除執行命令時的當前節點。服務器
在GFS Server任意節點上執行命令:app
$ gluster peer status
會顯示當前集羣的slave節點數量:優化
Number of Peers: 1
$ mkdir -p /data/gluster/app1-mysql
在任意GFS Server節點上執行命令:code
$ gluster volume create app1-mysql-vol replica 2 A:/data/gluster/app1-mysql B:/data/gluster/app1-mysql force
建立成功後會顯示:orm
volume create: mysql-vol: success: please start the volume to access data
$ gluster volume start app1-mysql-vol
啓動成功後會顯示
volume start: app1-mysql-vol: success
$ 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
$ gluster volume stop app1-mysql-vol # 中止名爲app1-mysql-vol的GFS Volume $ gluster volume delete app1-mysql-vol # 刪除名爲app1-mysql-vol的GFS Volume
GFS 客戶端節點必須能連通GFS服務器節點
$ yum install -y glusterfs glusterfs-fuse
$ mkdir -p /var/data/app1-mysql
$ mount.glusterfs 192.168.1.104:/app1-mysql-vol /var/data/app1-mysql
在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的本地目錄
$ umount /var/data/app1-mysql
以上介紹了最基本的GFS安裝配置過程,更多GFS使用方法和優化方式,後續會繼續整理。