Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Azure快照复制到其他区域_Azure_Azure Disk - Fatal编程技术网

将Azure快照复制到其他区域

将Azure快照复制到其他区域,azure,azure-disk,Azure,Azure Disk,我正在尝试使用Azure中的快照创建灾难恢复解决方案。我在一个集群中有很多很多磁盘,目前我可以拍摄这些磁盘的快照,以便能够在本地进行恢复。这很有效 现在,我想将现有快照复制到另一个区域,或者创建磁盘的新快照,但这些快照存储在另一个区域 参考: 我试过这个。在本例中,$disk_位置位于eastus,而$target_位置位于eastus2 az snapshot create --name $snapshot_name \ --resource-group $resource_group \ -

我正在尝试使用Azure中的快照创建灾难恢复解决方案。我在一个集群中有很多很多磁盘,目前我可以拍摄这些磁盘的快照,以便能够在本地进行恢复。这很有效

现在,我想将现有快照复制到另一个区域,或者创建磁盘的新快照,但这些快照存储在另一个区域

参考:

我试过这个。在本例中,$disk_位置位于eastus,而$target_位置位于eastus2

az snapshot create --name $snapshot_name \
--resource-group $resource_group \
--location $target_location \
--source "$disk_location" \
--no-wait
此操作失败,因为“未找到资源mdw_data1”。它存在,但不在$target_位置

我还尝试创建一个快照,将源作为另一个快照。我遇到了两个问题。首先,它说明快照已经存在,因为我使用的是相同的快照名称,当我更改为不同的名称时,它给了我相同的“未找到”错误

快照可以是本地冗余的(单个物理位置中有3个拷贝),也可以是区域冗余的(一个区域内3个可用性区域中有3个拷贝)。在区域离线的情况下,两者都没有帮助

参考:


此外,微软表示:“对于需要高可用性的应用程序,微软建议在主区域使用ZRS,并将其复制到辅助区域。”但是,我不能像他们建议的那样将快照复制到辅助区域。

AWS提供了一个命令来将快照从一个区域复制到另一个区域,但Azure没有直接从其CLI提供此功能

参考:

例如:

aws ec2 copy-snapshot \
--region us-east-1 \
--source-region us-west-2 \
--source-snapshot-id snap-066877671789bd71b \
--description "This is my copied snapshot."
Azure解决方案:

步骤1-在目标位置创建存储帐户

az storage account create --name $account_name \
--resource-group $resource_group \
--location $target_location
az storage container create --name $container_name 
--resource-group $resource_group \
--account-key $account_key \
--account-name $account_name
步骤2-从步骤1存储帐户获取存储密钥

注意:请注意Azure如何将“存储帐户”更改为“帐户帐户”

步骤3-在位于目标位置的新创建的存储帐户中创建容器

az storage account create --name $account_name \
--resource-group $resource_group \
--location $target_location
az storage container create --name $container_name 
--resource-group $resource_group \
--account-key $account_key \
--account-name $account_name
步骤4-授予对自己快照的访问权限

这对我来说是个奇怪的问题。您必须允许自己访问自己的快照。你还必须设定给自己的补助金有效期

duration="7200"

az snapshot grant-access --resource-group $resource_group \
--name $snapshot_id \
--duration-in-seconds $duration \
--query [accessSas] \
--output tsv
步骤5-使用SAS将快照复制到存储帐户中的容器

“destination_blob”是快照的名称,其末尾附加了“.vhd”

destination_blob="$snapshot_id"".vhd"

az storage blob copy start --destination-blob "$destination_blob" \
--destination-container "$container_name" \
--account-key "$account_key" \
--account-name "$account_name" \
--source-uri "$sas"
第6步-等待

继续运行,直到输出显示“成功”

步骤7-获取您的订阅id

az account show --query 'id' --output tsv
步骤8-创建快照 Azure不允许您使用相同名称但位于不同区域的快照。因此,很遗憾,您必须更新名称

target_snapshot_id="$snapshot_id""_copy"

az snapshot create --name $target_snapshot_id \
--resource-group $resource_group \
--location $target_location \
--source "https://${account_name}.blob.core.windows.net/${container_name}/${destination_blob}" \
--source-storage-account-id "/subscriptions/${subscription_id}/resourceGroups/${resource_group}/providers/Microsoft.Storage/storageAccounts/${account_name}"
步骤9-清理

az storage account delete --resource-group $resource_group \
--name $account_name \
--yes