资源编排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='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": "现有虚拟专有网络的实例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)
。具体步骤,请参见添加安全组规则。