主機名 |
ip
|
硬盤
|
NFS
|
server1.local
|
192.168.4.141
|
/dev/vdb
|
LV:5000M lianhua, 1000M huasheng
|
server2.local
|
192.168.4.59
|
/dev/vdb
|
LV:5000M lianhua, 1000M huasheng
|
server3.local
|
192.168.4.105
|
/dev/vdb
|
LV:5000M lianhua, 1000M huasheng
|
client1.local
|
192.168.4.144
|
/dev/vdb
|
|
[root@server1:/root] # cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.4.141 server1.local 192.168.4.59 server2.local 192.168.4.105 server3.local
[root@server1:/root] wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo [root@server1:/root] yum -y install centos-release-gluster312.noarch [root@server1:/root] yum -y --enablerepo=centos-gluster*-test install glusterfs-server glusterfs-cli glusterfs-geo-replication [root@server1:/root] yum -y --enablerepo=centos-gluster*-test install glusterfs-server glusterfs-cli glusterfs-geo-replication [root@server1:/root] systemctl start glusterd.service [root@server1:/root] systemctl enable glusterd.service [root@server1:/root] systemctl status glusterd.service # systemctl status glusterd.service ● glusterd.service - GlusterFS, a clustered file-system server Loaded: loaded (/etc/systemd/system/glusterd.service; disabled; vendor preset: disabled) Active: active (running) since Sat 2020-03-28 14:27:24 CST; 6h ago Main PID: 4519 (glusterd) Tasks: 188 (limit: 4915) Memory: 324.8M [root@server1:/root] glusterfs -V glusterfs 3.12.15 Repository revision: git://git.gluster.org/glusterfs.git Copyright (c) 2006-2016 Red Hat, Inc. <https://www.gluster.org/> GlusterFS comes with ABSOLUTELY NO WARRANTY. It is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation.
[root@server1:/root] # df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/vda1 ext4 40G 4.7G 33G 13% / tmpfs tmpfs 8.9G 3.9M 8.9G 1% /tmp /dev/mapper/server1--vol-lianhua ext4 4.6G 23M 4.3G 1% /mnt/bricks/lianhua /dev/mapper/server1--vol-huasheng ext4 4.6G 20M 4.3G 1% /mnt/bricks/huasheng
[root@server1:/root] # gluster peer probe server2 [root@server1:/root] # gluster peer probe server3 [root@server1:/root] # gluster peer status Number of Peers: 2 Hostname: server2.local Uuid: 72a5f725-1436-46e9-8ae3-404e30fc5eac State: Peer in Cluster (Connected) Hostname: server3.local Uuid: 4b2472bc-44a6-4e92-b3fa-6746c599c5d0 State: Peer in Cluster (Connected)
[root@server1:/root] # df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/vda1 ext4 40G 4.7G 33G 13% / tmpfs tmpfs 8.9G 3.9M 8.9G 1% /tmp /dev/mapper/server1--vol-lianhua ext4 4.6G 23M 4.3G 1% /mnt/bricks/lianhua /dev/mapper/server1--vol-huasheng ext4 4.6G 20M 4.3G 1% /mnt/bricks/huasheng [root@server1:/root] # gluster volume create lianhuasheng replica 3 server1:/mnt/bricks/lianhua server2:/mnt/bricks/lianhua server3:/mnt/bricks/lianhua force volume create: lianhuasheng: success: please start the volume to access data [root@server1:/root] # gluster volume start lianhuasheng [root@server1:/root] # gluster volume info lianhuasheng Volume Name: lianhuasheng Type: Replicate Volume ID: 895f24cb-cf45-4cba-b50d-55422aff0909 Status: Started Snapshot Count: 0 Number of Bricks: 1 x 3 = 3 Transport-type: tcp Bricks: Brick1: server1.local:/mnt/bricks/lianhua/brick Brick2: server2.local:/mnt/bricks/lianhua/brick Brick3: server3.local:/mnt/bricks/lianhua/brick Options Reconfigured: performance.client-io-threads: off nfs.disable: on transport.address-family: inet cluster.server-quorum-type: none cluster.quorum-type: auto cluster.quorum-reads: true cluster.consistent-metadata: on server.allow-insecure: on network.ping-timeout: 42 cluster.favorite-child-policy: mtime cluster.heal-timeout: 60 cluster.server-quorum-ratio: 51% [root@server1:/root] # mount -t glusterfs server1:/lianhuasheng /mnt/lianhuasheng [root@server1:/root] # df -hT /dev/vda1 ext4 40G 4.7G 33G 13% / tmpfs tmpfs 8.9G 3.9M 8.9G 1% /tmp /dev/mapper/server1--vol-lianhua ext4 4.6G 23M 4.3G 1% /mnt/bricks/lianhua /dev/mapper/server1--vol-huasheng ext4 4.6G 20M 4.3G 1% /mnt/bricks/huasheng server1.local:/lianhuasheng fuse.glusterfs 4.6G 24M 4.2G 1% /mnt/lianhuasheng
[root@client1:/root] # mount -t glusterfs -o acl -o rw,backupvolfile-server=server1.local server1.local:/lianhuasheng /mnt/lianhuasheng [root@client1:/root] # df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/vda1 ext4 40G 4.7G 33G 13% / tmpfs tmpfs 8.9G 3.9M 8.9G 1% /tmp server1.local:/lianhuasheng fuse.glusterfs 4.6G 20M 4.2G 8% /mnt/lianhuasheng
[root@client1:/root] # cd /mnt/lianhuasheng/ [root@client1:/mnt/lianhuasheng] # ls [root@client1:/mnt/lianhuasheng] # touch GlusterFS.log [root@client1:/mnt/lianhuasheng] # ll -h total 0K -rw-r--r-- 1 root root 0 Mar 28 22:38 GlusterFS.log [root@client1:/mnt/lianhuasheng] # ssh server1.local [root@server1:/root] # cd /mnt/lianhuasheng/ [root@server1:/mnt/lianhuasheng] # ll -h -rw-r--r-- 1 root root 0 Mar 28 22:38 GlusterFS.log
# 查看 GlusterFS 全部 volume gluster volume list # 刪除 GlusterFS volume gluster volume stop <volume_name> gluster volume delete <volume_name> # 卸載主機池中的主機 gluster peer detach <node_name> # 添加主機到主機池 gluster peer probe <node_name> # 建立 volume gluster volume create <volume_name> replica <number of replica> <server_name>:<brick_name>