Resource Orchestration Service支援在模板中定義所需的阿里雲資源(例如ECS執行個體、RDS資料庫執行個體)、資源間的依賴關係等。ROS的編排引擎將根據模板自動完成所有資源的建立和配置,實現自動化部署及營運。本文介紹如何通過OSS以及ROS服務快速建立Nginx。
前提條件
步驟一:在Bucket中上傳Nginx安裝包
步驟二:通過ROS建立資源棧
選擇模板。
在左側導覽列,單擊資源棧。
在頁面左上方的地區下拉式清單,選擇華東1(杭州)。
在資源棧列表頁面,單擊建立資源棧,然後在下拉式清單中選擇使用ROS。
在選擇模板頁面,指定模板為選擇已有模板,模板錄入方式選擇輸入模板,在ROS模板內容的JSON頁簽輸入以下模板內容,然後單擊下一步。
{ "ROSTemplateFormatVersion": "2015-09-01", "Description": "", "Parameters": { "NginxDownloadUrl": { "Type": "String", "Description": { "zh-cn": "nginx-*.rpm的下載路徑", "en": "The download path of nginx-*.rpm" }, "Label": { "zh-cn": "Nginx下載地址", "en": "Nginx Download Url" } }, "ZoneId": { "AssociationProperty": "ALIYUN::ECS::Instance:ZoneId", "Type": "String", "Description": { "zh-cn": "可用性區域ID。<br><b>註: <font color='blue'>選擇前請確認該可用性區域是否支援建立ECS資源的規格,建議選擇與其他交換器不同的可用性區域</font></b>", "en": "Availability Zone ID.<br><b>note:<font color='blue'>before selecting, please confirm that the Availability Zone supports the specification of creating ECS resources,which is recommended to be different from other VSwitch Availability Zone</font></b>" }, "Label": { "zh-cn": "交換器可用性區域", "en": "VSwitch Availability Zone" } }, "ImageId": { "Default": "centos_7", "Type": "String", "Description": { "zh-cn": "請使用Centos7的鏡像ID。詳見:<b><a href='https://help.aliyun.com/document_detail/112977.html' target='_blank'><font color='blue'>尋找鏡像</font></a></b>", "en": "Image ID,Please use Centos7, see detail:<b><a href='https://www.alibabacloud.com/help/en/doc-detail/112977.html' target='_blank'><font color='blue'>Find the mirror</font></a></b>" }, "Label": { "zh-cn": "鏡像", "en": "Image" } }, "InstanceType": { "AssociationProperty": "ALIYUN::ECS::Instance::InstanceType", "AssociationPropertyMetadata": { "ZoneId": "ZoneId" }, "Label": { "zh-cn": "執行個體規格", "en": "Instance Type" }, "Type": "String", "Description": { "zh-cn": "<font color='blue'><b>1.選擇機型前請先確認當前可用性區域下是否存在該機型,部分機型需要提前報備</b></font><br><font color='blue'><b>2.可選機型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB 內網頻寬1Gbps 內網收發包30萬PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB 內網頻寬1.5Gbps 內網收發包50萬PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB 內網頻寬2.5Gbps 內網收發包80萬PPS</font>]", "en": "<font color='blue'><b>1.Before selecting the model please confirm that the current available zone under the model is in stock, some models need to be reported in advance</b></font><br><font color='blue'><b>2.List of optional models</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU 16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]" } }, "SystemDiskCategory": { "Default": "cloud_efficiency", "Label": { "zh-cn": "系統硬碟類型", "en": "System Disk Type" }, "Type": "String", "Description": { "en": "<font color='blue'><b>Optional values:</b></font><br>[cloud_efficiency: <font color='green'>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color='green'>SSD Cloud Disk</font>]<br>[cloud_essd: <font color='green'>ESSD Cloud Disk</font>]<br>[cloud: <font color='green'>Cloud Disk</font>]<br>[ephemeral_ssd: <font color='green'>Local SSD Cloud Disk</font>]", "zh-cn": "<font color='blue'><b>可選值:</b></font><br>[cloud_efficiency: <font color='green'>高效雲端硬碟</font>]<br>[cloud_ssd: <font color='green'>SSD雲端硬碟</font>]<br>[cloud_essd: <font color='green'>ESSD雲端硬碟</font>]<br>[cloud: <font color='green'>普通雲端硬碟</font>]<br>[ephemeral_ssd: <font color='green'>本地SSD盤</font>]" }, "AllowedValues": [ "cloud_efficiency", "cloud_ssd", "cloud", "cloud_essd", "ephemeral_ssd" ] }, "InstancePassword": { "Type": "String", "Description": { "zh-cn": "伺服器登入密碼。長度為8~30字元,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。", "en": "Server login password, Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)." }, "MinLength": 8, "Label": { "zh-cn": "執行個體密碼", "en": "Instance Password" }, "AllowedPattern": "[0-9A-Za-z\\_\\-\\&:;'<>,=%`~!@#\\(\\)\\$\\^\\*\\+\\|\\{\\}\\[\\]\\.\\?\\/]+$", "NoEcho": true, "MaxLength": 30, "ConstraintDescription": { "zh-cn": "長度為8~30字元,必須包含三項(大寫字母、小寫字母、數字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符號)。", "en": "Length 8-30, must contain three(Capital letters, lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in)." } }, "SecurityGroup": { "Type": "String", "AssociationProperty": "ALIYUN::ECS::SecurityGroup::SecurityGroupId", "Description": { "zh-cn": "現有業務安全性群組的執行個體ID,可通過ECS控制台-網路與安全-安全性群組進行查詢。", "en": "Please search the business security group ID starting with(sg-xxx)from console-ECS-Network & Security" }, "Label": { "zh-cn": "安全性群組ID", "en": "Security Group ID" } }, "VPC": { "AssociationProperty": "ALIYUN::ECS::VPC::VPCId", "Type": "String", "Description": { "zh-cn": "現有Virtual Private Cloud絡的執行個體ID,可通過VPC控制台-專用網路進行查詢。", "en": "Please search the ID starting with (vpc-xxx)from console-Virtual Private Cloud" }, "Label": { "zh-cn": "現有VPC的執行個體ID", "en": "Existing VPC Instance ID" } }, "VSwitch": { "AssociationProperty": "ALIYUN::ECS::VSwitch::VSwitchId", "Type": "String", "Description": { "zh-cn": "現有業務網路交換器的執行個體ID,可通過VPC控制台-專用網路-交換器進行查詢。", "en": "Please search the business vswitch ID starting with(vsw-xxx)from console-Virtual Private Cloud-VSwitches" }, "Label": { "zh-cn": "網路交換器ID", "en": "VSwitch ID" } } }, "Metadata": { "ALIYUN::ROS::Interface": { "ParameterGroups": [ { "Parameters": [ "VPC", "VSwitch", "SecurityGroup" ], "Label": { "default": { "zh-cn": "基礎資源配置", "en": "Infrastructure Configuration" } } }, { "Parameters": [ "ZoneId", "ImageId", "InstanceType", "SystemDiskCategory", "InstancePassword", "NginxDownloadUrl" ], "Label": { "default": { "zh-cn": "ECS雲端服務器配置", "en": "ECS Configuration" } } } ], "TemplateTags": [ "acs:example:Linux應用服務:ROS_OOS建立Nginx應用" ] } }, "Resources": { "WebServer": { "Type": "ALIYUN::ECS::Instance", "Properties": { "InternetMaxBandwidthOut": 80, "IoOptimized": "optimized", "VpcId": { "Ref": "VPC" }, "UserData": { "Fn::Join": [ "", [ "#!/bin/bash \n", "NginxUrl=", { "Ref": "NginxDownloadUrl" }, "\n", "yum -y install aria2 \n", "aria2c $NginxUrl \n", "rpm -ivh nginx-*.rpm \n", "yum -y install nginx \n", "systemctl enable nginx.service \n", "systemctl restart nginx.service \n" ] ] }, "SecurityGroupId": { "Ref": "SecurityGroup" }, "VSwitchId": { "Ref": "VSwitch" }, "ImageId": { "Ref": "ImageId" }, "InstanceType": { "Ref": "InstanceType" }, "SystemDiskCategory": { "Ref": "SystemDiskCategory" }, "Password": { "Ref": "InstancePassword" } } } }, "Outputs": { "NginxUrl": { "Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "WebServer", "PublicIp" ] }, ":80" ] ] } } } }
配置參數。
在配置參數頁簽,自訂資源棧名稱。
在配置模板參數地區,按以下要求完成各配置項。
地區
參數
說明
基礎資源配置
現有VPC的執行個體ID
下拉選擇VPC ID。
網路交換器ID
下拉選擇網路交換器ID。
安全性群組ID
下拉選擇安全性群組ID。
ECS雲端服務器配置
交換器可用性區域
按需選擇交換器可用性區域,例如可用性區域G。
鏡像
填寫centos_7。
執行個體規格
按需選擇執行個體規格。
系統硬碟類型
選擇cloud_ssd。
執行個體密碼
自訂執行個體密碼。
Nginx下載地址
填寫Nginx安裝包的檔案URL。您可以從步驟一中擷取檔案URL。
在配置資源棧地區,保留預設配置。
單擊建立。
訪問Nginx歡迎頁面。
單擊已建立的資源棧。
單擊輸出頁簽,然後單擊NginxUrl。
單擊NginxUrl後,自動跳轉至CentOS歡迎頁面,表示Nginx已正常運行。
如果遇到無法訪問該頁面的問題,請為當前安全性群組ID添加預設連接埠
HTTP(80)
。具體步驟,請參見添加安全性群組規則。