調(diào)用CreateDBClusterEndpoint接口創(chuàng)建PolarDB自定義集群地址。

調(diào)試

您可以在OpenAPI Explorer中直接運(yùn)行該接口,免去您計算簽名的困擾。運(yùn)行成功后,OpenAPI Explorer可以自動生成SDK代碼示例。

請求參數(shù)

名稱 類型 是否必選 示例值 描述
Action String CreateDBClusterEndpoint

系統(tǒng)規(guī)定參數(shù)。取值:CreateDBClusterEndpoint

DBClusterId String pc-**************

集群ID。

EndpointType String Custom

自定義集群地址類型,取值固定為Custom

Nodes String pi-**********,pi-*********

加入目標(biāo)地址的讀負(fù)載節(jié)點(diǎn),多個節(jié)點(diǎn)間用英文逗號(,)分隔。 默認(rèn)為全部節(jié)點(diǎn)。

說明
  • PolarDB MySQL版需要傳入節(jié)點(diǎn)ID。
  • PolarDB PostgreSQL版和PolarDB PostgreSQL版(兼容Oracle)需要傳入節(jié)點(diǎn)角色名稱,例如Writer,Reader1,Reader2
  • ReadWriteMode取值為ReadOnly時,支持只掛載一個節(jié)點(diǎn)。但當(dāng)此節(jié)點(diǎn)故障時,該地址可能會有最多1小時的不可用,請勿用于生產(chǎn)環(huán)境。因此,推薦至少選擇2個節(jié)點(diǎn),以提升可用性。
  • ReadWriteMode取值為ReadWrite時,至少要選擇2個節(jié)點(diǎn)。
    • PolarDB MySQL版支持選擇任意兩個節(jié)點(diǎn)。當(dāng)兩個節(jié)點(diǎn)都是只讀節(jié)點(diǎn)時,寫請求都會發(fā)往主節(jié)點(diǎn)。
    • PolarDB PostgreSQL版和PolarDB PostgreSQL版(兼容Oracle)必須包含主節(jié)點(diǎn)。
ReadWriteMode String ReadOnly

讀寫模式,取值范圍如下:

  • ReadWrite:可讀可寫(自動讀寫分離)。
  • ReadOnly:只讀。

    默認(rèn)為ReadOnly

AutoAddNewNodes String Disable

新節(jié)點(diǎn)是否自動加入本地址,取值范圍如下:

  • Enable:新節(jié)點(diǎn)自動加入本地址。
  • Disable:新節(jié)點(diǎn)不自動加入本地址。

默認(rèn)取值為Disable

EndpointConfig String {"ConsistLevel": "1","DistributedTransaction": "on"}

集群地址的高級配置,格式為JSON,目前支持設(shè)置一致性級別、事務(wù)拆分、主庫不接受讀和連接池。

  • 設(shè)置一致性級別,格式為{"ConsistLevel":"一致性級別"},取值范圍如下:
    • 0:最終一致性
    • 1:會話一致性(默認(rèn)值)
    • 2:全局一致性
  • 設(shè)置事務(wù)拆分,格式為{"DistributedTransaction":"事務(wù)拆分"},取值范圍如下:
    • on:開啟事務(wù)拆分(默認(rèn)值)
    • off:關(guān)閉事務(wù)拆分
  • 設(shè)置主庫不接受讀,格式為{"MasterAcceptReads":"主庫不接受讀"},取值范圍如下:
    • on:表示主庫接受讀
    • off:表示主庫不接受讀(默認(rèn)值)
  • 設(shè)置連接池,格式為{"ConnectionPersist":"連接池"},取值范圍如下:
    • off:關(guān)閉連接池(默認(rèn)值)
    • Session:開啟會話級連接池
    • Transaction:開啟事務(wù)級連接池
說明
  • 僅當(dāng)PolarDB MySQL版集群地址的讀寫模式為可讀可寫(自動讀寫分離)時,支持設(shè)置事務(wù)拆分、主庫不接受讀和連接池。
  • 僅PolarDB MySQL版支持將一致性級別設(shè)置為全局一致性。
  • 如果參數(shù)ReadWriteMode取值為ReadOnly,一致性級別取值只能為0
  • 您可以同時設(shè)置一致性級別、事務(wù)拆分、主庫不接受讀和連接池,例如{"ConsistLevel":"1","DistributedTransaction":"on","ConnectionPersist":"Session","MasterAcceptReads":"on"}
  • 事務(wù)拆分的設(shè)置受一致性級別設(shè)置的約束。例如一致性級別取值為0時,不支持開啟事務(wù)拆分;一致性級別取值為12時,支持開啟事務(wù)拆分。
ClientToken String 6000170000591aed949d0f******************

用于保證請求的冪等性,防止重復(fù)提交請求。由客戶端生成該參數(shù)值,保證在不同請求間唯一,大小寫敏感、不超過64個ASCII字符。

DBEndpointDescription String test

自定義集群地址名稱。

返回數(shù)據(jù)

名稱 類型 示例值 描述
RequestId String CD35F3-F3-44CA-AFFF-BAF869******

請求ID。

示例

請求示例

http(s)://polardb.aliyuncs.com/?Action=CreateDBClusterEndpoint
&DBClusterId=pc-**************
&EndpointType=Custom
&<公共請求參數(shù)>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateDBClusterEndpointResponse>
<RequestId>CD35F3-F3-44CA-AFFF-BAF869******</RequestId>
</CreateDBClusterEndpointResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "CD35F3-F3-44CA-AFFF-BAF869******"
}

錯誤碼

HttpCode 錯誤碼 錯誤信息 描述
400 ClusterEndpoint.StatusNotValid Cluster endpoint status is not valid. 集群地址的狀態(tài)無效.
400 EndpointNum.Error Endpoint number error. Endpoint號錯誤。
400 LockTimeout The request processing has failed due to lock timeout. 由于鎖定超時,請求處理失敗
404 EndpointConfig.Invalid Endpoint config is invalid. 集群地址的高級配置參數(shù)無效
404 InvalidDBClusterId.NotFound The DBClusterId provided does not exist in our records. 當(dāng)前的記錄中不存在提供的 DBClusterId。
404 EndpointConfig.Conflict Endpoint config is invalid, CausalConsistRead should be session since node SCC mode enabled. Endpoint配置無效,CausalConsistRead應(yīng)為會話,因?yàn)楣?jié)點(diǎn)SCC模式已啟用。

訪問錯誤中心查看更多錯誤碼。