# 许可证

用户需要提供 License 才能运行 Alluxio，试用版本除外。License 由 Alluxio 的销售代表以文本字符串的形式提供。

License 有两种形式，适用于不同的使用方式：

* 集群 License 通过设置集群的配置属性来应用
* 部署 License 则通过创建一个单独的 License CRD 来应用

## 集群 License

集群 License 是为单个测试集群提供 License 的默认方式; 不推荐用于生产环境部署。

在[部署 Alluxio](/ee-ai-cn/ai-3.6/start/install/install-alluxio-on-kubernetes.md) 的过程中创建 `alluxio-cluster.yaml` 文件时，请在`spec.properties`添加 `alluxio.license` ：

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: AlluxioCluster
spec:
  properties:
    alluxio.license: <CLUSTER_LICENSE>
```

## 部署 License

部署 License 是为生产环境部署提供 License 的默认方式。一个部署 License 可以为多个集群提供授权。与从配置中读取 License 字符串不同，集群进程将从 ETCD 中获取 License。

生成部署 License 的前提条件是提供每个集群的名称和命名空间。

在部署 Alluxio 的过程中创建 `alluxio-cluster.yaml` 文件时，请确保不要在 `spec.properties` 下设置 `alluxio.license` 项，否则系统将默认其为集群 License 使用。

启动集群后，请等待 coordinator 和 worker 的 pod 状态达到 `Init:2/3` ；如果未启用 ETCD 部署，则状态将为 `Init:1/2`。这表示这些 pod 正在等待 License 分配到 ETCD。\
接下来，创建一个`alluxio-license.yaml`:

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: License
metadata:
  name: alluxio-license
  namespace: alx-ns
spec:
  clusters:
  - name: <clusterName>
    namespace: <namespaceName>
  - name: <clusterName2>
    namespace: <namespaceName2>
  licenseString: <DEPLOYMENT_LICENSE>
```

`<DEPLOYMENT_LICENSE>` 是提供的部署 License 字符串。\
`<clusterName>` 和 `<namespaceName>` 应与 `alluxio-cluster.yaml` 文件中 `metadata` 下对应的值保持一致:

```yaml
apiVersion: k8s-operator.alluxio.com/v1
kind: AlluxioCluster
metadata:
  name: <clusterName>
  namespace: <namespaceName>
```

如果未设置命名空间（namespace），则使用 `default` 作为命名空间名称。如果有多个集群由同一个 Operator 管理，请继续在 `clusters` 下列出每个集群的名称和命名空间。

{% hint style="warning" %}
仅在 `alluxio-license.yaml` 中指定已启动的集群。如果 Operator 无法找到其中任何一个集群，则许可证操作将失败，并且所有集群都无法继续部署。
{% endhint %}

通过运行 `kubectl create -f alluxio-license.yaml` 命令来应用 License。\
然后再次检查 Alluxio 的 pod，它们的状态应很快从 `Init` 变为 `Running`.

### 更新一个部署 License

使用之前相同的 `alluxio-license.yaml` 文件来指定集群。将 `licenseString` 更新为新的部署 License 字符串。

通过先删除再创建的方式重新应用 License：

```
kubectl delete -f alluxio-license.yaml
kubectl create -f alluxio-license.yaml
```

Alluxio 进程将会被通知以获取并应用新的 License。

## 检查 License 状态

`bin/alluxio license` 目录下的 CLI 命令用于描述 License 的详细信息以及集群对 License 限制的使用情况。

要查看 License 的内容，例如过期日期和集群容量等信息,请运行 `bin/alluxio license show`.

```bash
$ bin/alluxio license show
{
    "type": "official",
    "productionId": "<productionId>",
    "licenseId": "<licenseId>",
    "licenseVersion": 1,
    "expirationDate": "2025-01-01T00:00:00Z",
    "gracePeriodDate": "2025-01-01T00:00:00Z",
    "maxTotalStorageCapacityGB": 5000
}
```

想要查看 License 限制的使用情况，请运行以下命令 `bin/alluxio license status`.

```bash
$ bin/alluxio license status
{
    "summary": {
        "vCPU": 9,
        "memory": "12.00GB",
        "storage": "100.00GB",
        "processes": 2,
        "versions": {
            "<licenseId>": 2
        }
    },
    "processes": {
        "10.0.0.1:29999": {
            "licenseId": "<licenseId>",
            "vCPU": 8,
            "memory": "8.00GB",
            "storage": "100.00GB"
        },
        "alluxio-coordinator-0.alluxio:19998": {
            "licenseId": "<licenseId>",
            "vCPU": 1,
            "memory": "4.00GB"
        }
    }
}
```

`summary`部分描述了每个独立进程列出的所有值的总和。 需要特别注意的字段包括：

* `storage` 是员工总容量，若存在 License 的`maxTotalStorageCapacityGB` （最大总存储容量 GB），则会将该值与其进行对比。
* `processes` 是进程总数，若存在 License 的 `maxProcessCount` （最大进程数），则会将该值与其进行对比
* `versions` 将 License ID 映射到配置了相应 License 的进程数量。\
  通常预期所有进程均配置相同的 License，但由于 License 更新不完整，可能会出现不匹配的情况。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.alluxio.io/ee-ai-cn/ai-3.6/start/install/license.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
