你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az postgres flexible-server replica

管理只读副本。

命令

名称 说明 类型 Status
az postgres flexible-server replica create

创建服务器的只读副本。

Core GA
az postgres flexible-server replica list

列出某个给定服务器的所有只读副本。

Core GA
az postgres flexible-server replica promote

停止复制只读副本,并将其提升为独立服务器或主服务器。

Core GA

az postgres flexible-server replica create

创建服务器的只读副本。

az postgres flexible-server replica create --name
                                           --resource-group
                                           --source-server
                                           [--acquire-policy-token]
                                           [--change-reference]
                                           [--identity]
                                           [--key]
                                           [--location]
                                           [--no-wait]
                                           [--performance-tier]
                                           [--private-dns-zone]
                                           [--sku-name]
                                           [--storage-size]
                                           [--storage-type {PremiumV2_LRS}]
                                           [--subnet]
                                           [--tags]
                                           [--tier]
                                           [--vnet]
                                           [--yes]
                                           [--zone]

示例

在指定区域和位置创建具有公共或专用访问权限的“testerver”的只读副本“testreplica”(如果可用)。

az postgres flexible-server replica create --name testreplica -g testGroup --source-server testserver --zone 3 --location testLocation

使用现有网络资源为具有专用访问权限的“testerver”创建只读副本“testreplica”。

az postgres flexible-server replica create --name testreplica -g testGroup \
  --source-server testserver --zone 3 --location testLocation \
  --vnet newVnet --subnet newSubnet \
  --private-dns-zone testdns.postgres.database.azure.com \
  --tags "key=value"

在指定位置(如果可用)为具有公共或专用访问权限的“testerver”创建只读副本“testreplica”。 由于区域未传递,因此它将自动选取与源服务器不同的副本位置中的区域(如果可用),否则将选取与副本位置中的源服务器相同的区域(如果可用),否则会将区域设置为“无”,即无首选项

az postgres flexible-server replica create --name testreplica -g testgroup --source-server testserver --location testLocation

使用自定义 --storage-size 和 --sku 为“testserver”创建只读副本“testreplica”。

az postgres flexible-server replica create --name testreplica -g testgroup --source-server testserver --sku-name Standard_D4ds_v5 --storage-size 256

为“testserver”创建只读副本“testreplica”,其中“testreplica”位于其他资源组“newTestGroup”。 此处 --resource-group 适用于只读副本的资源组,并且 --source-server 必须作为资源标识符传递。

az postgres flexible-server replica create --name testreplicaserver -g newTestGroup         --source-server /subscriptions/{sourceSubscriptionId}/resourceGroups/{sourceResourceGroup}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{sourceServer} --location testLocation

必需参数

--name -n

只读副本的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

--source-server

要从中还原的源服务器的名称或资源标识符。

可选参数

以下参数是可选的,但根据上下文,命令可能需要一个或多个参数才能成功执行。

--acquire-policy-token

为此资源操作自动获取Azure Policy令牌。

属性
参数组: Global Policy Arguments
--change-reference

此资源操作的相关更改引用 ID。

属性
参数组: Global Policy Arguments
--identity

用于数据加密的用户分配标识的名称或资源标识符。

--key

用于数据加密的主 keyvault 密钥的资源标识符。

--location -l

Location. az account list-locations 中的值。 可以使用 az configure --defaults location=<location> 配置默认位置。

--no-wait

不等待长时间运行的操作完成。

属性
默认值: False
--performance-tier

服务器的性能层。

--private-dns-zone

此参数仅适用于具有专用访问的服务器,在使用 --vnet 或 --subnet 时是必需的。 现有专用 DNS 区域的名称或资源标识符。 可以使用同一资源组、不同资源组或其他订阅中的专用 DNS 区域。 如果要使用其他资源组或订阅中的区域,请提供其资源标识符。

--sku-name

计算 SKU 的名称。 遵循Standard_{VM 名称}的约定。 示例:Standard_B1ms。

--storage-size

服务器的存储容量。 最小值为 32 GiB,最大值为 16 TiB。

--storage-type

只读副本的存储类型。 允许的值PremiumV2_LRS。 默认值为只读副本以匹配主服务器的存储类型。

属性
接受的值: PremiumV2_LRS
--subnet

现有子网的名称或标识符。 如果要使用不同的资源组或订阅中的子网,请提供其资源标识符而不是名称。

--tags

空格分隔标记:key[=value] [key[=value] ...]。使用“”清除现有标记。

--tier

服务器的计算层。 接受的值:可突发、GeneralPurpose、MemoryOptimized。

--vnet

现有虚拟网络的名称或标识符。 如果要从其他资源组或订阅使用 vnet,请提供资源标识符。 名称必须介于 2 到 64 个字符之间。 名称必须以字母或数字开头,以字母、数字或下划线结尾,并且只能包含字母、数字、下划线、句点或连字符。

--yes -y

不要提示确认。

属性
默认值: False
--zone -z

要在其中预配资源的可用性区域。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

增加日志记录详细程度。 使用 --debug 获取完整的调试日志。

属性
默认值: False

az postgres flexible-server replica list

列出某个给定服务器的所有只读副本。

az postgres flexible-server replica list [--ids]
                                         [--name]
                                         [--resource-group]
                                         [--subscription]

示例

列出主服务器“testserver”的所有只读副本。

az postgres flexible-server replica list -g testgroup -n testserver

可选参数

以下参数是可选的,但根据上下文,命令可能需要一个或多个参数才能成功执行。

--ids

一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。

属性
参数组: Resource Id Arguments
--name -n

服务器的名称。 名称只能包含小写字母、数字和连字符 (-)。 最少 3 个字符,最多 63 个字符。

属性
参数组: Resource Id Arguments
--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

属性
参数组: Resource Id Arguments
--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

属性
参数组: Resource Id Arguments
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--verbose

增加日志记录详细程度。 使用 --debug 获取完整的调试日志。

属性
默认值: False

az postgres flexible-server replica promote

停止复制只读副本,并将其提升为独立服务器或主服务器。

az postgres flexible-server replica promote [--acquire-policy-token]
                                            [--change-reference]
                                            [--ids]
                                            [--name]
                                            [--promote-mode {standalone, switchover}]
                                            [--promote-option {forced, planned}]
                                            [--resource-group]
                                            [--subscription]
                                            [--yes]

示例

停止复制到“testreplica”,并将其提升为独立的读/写服务器。

az postgres flexible-server replica promote -g testgroup -n testreplica

停止复制到“testreplica”,并将其提升为具有强制数据同步的独立读/写服务器。

az postgres flexible-server replica promote -g testgroup -n testreplica --promote-mode standalone --promote-option forced

停止复制到“testreplica”,并将其提升到计划内数据同步的主服务器。正在升级的副本必须分配有读取器虚拟终结点,否则升级时会收到错误。

az postgres flexible-server replica promote -g testgroup -n testreplica --promote-mode switchover --promote-option planned

可选参数

以下参数是可选的,但根据上下文,命令可能需要一个或多个参数才能成功执行。

--acquire-policy-token

为此资源操作自动获取Azure Policy令牌。

属性
参数组: Global Policy Arguments
--change-reference

此资源操作的相关更改引用 ID。

属性
参数组: Global Policy Arguments
--ids

一个或多个资源 ID(以空格分隔)。 它应该是包含“Resource Id”参数的所有信息的完整资源 ID。 应提供 --ids 或其他“Resource Id”参数。

属性
参数组: Resource Id Arguments
--name -n

只读副本的名称。

属性
参数组: Resource Id Arguments
--promote-mode

是将只读副本提升到独立服务器还是将其提升为主服务器。

属性
默认值: standalone
接受的值: standalone, switchover
--promote-option

是在提升只读副本之前同步数据还是尽快升级数据。

属性
默认值: planned
接受的值: forced, planned
--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。

属性
参数组: Resource Id Arguments
--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

属性
参数组: Resource Id Arguments
--yes -y

不要提示确认。

属性
默认值: False
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

属性
默认值: False
--help -h

显示此帮助消息并退出。

--only-show-errors

仅显示错误,禁止显示警告。

属性
默认值: False
--output -o

输出格式。

属性
默认值: json
接受的值: json, jsonc, none, table, tsv, yaml, yamlc
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--verbose

增加日志记录详细程度。 使用 --debug 获取完整的调试日志。

属性
默认值: False