概述
单个 master 的稳定性可能较低,在一些线上提供服务的场景,需要使用多 master 来保证容错率。GooseFSRuntime 提供以 3 master 的形式来提供容错,通过 Raft 协议来进行选举,raft 是工程上使用较为广泛的强一致性、去中心化、高可用的分布式协议。
下面将为您简单地介绍上述特性。
前提条件
$ kubectl get pod -n fluid-systemgoosefsruntime-controller-5b64fdbbb-84pc6 1/1 Running 0 8hcsi-nodeplugin-fluid-fwgjh 2/2 Running 0 8hcsi-nodeplugin-fluid-ll8bq 2/2 Running 0 8hcsi-nodeplugin-fluid-dhz7d 2/2 Running 0 8hdataset-controller-5b7848dbbb-n44dj 1/1 Running 0 8h
通常来说,您会看到一个名为
dataset-controller
的 Pod、一个名为 goosefsruntime-controller
的 Pod 和多个名为 csi-nodeplugin
的 Pod 正在运行。其中,csi-nodeplugin
这些 Pod 的数量取决于您的 Kubernetes 集群中结点的数量。新建工作环境
$ mkdir <any-path>/co-locality$ cd <any-path>/co-locality
示例
查看全部结点
$ kubectl get nodesNAME STATUS ROLES AGE VERSION192.168.1.145 Ready <none> 7d14h v1.18.4-tke.13192.168.1.146 Ready <none> 7d14h v1.18.4-tke.13192.168.1.147 Ready <none> 7d14h v1.18.4-tke.13
检查待创建的 Dataset 资源对象
apiVersion: data.fluid.io/v1alpha1kind: Datasetmetadata:name: hbasespec:mounts:- mountPoint: https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/stable/name: hbase
说明
创建 Dataset 资源对象
$ kubectl create -f dataset.yamldataset.data.fluid.io/hbase created
检查待创建的 GooseFSRuntime 资源对象
apiVersion: data.fluid.io/v1alpha1kind: GooseFSRuntimemetadata:name: hbasespec:replicas: 3tieredstore:levels:- mediumtype: HDDpath: /mnt/disk1quota: 2Ghigh: "0.8"low: "0.7"master:replicas: 3
我们通过指定
spec.master.replicas=3
来开启 Raft 3 master 模式,该参数必须为正奇数。创建GooseFSRuntime资源并查看状态
$ kubectl create -f runtime.yamlgoosefsruntime.data.fluid.io/hbase created$ kubectl get podNAME READY STATUS RESTARTS AGEhbase-fuse-4v9mq 1/1 Running 0 84shbase-fuse-5kjbj 1/1 Running 0 84shbase-fuse-tp2q2 1/1 Running 0 84shbase-master-0 1/1 Running 0 104shbase-master-1 1/1 Running 0 102shbase-master-2 1/1 Running 0 100shbase-worker-cx8x7 1/1 Running 0 84shbase-worker-fjsr6 1/1 Running 0 84shbase-worker-fvpgc 1/1 Running 0 84s
查看 GooseFSRuntime 状态
NAME MASTER PHASE WORKER PHASE FUSE PHASE AGEhbase Ready Ready Ready 15m
确认
PHASE
全部为 Ready。查看 Raft 状态 leader/follower
登录其中一个 master 的 pod:
$ kubectl exec -ti hbase-master-0 bash$ goosefs fs masterInfo
可以看到其中一个节点是
LEADER
,其余两个是 FOLLOWER
:current leader master: hbase-master-0:26000All masters: [hbase-master-0:26000, hbase-master-1:26000, hbase-master-2:26000]