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

az postgres flexible-server replica

管理读取副本 (replica)。

命令

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

创建服务器的只读副本。

核心 GA
az postgres flexible-server replica list

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

核心 GA
az postgres flexible-server replica promote

停止读取副本 (replica)副本 (replica)并将其提升为独立服务器或主服务器。

核心 GA
az postgres flexible-server replica stop-replication

停止复制到只读副本,并使该副本成为读/写服务器。

核心 已放弃

az postgres flexible-server replica create

创建服务器的只读副本。

az postgres flexible-server replica create --replica-name
                                           --resource-group
                                           --source-server
                                           [--address-prefixes]
                                           [--identity]
                                           [--key]
                                           [--location]
                                           [--no-wait]
                                           [--performance-tier]
                                           [--private-dns-zone]
                                           [--sku-name]
                                           [--storage-size]
                                           [--subnet]
                                           [--subnet-prefixes]
                                           [--tier]
                                           [--vnet]
                                           [--yes]
                                           [--zone]

示例

在指定区域和位置创建具有公共或专用访问权限的“testerver”的读取副本 (replica)“testReplicaServer”。

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

使用具有专用访问的“testerver”的新子网创建读取副本 (replica)“testReplicaServer”。

az postgres flexible-server replica create --replica-name testReplicaServer -g testGroup \
  --source-server testserver --zone 3 --location testLocation \
  --vnet newVnet --subnet newSubnet \
  --address-prefixes 172.0.0.0/16 --subnet-prefixes 172.0.0.0/24 \
  --private-dns-zone testDNS.postgres.database.azure.com

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

az postgres flexible-server replica create --replica-name testReplicaServer -g testGroup --source-server testserver --location testLocation

使用自定义 --storage-size 和 --sku 为“testserver”创建读取副本 (replica)“testReplicaServer”。

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

必需参数

--replica-name

要还原到的服务器的名称。

--resource-group -g

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

--source-server

要从中还原的源服务器的名称或资源 ID。

可选参数

--address-prefixes

以 CIDR 格式创建新虚拟网络时要使用的 IP 地址前缀。 默认值为 10.0.0.0/16。

--identity

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

--key

用于数据加密的主密钥库密钥的资源 ID。

--location -l

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

--no-wait

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

默认值: False
--performance-tier

服务器的性能层。

--private-dns-zone

此参数仅适用于具有专用访问权限的服务器。 新的或现有的专用 DNS 区域的名称或 ID。 可以使用同一资源组、不同资源组或不同订阅中的专用 DNS 区域。 如果要使用不同资源组或订阅中的区域,请提供资源 ID。如果用户未提供专用 DNS 区域,CLI 会在虚拟网络所在的资源组中创建一个新的。

--sku-name

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

--storage-size

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

--subnet

新的或现有的子网的名称或资源 ID。 如果要使用不同资源组或订阅中的子网,请提供资源 ID 而不是名称。 请注意,子网将委托给 flexibleServer。 进行委托后,此子网不能用于任何其他类型的 Azure 资源。

--subnet-prefixes

以 CIDR 格式创建新子网时要使用的子网 IP 地址前缀。 默认值为 10.0.0.0/24。

--tier

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

--vnet

新的或现有的虚拟网络的名称或 ID。 如果要使用不同资源组或订阅中的 vnet,请提供资源 ID。 名称必须包含 2 到 64 个字符。 名称必须以字母或数字开头,以字母、数字或下划线结尾,并且只能包含字母、数字、下划线、句点或连字符。

--yes -y

不提示确认。

默认值: False
--zone -z

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

全局参数
--debug

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

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

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

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

--subscription

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

--verbose

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

az postgres flexible-server replica list

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

az postgres flexible-server replica list --name
                                         --resource-group

示例

列出主服务器“testerver”的所有读取副本 (replica)。

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

必需参数

--name -n

源服务器的名称。

--resource-group -g

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

全局参数
--debug

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

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

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

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

--subscription

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

--verbose

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

az postgres flexible-server replica promote

停止读取副本 (replica)副本 (replica)并将其提升为独立服务器或主服务器。

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

示例

停止副本 (replica)“testReplicaServer”并将其提升为独立的读/写服务器。

az postgres flexible-server replica promote -g testGroup -n testReplicaServer

停止副本 (replica)“testReplicaServer”并将其提升为具有强制数据同步的独立读/写服务器。

az postgres flexible-server replica promote -g testGroup -n testReplicaServer --promote-mode standalone --promote-option forced

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

az postgres flexible-server replica promote -g testGroup -n testReplicaServer --promote-mode switchover --promote-option planned

可选参数

--ids

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

--name -n

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

--promote-mode

是将读取副本 (replica)提升到独立服务器还是将读取提升为主服务器。

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

无论是在提升读取副本 (replica)之前同步数据,还是尽快提升数据。

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

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

--subscription

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

--yes -y

不提示确认。

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

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

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

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

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

--subscription

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

--verbose

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

az postgres flexible-server replica stop-replication

已放弃

此命令已弃用,将在将来的版本中删除。 请改用“postgres 灵活服务器副本 (replica)升级”。

停止复制到只读副本,并使该副本成为读/写服务器。

az postgres flexible-server replica stop-replication [--ids]
                                                     [--name]
                                                     [--resource-group]
                                                     [--subscription]
                                                     [--yes]

示例

停止对“testReplicaServer”的副本 (replica),使其成为读/写服务器。

az postgres flexible-server replica stop-replication -g testGroup -n testReplicaServer

可选参数

--ids

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

--name -n

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

--resource-group -g

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

--subscription

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

--yes -y

不提示确认。

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

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

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

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

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

--subscription

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

--verbose

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