![如果已安装的服务器发生故障,GlusterFS 如何(智能地)进行故障转移?](https://linux22.com/image/68296/%E5%A6%82%E6%9E%9C%E5%B7%B2%E5%AE%89%E8%A3%85%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%8F%91%E7%94%9F%E6%95%85%E9%9A%9C%EF%BC%8CGlusterFS%20%E5%A6%82%E4%BD%95%EF%BC%88%E6%99%BA%E8%83%BD%E5%9C%B0%EF%BC%89%E8%BF%9B%E8%A1%8C%E6%95%85%E9%9A%9C%E8%BD%AC%E7%A7%BB%EF%BC%9F.png)
在 GlusterFS 中,假设我在一个卷上有 2 个节点(服务器)。假设卷信息是这样的:
Volume Name: volume-www
Brick1: gluster-server-01:/volume-www/brick
Brick2: gluster-server-02:/volume-www/brick
正如我们所知,从客户端,我们必须volume-www
通过从一台服务器安装来安装卷。喜欢:
mount -t glusterfs gluster-server-01:/volume-www /var/www
我仍然觉得有一个瓶颈,因为我gluster-server-01
只连接到它。
- 如果失败怎么办?
当然,我可以再次从另一台健康的服务器手动挂载。但有没有更聪明的方法(工业方法)来解决这个问题?
答案1
当你这样做时:
mount -t glusterfs gluster-server-01:/volume-www /var/www
您最初连接到组成 Gluster 卷的节点之一,但 Gluster Native Client(基于 FUSE)从 接收有关其他节点的信息gluster-server-01
。由于客户端现在了解其他节点,因此它可以优雅地处理故障转移场景。
答案2
OpenUserX03 的回答不太准确。
当客户端连接到 Gluster 服务器节点时,它会收到有关所有节点的信息。之后,它开始同时与多个节点通信。因此,当一个节点死亡时,它不会“故障转移”,它只是失去该节点,但保持与其他节点的通信继续进行:
在他们的记录注释中:
mount 命令中指定的服务器仅用于获取描述卷名称的 gluster 配置 volfile。随后,客户端将直接与 volfile 中提到的服务器进行通信(甚至可能不包括用于挂载的服务器)。
答案3
您可以使用以下两种方式:
- 使用 backupvolfile 选项 fstab
server1_name:/media /media glusterfs 默认值,_netdev,backupvolfile-server=server2_name,log-level=WARNING,log-file=/var/log/gluster.log 0 0
- 创建数据文件 /etc/datastore.vol 示例
volume mymedia-client-0 type protocol/client option clnt-lk-version 1 option volfile-checksum 0 option volfile-key /mymedia option client-version 3.8.12 option process-uuid server01.vn-7565-2017/10/03-02 option fops-version 1298437 option ping-timeout 42 option remote-host 192.168.10.79 option remote-subvolume /data01/brick option transport-type socket option transport.address-family inet option send-gids true end-volume volume mymedia-client-1 type protocol/client option clnt-lk-version 1 option volfile-checksum 0 option volfile-key /mymedia option client-version 3.8.12 option process-uuid server01.vn-7565-2017/10/03-02 option fops-version 1298437 option ping-timeout 42 option remote-host 192.168.10.80 option remote-subvolume /data01/brick option transport-type socket option transport.address-family inet option send-gids true end-volume volume mymedia-replicate-0 type cluster/replicate subvolumes mymedia-client-0 mymedia-client-1 end-volume volume mymedia-client-2 type protocol/client option ping-timeout 42 option remote-host 192.168.10.81 option remote-subvolume /data01/brick option transport-type socket option transport.address-family inet option send-gids true end-volume volume mymedia-client-3 type protocol/client option ping-timeout 42 option remote-host 192.168.10.82 option remote-subvolume /data01/brick option transport-type socket option transport.address-family inet option send-gids true end-volume volume mymedia-replicate-1 type cluster/replicate subvolumes mymedia-client-2 mymedia-client-3 end-volume volume mymedia-dht type cluster/distribute option lock-migration off subvolumes mymedia-replicate-0 mymedia-replicate-1 end-volume volume mymedia-write-behind type performance/write-behind subvolumes mymedia-dht end-volume volume mymedia-read-ahead type performance/read-ahead subvolumes mymedia-write-behind end-volume volume mymedia-readdir-ahead type performance/readdir-ahead subvolumes mymedia-read-ahead end-volume volume mymedia-io-cache type performance/io-cache subvolumes mymedia-readdir-ahead end-volume volume mymedia-quick-read type performance/quick-read subvolumes mymedia-io-cache end-volume volume mymedia-open-behind type performance/open-behind subvolumes mymedia-quick-read end-volume volume mymedia-md-cache type performance/md-cache subvolumes mymedia-open-behind end-volume volume mymedia type debug/io-stats option log-level INFO option latency-measurement off option count-fop-hits off subvolumes mymedia-md-cache end-volume volume meta-autoload type meta subvolumes mymedia end-volume
与 fstab 内容对比:
/etc/datastore.vol /media glusterfs defaults,_netdev,log-level=WARNING,log-file=/var/log/gluster.log 0 0