全部產品
Search
文件中心

:WA-跨地區-NLB-ECS部署模板

更新時間:Oct 12, 2025

模板ID

FOOKUK1EPTFB97PA

地址:https://bpstudio.console.alibabacloud.com/bpStudio/topo?TemplateId=FOOKUK1EPTFB97PA

模板架構

image.jpeg

業務情境說明:

業務上希望在A地區的NLB執行個體能夠掛載另外兩個不同地區的ECS執行個體,實現跨地區高可用。按需設計架構:

在阿里雲西南1(成都)地區建立了Virtual Private Cloud1,在VPC1中建立了一個NLB執行個體,並在VPC1內建立了Elastic Compute Service1作為用戶端測實驗證跨地區負載平衡訪問;

同時在華東2(上海)建立了Virtual Private Cloud2,並在VPC2中建立了Elastic Compute Service2執行個體;

在華北1(青島)建立了Virtual Private Cloud3並在VPC3中建立了Elastic Compute Service3執行個體,ECS2與ECS3中部署了相同的服務。

三個地區的互聯,基於阿里雲的雲企業網和轉寄路由器實現,並配置跨地區串連和頻寬。

參數變數

參數變數類型包括String、Integer、Boolean、Map等,通過variables傳遞相關參數值。

如果未傳遞,則使用預設值。 如果修改模板變數配置,可以參考:模板變數配置

序號

變數名稱

變數類型

預設值

描述

1

${cen-name}

String

企業版cen-test

雲企業網名稱

2

${nlb-name}

String

nlb-test

NLB執行個體名稱

3

${instance-tags}

Map

{"createBy":"cadt"}

資源標籤

4

${nlb-listener}

String

nlb_listener_80

NLB的監聽

5

${nlb-listener-port}

Integer

80

監聽連接埠

6

${nlb-vservergroup-01}

String

nlb_servergroup

虛擬伺服器組

7

${nlb-sg-backend-port}

List<Map>

[{"backend_port":"80","weight":100}]

伺服器組連接埠配置

8

${ecs-01-num}

Integer

1

ECS01的執行個體數量

9

${ecs-01-type}

String

ecs.c6.large

ECS01的執行個體規格

10

${ecs-01-name}

String

ecs-chengdu-01

ECS01的執行個體/主機名稱

11

${ecs-01-password}

String

Test1234

ECS01的密碼

12

${ecs-01-privateip}

String

10.0.1.100

ECS01的私網IP地址

13

${ecs-02-num}

Integer

1

ECS02的執行個體數量

14

${ecs-02-type}

String

ecs.c6.large

ECS02的執行個體規格

15

${ecs-02-name}

String

ecs-shanghai-01

ECS02的執行個體/主機名稱

16

${ecs-02-password}

String

Test1234

ECS02的密碼

17

${ecs-02-privateip}

String

10.10.1.100

ECS02的私網IP地址

18

${ecs-03-num}

Integer

1

ECS03的執行個體數量

19

${ecs-03-type}

String

ecs.c6.large

ECS03的執行個體規格

20

${ecs-03-name}

String

ecs-qingdao-01

ECS03的執行個體/主機名稱

21

${ecs-03-password}

String

Test1234

ECS03的密碼

22

${ecs-03-privateip}

String

10.20.1.100

ECS03的私網IP地址

命令列調試

YAML檔案傳參配置樣本(預設VPC、交換器、共用頻寬、NLB、ECS均為新建立):

template_id: FOOKUK1EPTFB97PA
#area_id: "cn-beijing"
instances:
#  - node_type: vpc
#    node_name: vpc-01
#    id: vpc-bp**********ws
#  - node_type: vswitch
#    node_name: chengdu-vsw01
#    id: vsw-bp**********0ex
#  - node_type: vswitch
#    node_name: chengdu-vsw02
#    id: vsw-bp**********1ek
#  - node_type: vpc
#    node_name: vpc-02
#    id: vpc-bp**********ws
#  - node_type: vswitch
#    node_name: shanghai-vsw01
#    id: vsw-bp**********0ex
#  - node_type: vswitch
#    node_name: shanghai-vsw02
#    id: vsw-bp**********1ek
#  - node_type: vpc
#    node_name: vpc-03
#    id: vpc-bp**********ws
#  - node_type: vswitch
#    node_name: qingdao-vsw01
#    id: vsw-bp**********0ex
#  - node_type: vswitch
#    node_name: qingdao-vsw02
#    id: vsw-bp**********1ek
# 預設建立VPC和交換器,已注釋對應參數。複用現有VPC和交換器時,取消注釋,替換對應的執行個體ID

variables:
  ${nlb-name}: "ali-prod-nlb"
  ${nlb-network-type}: "Intranet"
  # 私網:Intranet,公網:Internet
  ${nlb-listener}: "listener_TCP_80"
  ${nlb-listener-port}: "80"
  ${nlb-vservergroup-01}: "SG_TCP_01"
  ${nlb-sg-backend-port}: "[{\"backend_port\":\"80\",\"weight\":\"100\"}]"
  ${cen-name}: "企業版CEN-01" 
  ${ecs-01-num}: "1"  
  ${ecs-01-type}: "ecs.c6.large"
  ${ecs-01-name}: "ecs-chengdu-01"
  ${ecs-01-privateip}: "10.0.1.100"
  ${ecs-01-password}: "Test1234"
  ${ecs-02-num}: "1"  
  ${ecs-02-type}: "ecs.c6.large"
  ${ecs-02-name}: "ecs-shanghai-01"
  ${ecs-02-privateip}: "10.10.1.100"
  ${ecs-02-password}: "Test1234"
  ${ecs-03-num}: "1"  
  ${ecs-03-type}: "ecs.c6.large"
  ${ecs-03-name}: "ecs-qingdao-01"
  ${ecs-03-privateip}: "10.20.1.100"
  ${ecs-03-password}: "Test1234"
  ${instance-tags}: "{\"env\":\"test\",\"createBy\":\"cadt\"}"
  #${resourcegroupId}: "rg-ac*****y"

configuration:
  enableMonitor: "0"
  enableReport: "0"

output:
  nlb:
    - Address
    - Port
  ecs: 
    - Private_ip

備忘說明:

1、如果需要替換模板中的已保有執行個體,比如使用存量的VPC、交換器等。可以替換對應的instances的ID欄位。

instances:
  - node_type: vpc
    node_name: vpc-01
    id: vpc-bp**********ws
  - node_type: vswitch
    node_name: chengdu-vsw01
    id: vsw-bp**********0ex
  - node_type: vswitch
    node_name: chengdu-vsw02
    id: vsw-bp**********1ek
  - node_type: vpc
    node_name: vpc-02
    id: vpc-bp**********ws
  - node_type: vswitch
    node_name: shanghai-vsw01
    id: vsw-bp**********0ex
  - node_type: vswitch
    node_name: shanghai-vsw02
    id: vsw-bp**********1ek
  - node_type: vpc
    node_name: vpc-03
    id: vpc-bp**********ws
  - node_type: vswitch
    node_name: qingdao-vsw01
    id: vsw-bp**********0ex
  - node_type: vswitch
    node_name: qingdao-vsw02
    id: vsw-bp**********1ek