資源編排ROS支持在模板中定義所需的阿里云資源(例如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='http://bestwisewords.com/document_detail/112977.html' target='_blank'><font color='blue'>查找鏡像</font></a></b>", "en": "Image ID,Please use Centos7, see detail:<b><a 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": "現有虛擬專有網絡的實例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)
。具體步驟,請參見添加安全組規則。
文檔內容是否對您有幫助?