tencent cloud

Cloud Load Balancer

動向とお知らせ
製品アップデート情報
製品に関するお知らせ
製品の説明
製品概要
製品の優位性
ユースケース
技術原理
Product Comparison
使用上の制約
Service Regions and Service Providers
購入ガイド
課金概要
課金項目
購入方法
支払い延滞の説明
製品属性の選択
クイックスタート
ドメイン名型CLBクイックスタート
CLBクイックスタート
IPv6 CLBクイックスタート
CentOSにおけるNginxのデプロイ
CentOSにおけるJava Webのデプロイ
操作ガイド
CLBインスタンス
CLBリスナー
バックエンドサーバー
ヘルスチェック
証明書管理
ログ管理
監視アラート
Cloud Access Management
従来型CLB
プラクティスチュートリアル
証明書をCLBに配置(双方向認証)
CLBのGzip有効化設定およびチェック方法の説明
HTTPS転送設定スタートガイド
クライアントリアルIPの取得方法
ロードバランサーのモニタリングアラート設定のベストプラクティス
マルチアベイラビリティーゾーンの高可用性設定の説明
バランシングアルゴリズムの選択と重みの設定の例
CLBのリスニングドメイン名に対してWebセキュリティ保護を実行するようにWAFを設定する
メンテナンスガイド
クライアントのtimewaitが多すぎる場合の対処方法
CLBのHTTPSサービスパフォーマンステスト
ストレステストに関するよくあるご質問
CLB証明書の操作権限に関するご質問
障害処理
UDPヘルスチェックの異常
API リファレンス
History
Introduction
API Category
Instance APIs
Listener APIs
Backend Service APIs
Target Group APIs
Redirection APIs
Other APIs
Classic CLB APIs
Load Balancing APIs
Making API Requests
Data Types
Error Codes
CLB API 2017
よくあるご質問
課金関連
CLB設定関連
ヘルスチェック異常調査
HTTPS関連
WS/WSSプロトコルサポート関連
HTTP/2プロトコルサポート関連
連絡先
用語集

Use Cases

PDF
フォーカスモード
フォントサイズ
最終更新日: 2024-12-19 10:38:23
An example is given here to help you get started with CLB APIs. Before using the APIs, deploy TCP service on two CVMs and listen on port 80. If the service returns the “hello world” string, the deployment is successful. By creating a CLB instance, you can access CVM services through the CLB VIP.

Purchasing a Public Network CLB Instance

To use CLB services, you need to purchase a public network CLB instance (with static IP). For more information on CLB instance purchase, use the CreateLoadBalancer API.
This example shows you how to create a public network CLB instance (with static IP). The Action field in the common request parameters of this API is CreateLoadBalancer. The list below contains the API request parameters.
Parameter
Description
Value
loadBalancerType
CLB instance type.
2: public network CLB instance, the service of which is accessed via a public network.
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=CreateLoadBalancer
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerType=2
Response of the request is as follows:
{
"code": 0,
"message": "",
"codeDesc": "Success",
"requestId": 3901941,
"dealIds": [
"3901941"
],
"unLoadBalancerIds": {
"3901941": [
"lb-lb-cjcy****"
]
}
}
Where, lb-cjcymkw5 is the unique ID of the CLB instance you just purchased. Next, use the DescribeLoadBalancers API to query whether the instance has been successfully created.

Creating a CLB Listener

This example shows you how to create a CLB listener with the unique ID of the CLB instance. For more information on the CLB listener creation, use the CreateLoadBalancerListeners API.
In this example, the table below lists the API request parameters.
Parameter
Description
Value
loadBalancerId
Unique ID of the CLB instance
This example uses the unique ID of the instance you’ve just created, i.e. lb-cjcy****
listeners.0.loadBalancerPort
Listening port of the CLB listener.
80
listeners.0.instancePort
Listening port on real server of the CLB instance.
80
listeners.0.protocol
Protocol listened by the CLB listener. 1: HTTP; 2: TCP; 3: UDP; 4: HTTPS
This example uses 2: TCP
listeners.0.healthSwitch
Whether to enable the health check for the CLB listener. 1: enable; 0: disable. The health check is enabled by default.
This example uses 1: enable
listeners.0.listenerName
Name of the CLB listener. This field is optional. Default value will be used if it is left empty.
This example uses listenerTest
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=CreateLoadBalancerListeners
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerId=lb-cjcy****
&listeners.0.loadBalancerPort=80
&listeners.0.instancePort=80
&listeners.0.protocol=2
&listeners.0.healthSwitch=1
&listeners.0.listenerName=listenerTest

Response of the request is as follows:
{
"code" : 0,
"message" : "",
"codeDesc": "Success",
"requestId" : 12354
}
To query the execution result of the task with the request ID, use the asynchronous DescribeLoadBalancersTaskResult API.

Binding Real Server to the CLB Instance

You need to bind CVM to the CLB instance after creating the listener. For more information on the binding method, use the RegisterInstancesWithLoadBalancer API.
This example shows you how to bind two CVMs (with the unique ID of ins-5678test and ins-1234test respectively) on the CLB instance. The Action field in the common request parameters of this API is RegisterInstancesWithLoadBalancer. The list below contains the API request parameters.
Parameter
Description
Value
loadBalancerId
Unique ID of the CLB instance.
This example uses the unique ID of the instance you’ve just created: lb-abcdefgh
backends.0.instanceId
Unique ID of the CVM bound to the CLB instance.
This example uses the unique ID of the first CVM:ins-5678test
backends.0.weight
Weight of the CVM bound to the CLB instance.
This example uses the default value 10
backends.1.instanceId
Unique ID of the CVM bound to the load balancer instance
This example uses the unique ID of the second CVM: ins-1234test
backends.1.weight
Weight of the CVM bound to the CLB instance.
This example uses the default value 10
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=RegisterInstancesWithLoadBalancer
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerId=lb-cjcy****
&backends.0.instanceId=ins-5678****
&backends.0.weight=10
&backends.1.instanceId=ins-1234****
&backends.1.weight=10
Response of the request is as follows:
{
"code" : 0,
"message" : "",
"codeDesc": "Success",
"requestId" : 1234
}
To query the execution result of the task with the request ID, use the asynchronous DescribeLoadBalancersTaskResult API.

Querying and Using the CLB Instance

This example shows you how to query the VIP or domain name of the CLB instance. For more information on the query method, use the DescribeLoadBalancers API.
The Action field in the common request parameters of the API is DescribeLoadBalancers. The list below contains the API request parameters.
Parameter
Description
Value
loadBalancerIds.0
Unique ID of the CLB instance.
This example uses the unique ID of the instance you’ve just created: lb-cjcy****
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=DescribeLoadBalancers
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerIds.0=lb-cjcy****
Response
{
"code": 0,
"message": "",
"codeDesc": "Success",
"loadBalancerSet": [{
"loadBalancerId": "lb-cjcy****",
"unLoadBalancerId": "lb-cjcy****",
"loadBalancerName": "59b25ffb-0",
"loadBalancerType": 2,
"domain": "20de02-0.gz.1251000011.clb.myqcloud.com",
"loadBalancerVips": [
"119.28.168.196"
],
"status": 1,
"createTime": "2017-09-08 17:16:42",
"statusTime": "2017-09-20 13:37:55",
"vpcId": 0,
"uniqVpcId": "",
"subnetId": 0,
"projectId": 1005621,
"forward": 0,
"snat": false,
"openBgp": 0,
"isolation": 0,
"log": ""
}],
"totalCount": 1
}
As the query results suggest, you can use the VIP 119.28.168.XX or domain name 20****-0.gz.1251000011.clb.myqcloud.com of the CLB instance to forward the request to the associated backend CVMs according to the rule of CLB listener, thereby balancing the load.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック