准备三台服务器分别安装,可以使用Xshell -工具-发送键输入到-已连接会话,把会话窗口的on 变成off,这样在一台机器上操作,其他机器可以执行相同的命令。
1,加glusterFS最新源
sudo add-apt-repository ppa:gluster/glusterfs-11
sudo apt update
sudo apt install software-properties-common
sudo apt install glusterfs-server -y
# 启动GlusterFS服务,安装完成后,可能没有自动运行,需要手动执行来启动服务.(所有节点均需启动) sudo service glusterd start # 查看服务运行状态 sudo service glusterd status
● glusterd.service - GlusterFS, a clustered file-system server
Loaded: loaded (/lib/systemd/system/glusterd.service; disabled; vendor preset: enabled)
Active: active (running) since Fri 2022-06-17 13:38:07 CST; 5s ago
sudo nano /etc/hosts
127.0.0.1 localhost 192.168.2.50 glusterfs-01 192.168.2.51 glusterfs-02 192.168.2.52 glusterfs-03
sudo gluster peer probe glusterfs-02 sudo gluster peer probe glusterfs-03
Output peer probe: success
sudo gluster peer status
Number of Peers: 2 Hostname: glusterfs-02 Uuid: 3a619f9e-6eb6-47e7-9301-7866ca9cdb53 State: Peer in Cluster (Connected) Hostname: glusterfs-03 Uuid: e843edad-7cd7-40b9-afe1-9e8d4824afd4 State: Peer in Cluster (Connected)
sudo gluster volume create volume_name replica number_of_servers domain1.com:/path/to/data/directory domain2.com:/path/to/data/directory force
以下是此gluster volume create命令的参数和选项的含义:
sudo gluster volume create gv0 replica 3 glusterfs-01:/glusterdata glusterfs-02:/glusterdata glusterfs-03:/glusterdata force
volume create: gv0: success: please start the volume to access data
sudo gluster volume status
Volume gv0 is not started
sudo gluster volume start gv0
Status of volume: gv0 Gluster process TCP Port RDMA Port Online Pid ------------------------------------------------------------------------------ Brick glusterfs-01:/glusterdata 56164 0 Y 3112 Brick glusterfs-02:/glusterdata 58153 0 Y 2897 Brick glusterfs-03:/glusterdata 60500 0 Y 2916 Self-heal Daemon on localhost N/A N/A Y 3144 Self-heal Daemon on glusterfs-02 N/A N/A Y 2929 Self-heal Daemon on glusterfs-03 N/A N/A Y 2948 Task Status of Volume gv0 ------------------------------------------------------------------------------ There are no active volume tasks
sudo ufw allow from glusterfs-02_ip_address to any port 56164 58153 60500
然后,为了增加一层安全性,deny在gluster0 和 gluster1上为卷的端口添加另一个总规则。这将确保除了您的客户端之外的任何机器都无法访问任一服务器上的卷:
sudo ufw deny 56164 58153 60500
# 注册开机自启(所有节点均需要开机自启,并且只需要执行一次就可以) sudo systemctl enable glusterd.service
挂载:
mount -t glusterfs k8s-jundax-dev-worker-01:/mygluster /mnt
hash在平衡,用户新加节点
gluster volume rebalance dist-replica-alarm-15 start
查看状态
gluster volume rebalance dist-replica-alarm-15 status
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!