#6 GlusterFS集群搭建(下)
安装 GlusterFS
参考 GlusterFS 官方安装文档进行配置
安装 software-properties-common
这是一个添加PPA源的工具。
sudo apt install software-properties-common
添加 GlusterFS PPA
sudo add-apt-repository ppa:gluster/glusterfs-7
sudo apt update
安装程序包
sudo apt install glusterfs-server -y
启动 GlusterFS
sudo systemctl start glusterd
集群 GlusterFS
添加 GlusterFS 节点
在某一台节点上操作即可。(比如ipfs2节点)
msmn-2010@ipfs2:~$ sudo gluster peer probe ipfs1
peer probe: success
msmn-2010@ipfs2:~$ sudo gluster peer probe ipfs2
peer probe: Probe on localhost not needed
当前本机节点无需添加,只需要添加其他节点即可。
查看集群
msmn-2010@ipfs2:~$ sudo gluster peer status
Number of Peers: 1
Hostname: ipfs1
Uuid: e7fcd0a3-e4ea-410e-b529-c36f408526f3
State: Peer in Cluster (Connected)
创建卷
gluster默认是无法在系统根目录挂载点创建卷的,先要创建子目录。
sudo mkdir -p /zfs-storage/data
然后创建名为gv1的分布卷(其他卷类型暂不涉及),非要挂载到系统根目录可以用 force
msmn-2010@ipfs2:~$ sudo gluster volume create gv1 ipfs1:/zfs-storage/data ipfs2:/zfs-storage/data
volume create: gv1: success: please start the volume to access data
查看卷信息
msmn-2010@ipfs2:~$ sudo gluster volume info
Volume Name: gv1
Type: Distribute
Volume ID: 6df3e313-6a70-45eb-9c4e-d873c5605050
Status: Created
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: ipfs1:/zfs-storage/data
Brick2: ipfs2:/zfs-storage/data
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
启动卷
sudo gluster volume start gv1
添加挂载点
创建一个挂载目录gv1在根目录下。
sudo mkdir -p /gv1
挂载gv1这个卷到gv1这个目录下
sudo mount -t glusterfs ipfs2:/gv1 /gv1
ipfs1同理也操作一遍。
msmn-2010@ipfs2:~$ sudo df -Th
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 793M 2.0M 791M 1% /run
rpool/ROOT/ubuntu_ttgznt zfs 15G 3.0G 12G 20% /
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
bpool/BOOT/ubuntu_ttgznt zfs 581M 198M 383M 35% /boot
rpool/USERDATA/msmn-2010_7j52ic zfs 12G 70M 12G 1% /home/msmn-2010
rpool/USERDATA/root_7j52ic zfs 12G 640K 12G 1% /root
rpool/ROOT/ubuntu_ttgznt/srv zfs 12G 128K 12G 1% /srv
rpool/ROOT/ubuntu_ttgznt/var/games zfs 12G 128K 12G 1% /var/games
rpool/ROOT/ubuntu_ttgznt/usr/local zfs 12G 128K 12G 1% /usr/local
rpool/ROOT/ubuntu_ttgznt/var/snap zfs 12G 640K 12G 1% /var/snap
rpool/ROOT/ubuntu_ttgznt/var/lib zfs 13G 1.3G 12G 10% /var/lib
/dev/sda2 vfat 512M 19M 494M 4% /boot/efi
rpool/ROOT/ubuntu_ttgznt/var/www zfs 12G 128K 12G 1% /var/www
rpool/ROOT/ubuntu_ttgznt/var/spool zfs 12G 128K 12G 1% /var/spool
rpool/ROOT/ubuntu_ttgznt/var/log zfs 12G 18M 12G 1% /var/log
rpool/ROOT/ubuntu_ttgznt/var/mail zfs 12G 128K 12G 1% /var/mail
rpool/ROOT/ubuntu_ttgznt/var/lib/AccountsService zfs 12G 128K 12G 1% /var/lib/AccountsService
rpool/ROOT/ubuntu_ttgznt/var/lib/dpkg zfs 12G 33M 12G 1% /var/lib/dpkg
rpool/ROOT/ubuntu_ttgznt/var/lib/apt zfs 12G 80M 12G 1% /var/lib/apt
rpool/ROOT/ubuntu_ttgznt/var/lib/NetworkManager zfs 12G 256K 12G 1% /var/lib/NetworkManager
zfs-storage zfs 58G 256K 58G 1% /zfs-storage
tmpfs tmpfs 793M 112K 793M 1% /run/user/1000
ipfs2:/gv1 fuse.glusterfs 116G 4.0G 112G 4% /gv1
zfs-storage是我们创建的zfs存储池,raidz1,是4块20GB的磁盘组成的。可用容量为N-1。 ipfs2:/gv1则是我们创建的存储集群挂载点,通过容量可以观察到,正好是ipfs1+ipfs2的容量总和。 至此,我们GlusterFS存储集群搭建完毕。
测试 GlusterFS
sudo touch test{1..100}
进入本机的zfs存储池查看文件
msmn-2010@ipfs1:/zfs-storage/data$ ls
test1 test2 test32 test40 test48 test53 test60 test65 test78 test83 test88 test95
test13 test22 test36 test43 test5 test54 test61 test69 test79 test84 test9 test96
test16 test26 test37 test45 test50 test56 test62 test71 test8 test85 test90 test97
test19 test31 test4 test47 test52 test59 test63 test72 test81 test87 test92 test98
msmn-2010@ipfs1:/zfs-storage/data$ ls | wc -l
48
然后进入另一个节点查看文件
msmn-2010@ipfs2:/zfs-storage/data$ ls
test10 test14 test20 test25 test3 test35 test42 test51 test6 test68 test74 test80 test91
test100 test15 test21 test27 test30 test38 test44 test55 test64 test7 test75 test82 test93
test11 test17 test23 test28 test33 test39 test46 test57 test66 test70 test76 test86 test94
test12 test18 test24 test29 test34 test41 test49 test58 test67 test73 test77 test89 test99
msmn-2010@ipfs2:/zfs-storage/data$ ls | wc -l
52
可以看到,这100个文件被均分到了各个节点的zfs存储池中。
最終更新
役に立ちましたか?