資源編排ROS集成示例
使用資源編排服務(wù)ROS調(diào)用云備份。本文為您介紹如何編寫一個資源編排的模板,自動化創(chuàng)建一個云備份的備份庫。
支持資源列表
資源編排服務(wù)ROS(Resource Orchestration Service)是阿里云提供的一項簡化云計算資源管理的服務(wù)。開發(fā)者和管理員可以編寫模板,在模板中定義所需的阿里云資源(例如:ECS 實例、RDS 數(shù)據(jù)庫實例)、資源間的依賴關(guān)系等。ROS的編排引擎將根據(jù)模板自動完成所有資源的創(chuàng)建和配置,實現(xiàn)自動化部署及運維。更多詳情請參見什么是資源編排服務(wù)。
支持使用資源編排服務(wù)ROS調(diào)用云備份。編排的資源包括普通資源和數(shù)據(jù)資源。
普通資源:
ALIYUN::HBR::BackupClients:為ECS實例安裝備份客戶端
ALIYUN::HBR::RestoreJob:創(chuàng)建恢復任務(wù)
ALIYUN::HBR::DbAgent安裝數(shù)據(jù)庫備份客戶端
ALIYUN::HBR::DbPlan:創(chuàng)建備份計劃
ALIYUN::HBR::DbVault:創(chuàng)建鏡像備份倉庫
ALIYUN::HBR::Vault:創(chuàng)建一個備份倉庫
數(shù)據(jù)資源:
DATASOURCE::HBR::Vaults:查詢備份倉庫基礎(chǔ)信息
權(quán)限說明
在本案例中,需要創(chuàng)建的資源:備份庫。默認情況下資源編排直接使用當前登錄控制臺的用戶憑證,要求當前用戶必須具備以下權(quán)限:
AliyunHBRFullAccess: 管理云備份資源的權(quán)限。
阿里云賬號擁有所有API的訪問權(quán)限,風險很高。強烈建議您創(chuàng)建并使用RAM用戶進行API訪問或日常運維。請根據(jù)業(yè)務(wù)的實際情況按需分配權(quán)限后進行接口調(diào)用。RAM用戶需具備操作云備份資源的權(quán)限。具體操作,請參見創(chuàng)建RAM用戶進行云備份操作。
操作步驟
登錄資源編排ROS控制臺,單擊頂部導航欄地域下拉框,選擇您需要的地域。
單擊左側(cè)菜單欄中的資源棧,選擇創(chuàng)建資源棧 > 使用ROS。
指定模板:選中選擇已有模板。
模板錄入方式:選中輸入模板。
模板內(nèi)容選擇ROS,并輸入代碼。
創(chuàng)建備份庫的語法、說明及示例,請參見ALIYUN::HBR::Vault。該示例中,創(chuàng)建一個名為
test-vault
的備份庫。YAML
格式ROSTemplateFormatVersion: '2015-09-01' Parameters: VaultName: Description: The name of the backup vault. The name must be 1 to 64 characters in length. MaxLength: 64 MinLength: 1 Type: String Default: test-valut Resources: ExtensionResource: Properties: VaultName: Ref: VaultName VaultType: STANDARD Type: ALIYUN::HBR::Vault Outputs: BackupPlanStatistics: Description: The statistics of backup plans that use the backup vault. Value: Fn::GetAtt: - ExtensionResource - BackupPlanStatistics BytesDone: Description: 'The amount of data that is backed up. Unit: bytes.' Value: Fn::GetAtt: - ExtensionResource - BytesDone CreateTime: Description: 'The time when the backup vault was created. This value is a UNIX timestamp. Unit: seconds.' Value: Fn::GetAtt: - ExtensionResource - CreateTime Dedup: Description: Indicates whether the deduplication feature is enabled. Value: Fn::GetAtt: - ExtensionResource - Dedup Description: Description: The description of the backup vault. Value: Fn::GetAtt: - ExtensionResource - Description IndexAvailable: Description: Indicates whether indexes are available. Indexes are available when they are not being updated. Value: Fn::GetAtt: - ExtensionResource - IndexAvailable IndexLevel: Description: 'The index level. - **OFF**: No indexes are created. - **META**: Metadata indexes are created. - **ALL**: Full-text indexes are created.' Value: Fn::GetAtt: - ExtensionResource - IndexLevel IndexUpdateTime: Description: The time when the index was updated. Value: Fn::GetAtt: - ExtensionResource - IndexUpdateTime LatestReplicationTime: Description: 'The time when the last remote backup was synchronized. This value is a UNIX timestamp. Unit: seconds.' Value: Fn::GetAtt: - ExtensionResource - LatestReplicationTime PaymentType: Description: PaymentType. Value: Fn::GetAtt: - ExtensionResource - PaymentType RedundancyType: Description: 'The data redundancy type of the backup vault. Valid values: - **LRS**: Locally redundant storage (LRS) is enabled for the backup vault. HBR stores the copies of each object on multiple devices of different facilities in the same zone. This way, HBR ensures data durability and availability even if hardware failures occur. - **ZRS**: Zone-redundant storage (ZRS) is enabled for the backup vault. HBR uses the multi-zone mechanism to distribute data across three zones within the same region. If a zone fails, the data that is stored in the other two zones is still accessible.' Value: Fn::GetAtt: - ExtensionResource - RedundancyType Replication: Description: 'Indicates whether the backup vault is a remote backup vault. Valid values: - **true**: The backup vault is a remote backup vault. - **false**: The backup vault is an on-premises backup vault.' Value: Fn::GetAtt: - ExtensionResource - Replication ReplicationProgress: Description: The progress of data synchronization from the backup vault to the mirror vault. Value: Fn::GetAtt: - ExtensionResource - ReplicationProgress ReplicationSourceRegionId: Description: The ID of the region where the remote backup vault resides. Value: Fn::GetAtt: - ExtensionResource - ReplicationSourceRegionId ReplicationSourceVaultId: Description: The ID of the source vault that corresponds to the remote backup vault. Value: Fn::GetAtt: - ExtensionResource - ReplicationSourceVaultId ResourceGroupId: Description: The ID of the resource group. Value: Fn::GetAtt: - ExtensionResource - ResourceGroupId Retention: Description: 'The retention period of the backup vault. Unit: days.' Value: Fn::GetAtt: - ExtensionResource - Retention SearchEnabled: Description: Indicates whether the backup search feature is enabled. Value: Fn::GetAtt: - ExtensionResource - SearchEnabled SourceTypes: Description: The information about the data source. Value: Fn::GetAtt: - ExtensionResource - SourceTypes StorageSize: Description: 'The usage of the backup vault. Unit: bytes.' Value: Fn::GetAtt: - ExtensionResource - StorageSize Tags: Description: The tags of the backup vault. Value: Fn::GetAtt: - ExtensionResource - Tags TrialInfo: Description: The free trial information. Value: Fn::GetAtt: - ExtensionResource - TrialInfo UpdatedTime: Description: 'The time when the backup vault was updated. This value is a UNIX timestamp. Unit: seconds.' Value: Fn::GetAtt: - ExtensionResource - UpdatedTime VaultId: Description: The ID of the backup vault. Value: Fn::GetAtt: - ExtensionResource - VaultId VaultName: Description: The name of the backup vault. Value: Fn::GetAtt: - ExtensionResource - VaultName VaultStatusMessage: Description: 'The status message that is returned when the backup vault is in the ERROR state. This parameter is available only for remote backup vaults. Valid values: - **UNKNOWN_ERROR*: An unknown error occurs. - **SOURCE_VAULT_ALREADY_HAS_REPLICATION**: A mirror vault is configured for the source vault.' Value: Fn::GetAtt: - ExtensionResource - VaultStatusMessage VaultStorageClass: Description: 'The storage type of the backup vault. Valid value: **STANDARD**, which indicates standard storage.' Value: Fn::GetAtt: - ExtensionResource - VaultStorageClass VaultType: Description: 'The type of the backup vault. Valid value: **STANDARD**, which indicates a standard backup vault.' Value: Fn::GetAtt: - ExtensionResource - VaultType
JSON
格式{ "ROSTemplateFormatVersion": "2015-09-01", "Parameters": { "VaultName": { "Description": "The name of the backup vault. The name must be 1 to 64 characters in length.", "MaxLength": 64, "MinLength": 1, "Type": "String", "Default": "test-valut" } }, "Resources": { "ExtensionResource": { "Properties": { "VaultName": { "Ref": "VaultName" }, "VaultType": "STANDARD" }, "Type": "ALIYUN::HBR::Vault" } }, "Outputs": { "BackupPlanStatistics": { "Description": "The statistics of backup plans that use the backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "BackupPlanStatistics" ] } }, "BytesDone": { "Description": "The amount of data that is backed up. Unit: bytes.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "BytesDone" ] } }, "CreateTime": { "Description": "The time when the backup vault was created. This value is a UNIX timestamp. Unit: seconds.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "CreateTime" ] } }, "Dedup": { "Description": "Indicates whether the deduplication feature is enabled.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "Dedup" ] } }, "Description": { "Description": "The description of the backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "Description" ] } }, "IndexAvailable": { "Description": "Indicates whether indexes are available. Indexes are available when they are not being updated.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "IndexAvailable" ] } }, "IndexLevel": { "Description": "The index level.\n- **OFF**: No indexes are created.\n- **META**: Metadata indexes are created.\n- **ALL**: Full-text indexes are created.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "IndexLevel" ] } }, "IndexUpdateTime": { "Description": "The time when the index was updated.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "IndexUpdateTime" ] } }, "LatestReplicationTime": { "Description": "The time when the last remote backup was synchronized. This value is a UNIX timestamp. Unit: seconds.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "LatestReplicationTime" ] } }, "PaymentType": { "Description": "PaymentType.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "PaymentType" ] } }, "RedundancyType": { "Description": "The data redundancy type of the backup vault. Valid values:\n- **LRS**: Locally redundant storage (LRS) is enabled for the backup vault. HBR stores the copies of each object on multiple devices of different facilities in the same zone. This way, HBR ensures data durability and availability even if hardware failures occur.\n- **ZRS**: Zone-redundant storage (ZRS) is enabled for the backup vault. HBR uses the multi-zone mechanism to distribute data across three zones within the same region. If a zone fails, the data that is stored in the other two zones is still accessible.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "RedundancyType" ] } }, "Replication": { "Description": "Indicates whether the backup vault is a remote backup vault. Valid values:\n- **true**: The backup vault is a remote backup vault.\n- **false**: The backup vault is an on-premises backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "Replication" ] } }, "ReplicationProgress": { "Description": "The progress of data synchronization from the backup vault to the mirror vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "ReplicationProgress" ] } }, "ReplicationSourceRegionId": { "Description": "The ID of the region where the remote backup vault resides.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "ReplicationSourceRegionId" ] } }, "ReplicationSourceVaultId": { "Description": "The ID of the source vault that corresponds to the remote backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "ReplicationSourceVaultId" ] } }, "ResourceGroupId": { "Description": "The ID of the resource group.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "ResourceGroupId" ] } }, "Retention": { "Description": "The retention period of the backup vault. Unit: days.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "Retention" ] } }, "SearchEnabled": { "Description": "Indicates whether the backup search feature is enabled.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "SearchEnabled" ] } }, "SourceTypes": { "Description": "The information about the data source.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "SourceTypes" ] } }, "StorageSize": { "Description": "The usage of the backup vault. Unit: bytes.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "StorageSize" ] } }, "Tags": { "Description": "The tags of the backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "Tags" ] } }, "TrialInfo": { "Description": "The free trial information.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "TrialInfo" ] } }, "UpdatedTime": { "Description": "The time when the backup vault was updated. This value is a UNIX timestamp. Unit: seconds.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "UpdatedTime" ] } }, "VaultId": { "Description": "The ID of the backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "VaultId" ] } }, "VaultName": { "Description": "The name of the backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "VaultName" ] } }, "VaultStatusMessage": { "Description": "The status message that is returned when the backup vault is in the ERROR state. This parameter is available only for remote backup vaults. Valid values:\n- **UNKNOWN_ERROR*: An unknown error occurs.\n- **SOURCE_VAULT_ALREADY_HAS_REPLICATION**: A mirror vault is configured for the source vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "VaultStatusMessage" ] } }, "VaultStorageClass": { "Description": "The storage type of the backup vault. Valid value: **STANDARD**, which indicates standard storage.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "VaultStorageClass" ] } }, "VaultType": { "Description": "The type of the backup vault. Valid value: **STANDARD**, which indicates a standard backup vault.", "Value": { "Fn::GetAtt": [ "ExtensionResource", "VaultType" ] } } } }
單擊創(chuàng)建,執(zhí)行資源棧。
輸出結(jié)果。
創(chuàng)建完成后,您可以通過OpenAPI、SDK或者在云備份控制臺,可以查看到名為
test-vault
的備份庫。