diff --git a/br/backup-and-restore-storages.md b/br/backup-and-restore-storages.md index 177e280d175f..30dad090d1a7 100644 --- a/br/backup-and-restore-storages.md +++ b/br/backup-and-restore-storages.md @@ -203,6 +203,66 @@ tiup br restore db --db test -u "${PD_IP}:2379" \ --storage "azure://external/backup-20220915?account-name=${account-name}" ``` +- 方式四:使用 Azure 托管标识 (Managed Identity) + + 从 v8.5.5 和 v9.0.0 起,如果你的 TiDB 集群和 br 命令行工具运行在 Azure 虚拟机 (VM) 或 Azure Kubernetes Service (AKS) 环境中,并且已为节点分配了 Azure 托管标识,则可以使用 Azure 托管标识进行鉴权。 + + 使用此方式前,请确保已在 [Azure Portal](https://azure.microsoft.com/) 中为对应的托管标识授予目标存储账户的访问权限(如 `Storage Blob Data Contributor`)。 + + - **系统分配的托管标识 (System-assigned)**: + + 使用系统分配的托管标识时,无需配置任何 Azure 相关环境变量,直接运行 br 备份命令即可。 + + ```shell + tiup br backup full -u "${PD_IP}:2379" \ + --storage "azure://external/backup-20220915?account-name=${account-name}" + ``` + + > **注意:** + > + > 请确保运行环境中**不存在** `AZURE_CLIENT_ID`、`AZURE_TENANT_ID` 或 `AZURE_CLIENT_SECRET` 环境变量,否则 Azure SDK 可能会优先使用其他认证方式,导致托管标识未生效。 + + - **用户分配的托管标识 (User-assigned)**: + + 使用用户分配的托管标识时,需要在 TiKV 运行环境和 br 命令行工具运行环境中配置环境变量 `AZURE_CLIENT_ID` (其值为该托管标识的 Client ID),然后再执行 br 备份命令。具体步骤如下: + + 1. 使用 TiUP 启动时为 TiKV 配置 Client ID: + + 以下步骤以 TiKV 端口 `24000`、systemd 服务名 `tikv-24000` 为例: + + 1. 执行以下命令进入服务配置编辑界面: + + ```shell + systemctl edit tikv-24000 + ``` + + 2. 配置 `AZURE_CLIENT_ID` 环境变量: + + ```ini + [Service] + Environment="AZURE_CLIENT_ID=" + ``` + + 3. 重新加载 systemd 配置并重启 TiKV: + + ```shell + systemctl daemon-reload + systemctl restart tikv-24000 + ``` + + 2. 为 br 命令行工具配置 `AZURE_CLIENT_ID` 环境变量: + + ```shell + export AZURE_CLIENT_ID="" + ``` + + 3. 使用 br 命令行工具将数据备份至 Azure Blob Storage: + + ```shell + tiup br backup full -u "${PD_IP}:2379" \ + --storage "azure://external/backup-20220915?account-name=${account-name}" + ``` +