调用 ModifyDBEndpointReadWriteFlag 接口开启或关闭读写分离。
同步请求。
参数 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
InstanceId | String | 是 | postgres-0af11cd4**** | 实例 ID。 |
EndpointId | String | 是 | postgres-0af11cd4****-cluster | 实例连接终端 ID。 |
ReadWriteSpliting | Boolean | 是 | true | 是否开启读写分离。取值:
|
ReadOnlyNodeMaxDelayTime | Integer | 否 | 30 | 只读节点的最大延迟阈值,当只读节点延迟时间超过该值时,读取流量不发往该节点。单位为秒,取值范围为 0~3600,默认值为 30。 说明 读写类型的终端,且开启读写分离后支持设置此参数。 |
ReadOnlyNodeDistributionType | String | 否 | Default | 读权重分配模式。开启读写分离时,即
|
ReadOnlyNodeWeight | Object[] | 否 | [
{"NodeType" : "Primary",
"Weight" : 100
},
{
"NodeId" : "postgres-c23003b1****-rof359",
"Weight" : 100
}
] | 自定义读权重分配,即传入主节点和只读节点的读请求权重。以 100 递增,最大值为 40000。 说明
|
null
POST /?Action=ModifyDBEndpointReadWriteFlag&Version=2022-01-01 HTTP/1.1 Content-Type: application/json Host: rds.volcengineapi.com X-Date: 20231002T101010Z Authorization: HMAC-SHA256 Credential=AKLTN2I0MmFiNzMxNWE5NDgzMzk4MmVjMTVkODlkZTZ****/20211202/cn-beijing/rds_postgresql/request,SignedHeaders=x-date, Signature=71d31fc7bcf990142851c9833c5656391486cda0ae2e0b8ada733b7c6458**** { "InstanceId": "postgres-c23003b1****", "EndpointId": "postgres-c23003b1****-cluster", "ReadWriteSpliting": true, "ReadOnlyNodeMaxDelayTime": 31, "ReadOnlyNodeDistributionType": "Custom", "ReadOnlyNodeWeight": [ { "NodeType": "Primary", "Weight": 300 }, { "NodeId": "postgres-c23003b1****-rof359", "NodeType": "ReadOnly", "Weight": 600 } ] }
{ "ResponseMetadata": { "RequestId": "2023101118285676A8F34389CC270EE9CA", "Action": "ModifyDBEndpointReadWriteFlag", "Version": "2022-01-01", "Service": "rds_postgresql", "Region": "cn-beijing" }, "Result": null }