多可用区(AZ)
简介
Alluxio 通过支持多可用区实现高可用性。当本地可用区( AZ )内的所有 Worker 都无法处理请求时,Alluxio 客户端可以回退至其他 AZ 中的 Worker。
多可用区支持,加上多副本和底层文件系统回退机制,提供了强大的服务可用性和 I/O 弹性。更多相关信息参见 Alluxio的I/O 弹性功能。
启用多可用区支持
在存在多个可用区的典型部署场景中,通常是每个 AZ 部署一个 Alluxio 集群。为了区分各 AZ 中的集群,需要为每个 Alluxio 集群分配唯一的集群名称。
创建一个JSON配置文件,指定所有可用区的Alluxio集群及其对应的etcd集群。以下是一个包含3个集群的示例:
[
{
"clusterNames": ["cluster-1"],
"endpoints": ["http://etcd-1:2379"]
},
{
"clusterNames": ["cluster-2"],
"endpoints": ["http://etcd-2:2379"]
},
{
"clusterNames": ["cluster-3"],
"endpoints": ["http://etcd-3:2379"]
}
]
将此配置文件保存为multi-az-clusters.json
,并放置在Alluxio的配置目录中,然后在alluxio-site.properties
中指定路径:
alluxio.multi.cluster.enabled=true
alluxio.multi.cluster.config.path=${alluxio.conf.dir}/multi-az-clusters.json
如果 Alluxio 已在运行,需重启所有进程以使配置生效。重启后,可使用以下命令检查多 AZ 支持是否配置成功:
$ bin/alluxio info nodes
如果配置正确,该命令将显示来自各 AZ 中所有 Alluxio 集群的 Worker 节点信息:
Cluster cluster-1
WorkerId Address Status
worker-3e506284-c636-40f9-bdae-0ec695cf32c9 10.0.11.250:29999 ONLINE
worker-a17b8d07-2999-4ee4-ad0d-27929071b963 10.0.11.20:29999 ONLINE
worker-c40952a2-8dd1-4fcb-8a78-ad84f2c5f5cc 10.0.11.134:29999 OFFLINE
Cluster cluster-2
WorkerId Address Status
worker-078a69be-dc3b-4096-93f0-41db38190fd4 10.0.11.202:29999 ONLINE
worker-27537ea1-1e92-4b83-93b9-edaf0c713d85 10.0.11.201:29999 OFFLINE
worker-47412fac-6a31-4bf7-9de6-5cdeb37bc753 10.0.11.154:29999 ONLINE
Cluster cluster-3
WorkerId Address Status
worker-978a6dbe-da3b-4096-a3f0-41d27929071d 10.0.11.202:29999 ONLINE
worker-17537aa1-2e92-2b8b-b3b9-edaf0c713add 10.0.11.123:29999 OFFLINE
worker-37412fad-8a33-3bf3-cde6-5cb37bc75323 10.0.11.567:29999 ONLINE
使用 Operator 部署多个 Alluxio 集群
Alluxio Operator 提供了在 Kubernetes 环境中部署和管理 Alluxio 集群的标准方法。有关安装 Alluxio Operator 的详细说明,请参阅 Alluxio Operator 安装指南.
Operator 通过名为 clusterGroup
的自定义资源支持部署多个 Alluxio 集群。
通过 clusterGroup
,用户可以在Kubernetes环境中统一定义和管理多个 Alluxio 集群的配置,从而实现高效编排和维护。
注意:通过
clusterGroup
创建的集群将共享同一套配置(包括属性设置、资源分配和扩缩容策略)。 要区分不同集群,需要使用 Kubernetes 的nodeSelector
字段,将每个 Alluxio 集群限制部署在对应的 AZ 上,确保集群之间的物理隔离。
准备步骤
以下示例将在两个 Kubernetes 命名空间中部署三个 Alluxio 集群:
集群 1:
alluxio-a
in namespacealx-ns
集群 2:
alluxio-b
in namespacealx-ns
集群 3:
alluxio-c
in namespacealx-ns-2
部署前确保已创建所需命名空间 (alx-ns
and alx-ns-2
):
kubectl create namespace alx-ns
kubectl create namespace alx-ns-2
基于ETCD的多集群部署模式
为了配置多个集群,需要创建一个包含各个集群名称及其 ETCD 信息的 ConfigMap。根据 ETCD 的配置方式不同,每个集群的 ETCD 信息可能有所不同。
在使用 clusterGroup
资源部署多个 Alluxio 集群时,Alluxio 支持以下三种部署模式,这些模式依据 ETCD 的设置方式分类如下:
每个集群使用独立的 ETCD 实例
每个 Alluxio 集群使用其专属的 ETCD 实例。
多个集群共享同一个 ETCD 实例
多个集群共用一个 ETCD 实例,同时通过独立的命名空间实现隔离。
集成外部 ETCD
各集群连接至由外部托管的 ETCD 服务
这些模式为不同的运维需求和基础架构提供了灵活的部署选项,用户可根据实际情况选择合适的模式。
独立ETCD 模式
独立 ETCD 部署模式下,每个 Alluxio 集群运行在其专属的 ETCD 实例上。

在此模式下,配置文件 multi-az-clusters.json
必须进行自定义,从而为每个集群指定独立的 ETCD 端点,示例如下:
[
{
"clusterNames": ["alx-ns-alluxio-a"],
"endpoints": ["http://alluxio-a-etcd.alx-ns:2379"]
},
{
"clusterNames": ["alx-ns-alluxio-b"],
"endpoints": ["http://alluxio-b-etcd.alx-ns:2379"]
},
{
"clusterNames": ["alx-ns-2-alluxio-c"],
"endpoints": ["http://alluxio-c-etcd.alx-ns-2:2379"]
}
]
必须在每个命名空间中创建 ConfigMap
,并使用相同的配置文件:
kubectl create configmap multi-cluster --from-file=multi-az-clusters.json -n alx-ns
kubectl create configmap multi-cluster --from-file=multi-az-clusters.json -n alx-ns-2
然后,定义并应用ClusterGroup
清单来部署各个集群。要点如下:
必须在每个集群的
properties
中指定多集群 JSON 配置文件的路径。ConfigMap 必须挂载到所有 Alluxio 集群组件中的
/multi-az
目录下。
此外,用户需在 dependencies
中省略 ETCD 依赖项,以禁用 clusterGroup
中的内部 ETCD 配置功能。
apiVersion: k8s-operator.alluxio.com/v1
kind: ClusterGroup
metadata:
name: alluxio-cluster-group
namespace: alx-ns
spec:
dependencies:
dashboard:
image: alluxio/alluxio-dashboard
imageTag: AI-3.6-12.0.2
license: "licenseString"
gateway:
image: alluxio/alluxio-gateway
imageTag: AI-3.6-12.0.2
groups:
- name: alluxio-a
namespace: alx-ns
nodeSelector:
region: az-1
- name: alluxio-b
namespace: alx-ns
nodeSelector:
region: az-2
- name: alluxio-c
namespace: alx-ns-2
nodeSelector:
region: az-3
template:
spec:
image: alluxio/alluxio-enterprise
imageTag: AI-3.6-12.0.2
properties:
alluxio.multi.cluster.enabled: "true"
alluxio.multi.cluster.config.path: "/multi-az/multi-az-clusters.json"
worker:
count: 2
configMaps:
coordinator:
multi-cluster: /multi-az
worker:
multi-cluster: /multi-az
fuse:
multi-cluster: /multi-az
etcd:
replicaCount: 1
在此配置中,每个 Alluxio 集群将在各自的命名空间内独立启动并管理其专属的 ETCD 实例。clusterGroup
本身不会部署任何 ETCD 集群。
可通过list集群组命名空间中的 Pod 来进行验证。
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
alluxio-cg-dashboard-dfd4dcfb5-fvj8j 1/1 Running 0 3h27m
alluxio-cg-gateway-59df98fb66-kkz6l 1/1 Running 0 3h27m
每个 Alluxio 集群将在其对应的命名空间中运行自己的 ETCD 服务。
例如,在命名空间 alx-ns
中,alluxio-a
和 alluxio-b
两个集群将分别部署各自的 ETCD Pod:
$ kubectl get pod -n alx-ns
NAME READY STATUS RESTARTS AGE
alluxio-a-coordinator-0 1/1 Running 0 3h27m
alluxio-a-etcd-0 1/1 Running 0 3h27m
alluxio-a-grafana-66fd6b957f-gzjqz 1/1 Running 0 3h27m
alluxio-a-prometheus-678b98fccf-c569z 1/1 Running 0 3h27m
alluxio-a-worker-649cdbbbb-g94gh 1/1 Running 0 3h27m
alluxio-a-worker-649cdbbbb-mvvdg 1/1 Running 0 3h27m
alluxio-b-coordinator-0 1/1 Running 0 3h27m
alluxio-b-etcd-0 1/1 Running 0 3h27m
alluxio-b-grafana-5df79f9fdd-rj72b 1/1 Running 0 3h27m
alluxio-b-prometheus-69c867fd77-2whnh 1/1 Running 0 3h27m
alluxio-b-worker-6bc8db98c4-szw95 1/1 Running 0 3h27m
alluxio-b-worker-6bc8db98c4-zcwp9 1/1 Running 0 3h27m
同样地,alluxio-c
会在 alx-ns-2
命名空间中启动自己的 ETCD 实例。
$ kubectl get pod -n alx-ns-2
NAME READY STATUS RESTARTS AGE
alluxio-c-coordinator-0 1/1 Running 0 3h27m
alluxio-c-etcd-0 1/1 Running 0 3h27m
alluxio-c-grafana-85bbd744d9-9rvnf 1/1 Running 0 3h27m
alluxio-c-prometheus-57cb49b479-29gzv 1/1 Running 0 3h27m
alluxio-c-worker-556c696898-5lgrk 1/1 Running 0 3h27m
alluxio-c-worker-556c696898-m7tzb 1/1 Running 0 3h27m
要验证所有集群的状态,可使用以下命令:
$ kubectl exec -it -n alx-ns alluxio-a-coordinator-0 -- alluxio info nodes
输出示例:
Cluster alx-ns-2-alluxio-c
WorkerId Address Status
worker-0ed62e5d-c6f8-4062-b67d-b88749085fac 10.0.4.33:29999 ONLINE
worker-b940c3bb-f1c3-4446-91a4-663df1aab65b 10.0.4.78:29999 ONLINE
Cluster alx-ns-alluxio-a
WorkerId Address Status
worker-4c134fbc-7d52-4d30-a568-3ecf374ed382 10.0.4.162:29999 ONLINE
worker-eb9af320-d161-4d83-8484-7de105093e20 10.0.4.221:29999 ONLINE
Cluster alx-ns-alluxio-b
WorkerId Address Status
worker-68f3cd7f-e277-48fd-84f5-b653675670a7 10.0.4.226:29999 ONLINE
worker-907b9c42-cce5-4415-9069-3ec9ee6d10d2 10.0.4.175:29999 ONLINE
共享 ETCD 模式
共享 ETCD 部署模式下,所有 Alluxio 集群共用同一个 ETCD 集群来进行协调。

首先创建一个名为 multi-az-clusters.json
的 JSON 配置文件,用于指定参与的 Alluxio 集群及其共享的 ETCD 端点:
[
{
"clusterNames": ["alx-ns-alluxio-a"],
"endpoints": ["http://alluxio-cg-etcd.default:2379"]
},
{
"clusterNames": ["alx-ns-alluxio-b"],
"endpoints": ["http://alluxio-cg-etcd.default:2379"]
},
{
"clusterNames": ["alx-ns-2-alluxio-c"],
"endpoints": ["http://alluxio-cg-etcd.default:2379"]
}
]
必须在每个命名空间中创建 ConfigMap
,并使用相同的配置文件:
kubectl create configmap multi-cluster --from-file=multi-az-clusters.json -n alx-ns
kubectl create configmap multi-cluster --from-file=multi-az-clusters.json -n alx-ns-2
然后,定义并应用ClusterGroup
清单来部署各个集群。要点如下:
必须在每个集群的
properties
中指定多集群 JSON 配置文件的路径。ConfigMap 必须挂载到所有 Alluxio 集群组件中的
/multi-az
目录下。
要启用此模式,需要在 ClusterGroup 资源的 dependencies
中配置 ETCD 依赖项。
示例如下:
apiVersion: k8s-operator.alluxio.com/v1
kind: ClusterGroup
metadata:
name: alluxio-cg
namespace: default
spec:
dependencies:
etcd:
replicaCount: 3
dashboard:
image: alluxio/alluxio-dashboard
imageTag: AI-3.6-12.0.2
license: "licenseString"
gateway:
image: alluxio/alluxio-gateway
imageTag: AI-3.6-12.0.2
groups:
- name: alluxio-a
namespace: alx-ns
nodeSelector:
region: az-1
- name: alluxio-b
namespace: alx-ns
nodeSelector:
region: az-2
- name: alluxio-c
namespace: alx-ns-2
nodeSelector:
region: az-3
template:
spec:
image: alluxio/alluxio-enterprise
imageTag: AI-3.6-12.0.2
properties:
alluxio.multi.cluster.enabled: "true"
alluxio.multi.cluster.config.path: "/multi-az/multi-az-clusters.json"
worker:
count: 2
configMaps:
coordinator:
multi-cluster: /multi-az
worker:
multi-cluster: /multi-az
fuse:
multi-cluster: /multi-az
使用以下命令来应用此YAML 文件:
kubectl apply -f clusterGroup.yaml
应用完成后,将会创建一个共享ETCD 集群,所有 Alluxio 集群都会连接到该集群:
kubectl get pod
NAME READY STATUS RESTARTS AGE
alluxio-cg-dashboard-7868ff9968-844jp 1/1 Running 0 36s
alluxio-cg-etcd-0 1/1 Running 0 28m
alluxio-cg-etcd-1 1/1 Running 0 28m
alluxio-cg-etcd-2 1/1 Running 0 28m
alluxio-cg-gateway-59df98fb66-zh59q 1/1 Running 0 28m
集群 alluxio-a
和 alluxio-b
将部署在命名空间 alx-ns
中:
$ kubectl get pod -n alx-ns -w
NAME READY STATUS RESTARTS AGE
alluxio-a-coordinator-0 1/1 Running 1 (7m29s ago) 8m27s
alluxio-a-grafana-66fd6b957f-zp2mh 1/1 Running 0 8m27s
alluxio-a-prometheus-678b98fccf-48p9d 1/1 Running 0 8m27s
alluxio-a-worker-b98859c7-h5qtd 1/1 Running 1 (7m20s ago) 8m27s
alluxio-a-worker-b98859c7-z6wx2 1/1 Running 1 (7m17s ago) 8m27s
alluxio-b-coordinator-0 1/1 Running 1 (7m25s ago) 8m25s
alluxio-b-grafana-5df79f9fdd-wxx6n 1/1 Running 0 8m25s
alluxio-b-prometheus-69c867fd77-fdxc4 1/1 Running 0 8m25s
alluxio-b-worker-5b6d5fdfbd-44r9q 1/1 Running 1 (7m14s ago) 8m25s
alluxio-b-worker-5b6d5fdfbd-k47vh 1/1 Running 1 (7m18s ago) 8m25s
位于alx-ns-2
命名空间下的集群,例如 alluxio-c
,也将启动:
$ kubectl get pod -n alx-ns-2 -w
NAME READY STATUS RESTARTS AGE
alluxio-c-coordinator-0 1/1 Running 1 (7m30s ago) 8m29s
alluxio-c-grafana-85bbd744d9-v9mr6 1/1 Running 0 8m29s
alluxio-c-prometheus-57cb49b479-w7njl 1/1 Running 0 8m29s
alluxio-c-worker-fb6d6f4cf-bp85r 1/1 Running 1 (7m28s ago) 8m29s
alluxio-c-worker-fb6d6f4cf-pdh9q 1/1 Running 1 (7m20s ago) 8m29s
要验证集群状态和 Worker 注册情况,运行以下命令:
kubectl exec -it -n alx-ns alluxio-a-coordinator-0 -- alluxio info nodes
输出将显示多个 Alluxio 集群及其各自的 Worker 节点信息:
Cluster alx-ns-2-alluxio-c
WorkerId Address Status
worker-0ed62e5d-c6f8-4062-b67d-b88749085fac 10.0.4.200:29999 ONLINE
worker-b940c3bb-f1c3-4446-91a4-663df1aab65b 10.0.4.718:29999 ONLINE
Cluster alx-ns-alluxio-a
WorkerId Address Status
worker-4c134fbc-7d52-4d30-a568-3ecf374ed382 10.0.4.162:29999 ONLINE
worker-eb9af320-d161-4d83-8484-7de105093e20 10.0.4.120:29999 ONLINE
Cluster alx-ns-alluxio-b
WorkerId Address Status
worker-68f3cd7f-e277-48fd-84f5-b653675670a7 10.0.4.134:29999 ONLINE
worker-907b9c42-cce5-4415-9069-3ec9ee6d10d2 10.0.4.164:29999 ONLINE
外部 ETCD
外部 ETCD 模式下,所有 Alluxio 集群都会连接到一个共享的、由外部托管的 ETCD 集群。

如果已部署外部 ETCD 集群,可以配置 Alluxio 集群连接到该集群:
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
external-etcd-0 1/1 Running 0 6m10s
external-etcd-1 1/1 Running 0 6m10s
external-etcd-2 1/1 Running 0 6m10s
创建一个配置文件 multi-az-clusters.json
,用于定义所有集群共享的外部 ETCD 端点:
[
{
"clusterNames": ["alx-ns-alluxio-a"],
"endpoints": ["http://external-etcd.default:2379"]
},
{
"clusterNames": ["alx-ns-alluxio-b"],
"endpoints": ["http://external-etcd.default:2379"]
},
{
"clusterNames": ["alx-ns-2-alluxio-c"],
"endpoints": ["http://external-etcd.default:2379"]
}
]
必须在每个命名空间中创建 ConfigMap
,并使用相同的配置文件:
kubectl create configmap multi-cluster --from-file=multi-az-clusters.json -n alx-ns
kubectl create configmap multi-cluster --from-file=multi-az-clusters.json -n alx-ns-2
然后,定义并应用ClusterGroup
清单来部署各个集群。要点如下:
禁用 ETCD
在
ClusterGroup
配置中将etcd.enabled
设置为false
,以防止 Operator 部署其自身的 ETCD 实例在
dependencies
中省略etcd
依赖项。
在 Alluxio 集群的
properties
中指定外部 ETCD 端点。
ClusterGroup
示例如下:
apiVersion: k8s-operator.alluxio.com/v1
kind: ClusterGroup
metadata:
name: alluxio-cg
namespace: default
spec:
dependencies: # ETCD is not included here
dashboard:
image: alluxio/alluxio-dashboard
imageTag: AI-3.6-12.0.2
license: "licenseString"
gateway:
image: alluxio/alluxio-gateway
imageTag: AI-3.6-12.0.2
groups:
- name: alluxio-a
namespace: alx-ns
nodeSelector:
region: az-1
- name: alluxio-b
namespace: alx-ns
nodeSelector:
region: az-2
- name: alluxio-c
namespace: alx-ns-2
nodeSelector:
region: az-3
template:
spec:
image: alluxio/alluxio-enterprise
imageTag: AI-3.6-12.0.2
properties:
alluxio.multi.cluster.enabled: "true"
alluxio.multi.cluster.config.path: "/multi-az/multi-az-clusters.json"
alluxio.etcd.endpoints: "http://external-etcd.default:2379"
worker:
count: 2
configMaps:
coordinator:
multi-cluster: /multi-az
worker:
multi-cluster: /multi-az
fuse:
multi-cluster: /multi-az
etcd:
enabled: false # Explicitly disable internal ETCD
应用该配置:
$ kubectl apply -f clusterGroup.yaml
外部 ETCD Pod 应在default
命名空间中运行:
$ kubectl get pod
NAME READY STATUS RESTARTS AGE
alluxio-cg-dashboard-dfd4dcfb5-h2wbw 1/1 Running 0 8m45s
alluxio-cg-gateway-59df98fb66-7jd6x 1/1 Running 0 8m46s
external-etcd-0 1/1 Running 0 12m
external-etcd-1 1/1 Running 0 12m
external-etcd-2 1/1 Running 0 12m
各个 Alluxio 集群的 Pod 在其对应的命名空间中运行:
$ kubectl get pod -n alx-ns
NAME READY STATUS RESTARTS AGE
alluxio-a-coordinator-0 1/1 Running 0 8m36s
alluxio-a-grafana-66fd6b957f-kcb4r 1/1 Running 0 8m36s
alluxio-a-prometheus-678b98fccf-lcgmp 1/1 Running 0 8m36s
alluxio-a-worker-66768f7d46-42tvc 1/1 Running 0 8m36s
alluxio-a-worker-66768f7d46-zlccd 1/1 Running 0 8m36s
alluxio-b-coordinator-0 1/1 Running 0 8m34s
alluxio-b-grafana-5df79f9fdd-qmnfw 1/1 Running 0 8m34s
alluxio-b-prometheus-69c867fd77-db72c 1/1 Running 0 8m34s
alluxio-b-worker-5f8dbd89dc-g54c2 1/1 Running 0 8m34s
alluxio-b-worker-5f8dbd89dc-ltm5p 1/1 Running 0 8m33s
$ kubectl get pod -n alx-ns-2
NAME READY STATUS RESTARTS AGE
alluxio-c-coordinator-0 1/1 Running 0 8m34s
alluxio-c-grafana-85bbd744d9-pxgmg 1/1 Running 0 8m34s
alluxio-c-prometheus-57cb49b479-jpqff 1/1 Running 0 8m34s
alluxio-c-worker-6b55f954b4-8bd6l 1/1 Running 0 8m34s
alluxio-c-worker-6b55f954b4-gg5qj 1/1 Running 0 8m33s
检查多集群状态:
$ kubectl exec -it -n alx-ns alluxio-a-coordinator-0 -- alluxio info nodes
Cluster alx-ns-2-alluxio-c
WorkerId Address Status
worker-0ed62e5d-c6f8-4062-b67d-b88749085fac 10.0.4.36:29999 ONLINE
worker-b940c3bb-f1c3-4446-91a4-663df1aab65b 10.0.4.15:29999 ONLINE
Cluster alx-ns-alluxio-a
WorkerId Address Status
worker-4c134fbc-7d52-4d30-a568-3ecf374ed382 10.0.4.162:29999 ONLINE
worker-eb9af320-d161-4d83-8484-7de105093e20 10.0.4.221:29999 ONLINE
Cluster alx-ns-alluxio-b
WorkerId Address Status
worker-68f3cd7f-e277-48fd-84f5-b653675670a7 10.0.4.85:29999 ONLINE
worker-907b9c42-cce5-4415-9069-3ec9ee6d10d2 10.0.4.222:29999 ONLINE
启用多可用区多副本文件的 I/O优化
Alluxio 支持针对多副本文件的 I/O优化。当文件在多个可用区中存在副本时,这些副本不仅能提供更快的访问速度,还能在某个可用区发生故障导致部分集群不可用时,确保系统的高可用性。
当 Alluxio 客户端读取一个在多可用区中有副本的文件时,首先会检查本地集群中是否有任何本地 worker 缓存了该文件。如果有,客户端会尝试使用本地 worker 读取文件。如果本地没有缓存该文件,或者在本地可用区发生故障导致所有本地 worker 读取失败,客户端将回退到其他可用区中其他集群的 worker。如果所有候选 worker 都无法响应读取请求,客户端将最终回退到UFS,将其作为保底访问方案。
对于不在多个可用区中有副本的文件而言,客户端在本地 worker 读取失败时不会回退到其他可用区,而是直接回退到 UFS。
注意:如果启用了该功能,客户端会优先选择完整缓存的文件副本(即使该副本位于远程 worker)。客户端按照以下优先级顺序选择数据源:
拥有完整缓存文件的本地 worker。
拥有完整缓存文件的远程 worker。
本地或远程worker均没有完整缓存文件时,选择本地 worker。
本地候选 worker 不可用时,选择远程 worker。
所有可用区的候选 worker 均不可用时,回退到UFS。
启用被动缓存
建议在多可用区多副本部署中启用 被动缓存(Passive Cache)功能。该配置能确保副本不足的文件自动生成更多副本,并且不会因首选 worker 缓存未命中而影响性能。
要启用 I/O 优化和被动缓存,请在 alluxio-site.properties
中添加以下配置:
# 注意,必须启用多副本优化 I/O 功能,被动缓存才能生效
alluxio.user.replica.prefer.cached.replicas=true
alluxio.user.file.passive.cache.enabled=true
Last updated