利用ROS搭建套用基礎套件

來源:互聯網
上載者:User

摘要: 本文介紹如果利用阿裡雲資源編排服務搭建一套企業級套用的基礎架構(SLB+ECS+RDS).

幕後

SLB + ECS + RDS 是企業級套用的基礎搭配,在小型套用場景下這三款產品成為了架構的核心元件。

screenshot

基本結構如上圖所示,建立一組ECS實例並掛在到SLB下面,然後建立一個ECS實例,同時把ECS的IP上線到存取白名單。作為套用方,您只需要根據商務類型和特點預估一下ECS的數量即可,其餘的事情阿裡雲資源編排服務ROS可以幫您一鍵完成。

建立的資源包括

·ALIYUN::ECS::InstanceGroup

    • 建立一組相同設定的ECS.

注意:如果每台ECS的轉寄權數一樣的話,可以採用本文的方式掛載到SLB,否則您可以參考手動的方式掛載並設定不同的權數值。

·ALIYUN::SLB::LoadBalancer

    • 建立一個負載平衡

·ALIYUN::SLB::Listener

    • 設定監聽

·ALIYUN::SLB::BackendServerAttachment

    • 掛載ECS到負載平衡

·ALIYUN::RDS::DBInstance

    • 建立RDS實例

有關RDS其他設定請參考利用ROS建立RDS實例

步驟詳解

  • step1: 建立一組ECS實例,設定為2核4G(ecs.s2.large), 選擇非IO優化的普通雲盤,選擇公共鏡像,同時建立一個安全性群組。ECS數量的上線根據具體的商務場景來設定,本例設定預設值為2。
"ecsInstanceGroup": {
"Properties": {
"ImageId": "centos7u2_64_40G_cloudinit_20160520.raw",
"InstanceType": "ecs.s2.large",
"MaxAmount": {
"Ref": "EcsMaxAmount"
},
"MinAmount": 2,
"SecurityGroupId": {
"Fn::GetAtt": [
"securityGroup",
"SecurityGroupId"
]
}
},
"Type": "ALIYUN::ECS::InstanceGroup"
},
"securityGroup": {
"Properties": {
"SecurityGroupEgress": [
{
"DestCidrIp": "0.0.0.0/0",
"IpProtocol": "all",
"NicType": "internet",
"PortRange": "-1/-1",
"Priority": 1
}
],
"SecurityGroupIngress": [
{
"IpProtocol": "all",
"NicType": "internet",
"PortRange": "-1/-1",
"Priority": 1,
"SourceCidrIp": "0.0.0.0/0"
}
],
"SecurityGroupName": {
"Ref": "SecurityGroupName"
}
},
"Type": "ALIYUN::ECS::SecurityGroup"
}
  • step2: 建立負載平衡,設定埠對應為80 -> 8080
"LoadBalancer": {
"Properties": {
"AddressType": "internet",
"InternetChargeType": "paybytraffic",
"LoadBalancerName": "createByRos"
},
"Type": "ALIYUN::SLB::LoadBalancer"
},
"CreateListener": {
"Type": "ALIYUN::SLB::Listener",
"Properties": {
"LoadBalancerId": {"Ref": "LoadBalancer"},
"ListenerPort": "80",
"BackendServerPort": 8080,
"Bandwidth": 1,
"Protocol": "http",
"HealthCheck": {
"HealthyThreshold": 3,
"UnhealthyThreshold": 3,
"Interval": 2,
"Timeout": 5,
"HttpCode": "http_2xx,http_3xx,http_4xx,http_5xx"
},
"Scheduler": "wrr"
}
}
  • step3: 掛載ECS到SLB, 設定相同的權數
"Attachment": {
"Properties": {
"BackendServerList":
{
"Fn::GetAtt": [
"ecsInstanceGroup",
"InstanceIds"
]
},
"LoadBalancerId": {
"Ref": "LoadBalancer"
}
},
"Type": "ALIYUN::SLB::BackendServerAttachment"
}
  • step4: 建立RDS實例,同時設定存取白名單

"RDSInstance": {
"Properties": {
"ConnectionMode": "Safty",
"DBInstanceClass": "rds.mys2.large",
"DBInstanceDescription": "createByRos",
"DBInstanceNetType": "Intranet",
"DBInstanceStorage": "100",
"Engine": "MySQL",
"EngineVersion": "5.6",
"SecurityIPList": {
"Fn::GetAtt": [
"ecsInstanceGroup",
"PrivateIps"
]
}
},
"Type": "ALIYUN::RDS::DBInstance"
}

到ROS主控台建立

下載範本

相關產品:

  1. 資源編排ROS
  2. 企業級分散式套用服務
  3. 雲端服務器ECS
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.