写点什么

资源编排产品实现简单架构快速上云

  • 2019-10-17
  • 本文字数:4512 字

    阅读完需:约 15 分钟

资源编排产品实现简单架构快速上云

资源编排是一项简化云计算资源管理和运维的服务。用户通过模板描述多个云资源的配置信息和依赖关系,通过模板创建资源栈,自动完成所有资源的创建和配置,以实现资源的统一管理和自动化运维等目的。服务本身免费,仅收取所使用资源的费用:如云主机、公网 IP、云数据库实例等。

一、准备工作

1.说明

我们用 wordpress 模拟网站源代码,*.sql 文件模拟网站数据库备份,将网站源代码迁移到位于华北-北京不同可用区的两台云主机上,将 sql 备份文件恢复到云数据库 RDS MySQL 上,云主机与云数据库都由京东云资源编排产品自动创建生成。


模板的常用参数说明详见

2.测试示意图

二、开始

1. 创建资源栈(模板)

打开控制台,选择管理-资源编排-资源栈,选择需要创建的资源栈所在的地域,支持华北-北京、华南-广州、华东-宿迁、华东-上海,我这里选择华北-北京,点击创建资源栈按钮。



点击我的模板,将原模板内容删除,复制下面的 json 代码到模板内容中(此 json 代码内容中创建的资源较多,所以代码较多,复制时仔细认真点),点击下一步



1json  2{  3    "JDCLOUDTemplateFormatVersion": "2018-10-01",  4    "Description": "JDRO WORDPRESS_WITH_CLUSTER TEMPLATE",  5    "Parameters": {  6        "VPCName": {  7            "Default": "vpc",  8            "Type": "String",  9            "MinLength": "1", 10            "MaxLength": "32", 11            "Description": "Define the VPC Name. It cannot be same as an existing VPC name, otherwise the resource will fail to be created", 12            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$", 13            "ConstraintDescription": "Name only supports numbers, capital and lowercase letters, English underline and hyphen ." 14        }, 15        "SubnetName": { 16            "Default": "subnet", 17            "Type": "String", 18            "MinLength": "1", 19            "MaxLength": "32", 20            "Description": "Define the Subnet Name. It cannot be same as an existing Subnet name, otherwise the resource will fail to be created", 21            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$", 22            "ConstraintDescription": "Name only supports numbers, capital and lowercase letters, English underline and hyphen ." 23        }, 24        "AddressPrefix": { 25            "Default": "10.0.0.0/16", 26            "Type": "String", 27            "Description": "Give an exact CIDR", 28            "AllowedValues": [ 29                "192.168.0.0/16", 30                "172.16.0.0/16", 31                "10.0.0.0/16" 32            ], 33            "ConstraintDescription": "Need give an exact CIDR." 34        }, 35        "InstanceName1": { 36            "Default": "vm1", 37            "Type": "String", 38            "MinLength": "1", 39            "MaxLength": "32", 40            "Description": "Define the Instance Name", 41            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$", 42            "ConstraintDescription": "Name only supports numbers, capital and lowercase letters, English underline and hyphen." 43        }, 44        "InstanceName2": { 45            "Default": "vm2", 46            "Type": "String", 47            "MinLength": "1", 48            "MaxLength": "32", 49            "Description": "Define the Instance Name", 50            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$", 51            "ConstraintDescription": "Name only supports numbers, capital and lowercase letters, English underline and hyphen." 52        }, 53        "VMPassword": { 54            "NoEcho": true, 55            "Description": "Password for vm access", 56            "Type": "String", 57            "MinLength": "8", 58            "MaxLength": "16", 59            "AllowedPattern": "[a-zA-Z0-9]*" 60        }, 61        "DiskName1": { 62            "Default": "disk1", 63            "Type": "String", 64            "MinLength": "1", 65            "MaxLength": "32", 66            "Description": "The Disk Name", 67            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$", 68            "ConstraintDescription": "Name only supports numbers, capital and lowercase letters, English underline and hyphen." 69        }, 70        "DiskName2": { 71            "Default": "disk2", 72            "Type": "String", 73            "MinLength": "1", 74            "MaxLength": "32", 75            "Description": "The Disk Name", 76            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$", 77            "ConstraintDescription": "Name only supports  numbers, capital and lowercase letters, English underline and hyphen." 78        }, 79        "DBName": { 80            "Default": "wordpress", 81            "Description": "MySQL database name", 82            "Type": "String", 83            "MinLength": "2", 84            "MaxLength": "32", 85            "AllowedPattern": "^[a-z][a-z0-9_]*$", 86            "ConstraintDescription": "The name only supports lower case letters, numbers and English underline, no less than 2 characters and no more than 32 characters." 87        }, 88        "DBUser": { 89            "Default": "wordpress", 90            "Description": "Username for MySQL database access", 91            "Type": "String", 92            "MinLength": "1", 93            "MaxLength": "16", 94            "AllowedPattern": "^[a-zA-Z][a-zA-Z0-9]*$", 95            "ConstraintDescription": "must begin with a letter and contain only alphanumeric characters." 96        }, 97        "DBPassword": { 98            "NoEcho": true, 99            "Description": "Password must contain and only supports letters both in upper case and lower case as well as figures, no less than 8 characters and no more than 16 characters. e.g. Ptest1130",100            "Type": "String",101            "MinLength": "8",102            "MaxLength": "16",103            "AllowedPattern": "[a-zA-Z0-9]*"104        },105        "LoadBalancerName": {106            "Default": "lb",107            "Description": "LoadBalancer name",108            "Type": "String",109            "MinLength": "1",110            "MaxLength": "32",111            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$",112            "ConstraintDescription": "Name only supports  numbers, capital and lowercase letters, English underline  and hyphen."113        },114        "TargetGroupName": {115            "Default": "lbtargetgroup",116            "Description": "TargetGroup Name",117            "Type": "String",118            "MinLength": "1",119            "MaxLength": "32",120            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$",121            "ConstraintDescription": "Name only supports  numbers, capital and lowercase letters, English underline  and hyphen."122        },123        "LBBackendName": {124            "Default": "lbbackend",125            "Description": "Backend Name",126            "Type": "String",127            "MinLength": "1",128            "MaxLength": "32",129            "AllowedPattern": "^[a-zA-Z_][a-zA-Z0-9_-]*$",130            "ConstraintDescription": "Name only supports  numbers, capital and lowercase letters, English underline  and hyphen."131        }132    },133    "Mappings": {134        "AZInfo": {135            "cn-north-1": {136                "az1": "cn-north-1a",137                "az2": "cn-north-1b",138                "az3": "cn-north-1c"139            },140            "cn-east-1": {141                "az1": "cn-east-1a"142            },143            "cn-east-2": {144                "az1": "cn-east-2a",145                "az2": "cn-east-2b"146            },147            "cn-south-1": {148                "az1": "cn-south-1a"149            }150        },151        "ImageInfo": {152            "cn-north-1": {153                "image": "img-9ha1rgelkq"154            },155            "cn-east-1": {156                "image": "img-htaupmjlqq"157            },158            "cn-east-2": {159                "image": "img-ssazsh60t6"160            },161            "cn-south-1": {162                "image": "img-uxgb28v2y3"163            }164        }
复制代码


(由于篇幅原因,只选取部分)


栈名称:资源编排测试


超时时间(分钟):10


  • VPCName:vpc

  • SubnetName:subnet

  • AddressPrefix:10.0.0.0/16

  • InstanceName1:vm1

  • InstanceName2:vm2

  • VMPassword:自定义

  • DiskName1:disk1

  • DiskName2:disk2

  • DBName:wordpress

  • DBUser:wordpress

  • DBPassword:自定义

  • LoadBalancerName:lb

  • TargetGroupName:lbtargetgroup

  • LBBackendName:lbbackend


确认资源栈信息后,点击创建资源栈



ta 创建完成后点击时间列表能够查看整个资源栈的创建过程




2. 测试上云

所有资源创建完成后,我们找到创建好的负载均衡实例公网 IP,粘贴到浏览器打开查看效果



接下来我们将本地的 MySQL 数据库备份文件导入到我们创建的云数据库 RDS MySQL 中


备份本地数据库,命令如下:


1mysqldump -u用户名 -p密码 --single-transaction --set-gtid-purged=OFF -B 数据库名称 > /路径/导出文件名.sql
复制代码


将本地 MySQL 备份完成后,我们需要创建一台与云数据库 RDS MySQL 在相同 VPC 的云主机(不在同一 VPC 默认情况下无法访问云数据库),创建云主机方法见


创建完云主机后,将本地备份的.sql 文件上传到京东云对象存储



上传完备份 SQL 后,我们获取相应备份文件的外链地址



然后通过 wget 命令下载到上面我们创建的云主机



然后通过如下命令进行备份文件的导入


1mysql -h云数据库域名 -u用户名 -p 数据库名  < /云主机路径/导出文件名.sql
复制代码


云数据库域名查看方式:



最大复制负载均衡公网 IP 到浏览器,查看结果:



2019-10-17 17:541286

评论

发布
暂无评论
发现更多内容

常见的软件可靠性度量和分析方法

穿过生命散发芬芳

可靠性度量 6 月 优质更文活动

解决vue组件终端报错: error Component name “xxx“ should always be multi-word vue/multi-word

不觉心动

6 月 优质更文活动

3DCAT亮相糖酒会,为元宇宙展会提供实时云渲染支持

3DCAT实时渲染

元宇宙 实时云渲染

从数据开始,构建值得信赖的生成式AI应用

澳鹏Appen

人工智能 nlp 数据标注 ChatGPT 生成式AI

Milvus Lite 已交卷!轻量版 Milvus,主打就是一个轻便、无负担

Zilliz

Milvus 向量数据库 MILVUSLITE

火山引擎DataLeap:从短视频APP实践来看,如何统一数据指标口径?

字节跳动数据平台

大数据 指标体系 数据研发 指标建设

节省90%编译时间,这是字节跳动开源的基于Rust的前端构建工具

字节跳动技术范儿

rust 前端 前端构建

SaaS公司如何成为 AI 独角兽?发挥长板:流程、用户需求和数据积累

B Impact

使用SpringBoot整合数据库连接池Druid的错误总结

不觉心动

6 月 优质更文活动

有哪些内外网都能传输文件的工具-镭速

镭速

Go 空结构体:零内存的魔力

陈明勇

Go golang 空结构体 6 月 优质更文活动

C语言编程—头文件

芯动大师

C语言 头文件 6 月 优质更文活动

Vue安装并使用axios发送请求

不觉心动

6 月 优质更文活动

npm安装nanoid生成随机id并简单使用

不觉心动

6 月 优质更文活动

【零售电商系列】走进亚马逊(一)

小诚信驿站

6 月 优质更文活动

2023-06-08:给你一棵二叉树的根节点 root ,返回树的 最大宽度 。 树的 最大宽度 是所有层中最大的 宽度 。 每一层的 宽度 被定义为该层最左和最右的非空节点(即,两个端点)之间的长度

福大大架构师每日一题

算法 福大大

Pilota:为什么一个代码生成工具如此复杂丨GOTC Rust系列分享

字节跳动技术范儿

rust GOTC

Vue.js 最佳实践:提高性能和减少耦合的方法

xfgg

JavaScript Vue 前端 6 月 优质更文活动

对话 ChatGPT 理解 Rust 异步网络 io

蓬蒿

rust 编程语言 tokio 异步网路io

Vue使用axios进行get请求拼接参数的两种方式

不觉心动

6 月 优质更文活动

解决SpringBoot整合Mybatis和Mybatis-Plus不能公用(版本兼容性问题)

不觉心动

6 月 优质更文活动

模型服务文档自动生成,要素追溯关联、结构规范易读|ModelWhale 版本更新

ModelWhale

大模型 企业团队协同 数据开放和利用 学科交叉 人文社科

墨天轮国产关系型分布式数据库榜单解读

墨天轮

数据库 GaussDB TiDB oceanbase polarDB

中企出海成大热趋势,海外用户如何高效触达

MobTech袤博科技

开发一个API Gateway

无心

API Gateway

HAG:首个通过合规STO将RWA通证化应用于比特币Mining的项目

股市老人

浅谈中小企业如何选择适合自己的网络营销方式

石头IT视角

SpringBoot项目使用hutool工具进行HttpClient接口调用的处理(文件上传)

不觉心动

6 月 优质更文活动

资源编排产品实现简单架构快速上云_架构_韩超超_InfoQ精选文章