环境
CentOS 7.5
Using Storage SIG Yum Repos
yum install centos-release-gluster -y
Have at least two nodes
以下IP和hostname根据实际情况设置
# 修改hostname
hostnamectl set-hostname server1
# 修改hosts文件
tee /etc/hosts <<-'EOF'
192.168.161.131 server2
192.168.161.129 server1
EOF
添加硬盘
首先向Gluster节点上添加硬盘,使用fdisk -l
命令查看,可以看到多出来的/dev/sdb
mkfs.xfs -i size=512 /dev/sdb
mkdir -p /bricks/brick1
vi /etc/fstab
添加如下内容:
/dev/sdb /bricks/brick1 xfs defaults 1 2
保存然后退出
mount -a && mount
Installing GlusterFS
yum install glusterfs-server -y
systemctl enable glusterd
systemctl start glusterd
firewall-cmd --zone=public --add-service=nfs --add-service=glusterfs --add-service=samba --add-service=samba-client --permanent
firewall-cmd --zone=public --add-port=111/tcp --add-port=139/tcp --add-port=445/tcp --add-port=965/tcp --add-port=2049/tcp --add-port=38465-38469/tcp --add-port=631/tcp --add-port=111/udp --add-port=963/udp --add-port=49152-49251/tcp --permanent
firewall-cmd --zone=public --add-port=24010/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-all
From "server1"
gluster peer probe server2
Note: When using hostnames, the first server needs to be probed from one other server to set it's hostname.
From "server2"
gluster peer probe server1
Note: Once this pool has been established, only trusted members may probe new servers into the pool. A new server cannot probe the pool, it must be probed from the pool.
Set up a GlusterFS volume
On both server1 and server2:
mkdir /bricks/brick1/gv0
From any single server:
gluster volume create gv0 replica 2 server1:/bricks/brick1/gv0 server2:/bricks/brick1/gv0
gluster volume start gv0
Confirm that the volume shows "Started":
gluster volume info
Testing the GlusterFS volume
For this step, we will use one of the servers to mount the volume. Typically, you would do this from an external machine, known as a "client". Since using the method here would require additional packages to be installed on the client machine, we will use the servers as a simple place to test first.
mount -t glusterfs server1:/gv0 /mnt
for i in `seq -w 1 100`; do cp -rp /var/log/messages /mnt/copy-test-$i; done
First, check the mount point:
ls -lA /mnt | wc -l
You should see 100 files returned. Next, check the GlusterFS mount points on each server:
ls -lA /bricks/brick1/gv0
You should see 100 per server using the method we listed here. Without replication, in a distribute only volume (not detailed here), you should see about 50 each.
Using GlusterFS Client
On Ubuntu
Install glusterfs-client
sudo apt install -y glusterfs-client
# 修改hosts文件
tee /etc/hosts <<-'EOF'
192.168.161.131 server2
192.168.161.129 server1
EOF
sudo mkdir -p /mnt/glusterfs
sudo mount -t glusterfs server1:/gv0 /mnt/glusterfs
自动挂载
To mount a volume, edit the /etc/fstab
file and add the following line:
server1:/gv0 /mnt/glusterfs glusterfs defaults,_netdev 0 0
https://wiki.centos.org/SpecialInterestGroup/Storage/gluster-Quickstart
GlusterFS Documents