所选语种没有对应资源,请选择:

本站点使用Cookies,继续浏览表示您同意我们使用Cookies。Cookies和隐私政策>

提示

尊敬的用户,您的IE浏览器版本过低,为获取更好的浏览体验,请升级您的IE浏览器。

升级

FusionCloud 6.3.1 用户指南 (Region Type I) 10

评分并提供意见反馈 :
华为采用机器翻译与人工审校相结合的方式将此文档翻译成不同语言,希望能帮助您更容易理解此文档的内容。 请注意:即使是最好的机器翻译,其准确度也不及专业翻译人员的水平。 华为对于翻译的准确性不承担任何责任,并建议您参考英文文档(已提供链接)。
vAPP部署WordPress

vAPP部署WordPress

背景信息

本文档以vAPP部署WordPress个人博客网站为例,演示如何实现通过弹性云服务器访问Web应用。

本文档中样例所使用的软件版本如下:

  • mysql-5.5.31-0.7.10.x86_64.tar.gz
  • apache22_php53_wordpress49.tar.gz

准备

软件包

需要准备如下软件包:

  • mysql-5.5.31-0.7.10.x86_64.tar.gz
  • apache22_php53_wordpress49.tar.gz
云服务准备

本文档需要准备如下的云服务,如表38-10所示。

表38-10 云服务列表

云服务名称

具体操作

镜像

请参见镜像服务

本文档样例使用SUSE 11 Linux 64bit且成功安装Cloud-Init_0.7.6。

虚拟私有云

请参见申请虚拟私有云

弹性负载均衡

请参见申请负载均衡

弹性云服务器

请参见弹性云服务器

本文档样例使用的弹性云服务器规格:2U2G40G(2/vCPUs+2G/Memory+40G/Root Disk)

弹性IP

申请弹性IP并与弹性云服务器绑定。

请参见申请和绑定弹性IP

搭建软件源云服务器

软件源云服务器与vAPP创建的云服务器网络相通,以确保创建vAPP实例时云服务器可以从软件源云服务器上获取软件包;软件源云服务器与本地网络互通,以确保软件可以正常上传到软件源云服务器。

前提条件

已存在可用的弹性云服务器及弹性IP,且弹性IP已与弹性云服务器绑定。

操作步骤

安装Apache服务

软件源云服务器需安装Apache服务,上传Apache软件包至vAPP-ecs-SwSrv软件源云服务器中的opt目录下。本次搭建的软件源云服务器选用Apache软件包为“apache2-2.2.10-2.24.5.x86_64.tar.gz”

  1. 使用MobaXterm工具,以“root”用户使用设置的登录密码或者密钥对登录虚拟机。

  2. 将本地计算机的Apache软件包上传至软件源云服务器的opt目录下,执行解压命令:

    tar -zxvf apache2-2.2.10-2.24.5.x86_64.tar.gz

  3. 运行脚本执行安装。

  4. 进入到“/opt/apache”目录,执行如下命令启动Apache:

    service apache2 start

  5. 执行如下命令查看Apache服务是否启动正常:

    ps –ef | grep apache

    出现如下输出说明启动正常:

上传软件包

  1. 将本地计算机的WordPress软件包上传至软件源云服务器上的对应目录:

    MySQL:/srv/www/htdocs/packages/sles/11/x86_64/mysql/mysql-5.5.31-0.7.10.x86_64.tar.gz

    WordPress:/srv/www/htdocs/packages/sles/11/x86_64/wordpress/apache22_php53_wordpress49.tar.gz

  2. 验证虚拟机能否正常下载软件包

    • 登录和软件源云服务器同VPC子网的其他虚拟机
    • 执行如下命令验证虚拟机能否正常下载软件源云服务器上的软件包:

    wget http://[软件源虚拟机IP]/packages/sles/11/x86_64/mysql/mysql-5.5.31-0.7.10.x86_64.tar.gz

    回显信息如下,说明虚拟机可正常下载软件源云服务器上的软件包,至此完成软件源云服务器的搭建。

规划配置

模板内容解析

本次部署通过导入提前准备好的RTS样例模板来创建vAPP产品,然后发放vAPP实例,所使用的RTS样例模板见附件

关键模板资源

  • 资源:OS::Nova::Server

  • 资源:OS::Cinder::Volume

  • 资源:OS::Neutron::Port

  • 资源:OS::Neutron::LBaaS::LoadBalancer

  • 资源:OS::Neutron::LBaaS::Listener

  • 资源:OS::Neutron::LBaaS::Pool

  • 资源:OS::Neutron::LBaaS::HealthMonitor

  • 资源:OS::Neutron::LBaaS::PoolMember

模板参数说明

  • dbServerName: 用于部署数据库的服务器的名称(label:数据库服务器名称,value:vAPP_ecs_MySQL)。
  • eipExternalNet: 弹性IP对应的外部网络名称或者ID(label:弹性IP的外部网络,value:点击输入框后面的选择,在弹出框中选择需要的参数)。
  • web1ServerName: WordPress服务器1的名称(label:云服务器名称,value:vAPP_ecs_WordPress1)。
  • web2ServerName: WordPress服务器2的名称(label:云服务器名称,value:vAPP_ecs_WordPress2)。
  • availabilityZone: 指在同一地域下,电力、网络隔离的物理区域,可用分区之间内网互通,不同可用分区之间物理隔离(label:可用分区,value:点击输入框后面的选择,在弹出框中选择需要的参数)。
  • imageId: 用于创建系统盘的镜像ID(label:镜像,value:单击输入框后面的选择,在弹出框中选择需要的参数)。
  • flavor: 服务器的规格,包括内存、CPU、磁盘类型等信息(label:规格,value:单击输入框后面的选择,在弹出框中选择需要的参数)。
  • volumeSize: 服务器的系统盘大小,以GB为单位。该值应大于或等于镜像的大小(label:系统盘大小,value:根据业务所需填写)。
  • volumeType: 服务器的系统盘类型(label:磁盘类型,value:单击输入框后面的选择,在弹出框中选择需要的参数)。
  • serverPortNetwork: 服务器的网卡所属网络(label:网卡,value:单击输入框后面的选择,在弹出框中选择需要的参数)。
  • dbRootPassword: MySQL数据库root用户的密码(label:MySQL数据库root用户的密码)。
  • mysqlUser: 通过WordPress访问数据库时使用的用户名(label:MySQL用户名称)。
  • mysqlPassword: 通过WordPress访问数据库的登录密码(label:MySQL用户密码)。
  • wordpressSourceUrl: WordPress安装包的下载地址。(label:WordPress下载地址,value:http://软件源云服务器私有IP/packages/sles/11/x86 64/wordpress/apache22 php53 wordpress49.tar.gz)
  • mysqlSourceUrl: MySQL安装包的下载地址。(label:MySQL下载地址,value:http://软件源云服务器私有IP/packages/sles/11/x86 64/mysql/mysql-5.5.31-0.7.10.x86 64.tar.gz )
  • lbAlgorithm: 该算法用于在池的成员之间分配负载。取值范围:ROUND_ROBIN,LEAST_CONNECTIONS,SOURCE_IP,分别表示轮询算法,最少连接,源IP算法(label:VLB分配策略类型,value:从下拉框中选择)。
  • protocol: 监听器的协议,支持TCP和HTTP,其取值必须与OS::Neutron::LBaaS::Listener.protocol保持一致(label:监听协议,value:从下拉框中选择)。
  • listenerProtocolPort: 监听端口,取值范围[0,65535],protocol为TCP时,protocol_port范围为[0-65535];protocol为HTTP时,protocol_port范围为[1-65535] (label:监听端口,value:ELB监听前端端口)。
  • memberProtocolPort: 后端端口号,取值范围[0,65535],端口0只在DR模式下有效(label:后端端口号,value:Apache启动端口)。
  • healthMonitorType: 检查类型,可以为PING,TCP,HTTP,HTTPS。(label:健康检查类型,value:从下拉框中选择)。
脚本内容

WordPress安装脚本

#!/bin/bash

SOURCE_URL=$${WordPress_source_url}

LOCAL_TEMP=/opt/tmp

MYSQL_ROOT_PASSWORD=$${mysql_root_password}

MYSQL_DATABASE_NAME=$${mysql_database_name}

MYSQL_USER=$${mysql_user}

MYSQL_PASSWORD=$${mysql_password}

MYSQL_IP_ADDR=$${mysql_server,IP_address}

mkdir -p $LOCAL_TEMP

cd $LOCAL_TEMP

wget -qc $SOURCE_URL -O WordPress.tar.gz

tar -zxvf WordPress.tar.gz

rm WordPress.tar.gz

# Install Apache

rpm -ivh apache/libapr1-1.3.3-11.18.19.1.x86_64.rpm

rpm -ivh apache/libapr-util1-1.3.4-12.22.21.2.x86_64.rpm

rpm -ivh apache/apache2-utils-2.2.12-1.38.2.x86_64.rpm

rpm -ivh apache/apache2-2.2.12-1.38.2.x86_64.rpm apache/apache2-prefork-2.2.12-1.38.2.x86_64.rpm

chkconfig apache2 on

service apache2 start

# Install PHP

rpm -ivh php/php53-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php/php53-ctype-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php/php53-dom-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php/php53-iconv-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php/php53-json-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php/php53-tokenizer-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php/php53-xmlreader-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php/php53-xmlwriter-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-gd-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-gettext-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-mbstring-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-pdo-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-mysql-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-zlib-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-pear-5.3.17-0.13.7.x86_64.rpm

rpm -ivh php-suggested/php53-suhosin-5.3.17-0.13.7.x86_64.rpm

rpm -ivh apache2-mod_php53-5.3.17-0.13.7.x86_64.rpm

service apache2 restart

# Install Wordpress

tar -zxvf wordpress-4.9.7.tar.gz -C /srv/www/htdocs

cd /srv/www/htdocs/wordpress

mv wp-config-sample.php wp-config.php

sed -i s/database_name_here/$MYSQL_DATABASE_NAME/ /srv/www/htdocs/wordpress/wp-config.php

sed -i s/username_here/$MYSQL_USER/ /srv/www/htdocs/wordpress/wp-config.php

sed -i s/password_here/$MYSQL_PASSWORD/ /srv/www/htdocs/wordpress/wp-config.php

sed -i s/localhost/$MYSQL_IP_ADDR/ /srv/www/htdocs/wordpress/wp-config.php

sleep 3m

service apache2 restart

MySQL安装脚本

#!/bin/bash

SOURCE_URL=$${mysql_source_url}

LOCAL_TEMP=/opt/tmp

MYSQL_ROOT_PASSWORD=$${mysql_root_password}

MYSQL_DATABASE_NAME=$${mysql_database_name}

MYSQL_USER=$${mysql_user}

MYSQL_PASSWORD=$${mysql_password}

MYSQL_IP_ADDR=localhost

mkdir -p $LOCAL_TEMP

cd $LOCAL_TEMP

wget -qc $SOURCE_URL -O mysql.tar.gz

tar -zxvf mysql.tar.gz

rm mysql.tar.gz

# Install MySQL, create wordpress database and user

rpm -ivh mysql/mysql-client-5.5.31-0.7.10.x86_64.rpm

rpm -ivh mysql/mysql-5.5.31-0.7.10.x86_64.rpm

chkconfig mysql on

service mysql start

mysqladmin -u root password $MYSQL_ROOT_PASSWORD

mysql -uroot -p$MYSQL_ROOT_PASSWORD -e "CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE_NAME};GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE_NAME}.* TO '${MYSQL_USER}'@'localhost' IDENTIFIED BY '${MYSQL_PASSWORD}';GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE_NAME}.* TO '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';FLUSH PRIVILEGES;"

service mysql restart

配置操作
操作步骤

导入WordPress的RTS模板

  1. 使用浏览器,以VDC管理员或代维管理员帐号登录ManageOne。

    非B2B场景登录地址:https://控制台主页的访问地址。例如,https://console.demo.com。

    B2B场景登录地址:https://租户的访问地址。例如,https://tenant.demo.com。

  2. 在导航栏左上角下拉框选择地域和Project。
  3. 选择“控制台 > 管理与部署 > vAPP”。
  4. 在左树菜单选择“vAPP模板 > 我的模板”,单击“导入模板”。
  5. 进入模板导入页面,导入提前准备好的RTS模板。
  6. 单击“导入”。

创建WordPress的vAPP产品

  1. 选择刚刚导入的RTS模板,单击“创建产品”。
  2. 填写产品名称,并根据环境信息填写模板参数。
  3. 单击“提交产品”。

发布并上线vAPP产品

  1. 选择“VDC > 产品管理 ”。
  2. 在左树菜单选择“管理与部署 > vAPP”。
  3. 在刚刚创建的vAPP产品处,单击“发布产品”。
  4. 在弹出的“发布设置”对话框中,设置可见范围和审批流程。
  5. 设置完成后,单击“确定”。
  6. 单击已发布的vAPP产品的“上线”。

申请vAPP实例

  1. 选择“控制台 > 管理与部署 > vAPP”。
  2. 在左树菜单选择“vAPP实例”,单击“申请vAPP”。
  3. 选择刚刚发布并上线的产品,单击“立即申请”。
  4. 检查下发的参数,确认无误后单击“提交申请”。

服务调测

通过ELB访问Web应用

本示例通过脚本自动将Web应用部署到Apache中,用户可以通过ELB访问Web页面。

  1. 选择本样例中创建的ELB,在浏览器中访问http://ELB的弹性IP:ELB的前端端口/wordpress,进入WordPress注册页面,表示Apache安装成功,WordPress应用启动正常。

  2. 配置好用户信息后,单击“安装”。

  3. 安装成功后,单击“登录”,进入WordPress登录页面。

  4. 单击“登录”,进入WordPress管理页面。

FAQ

vAPP实例云服务器无法正常下载到软件源云服务器上的软件包

vAPP实例云服务器无法正常下载到软件源云服务器上的软件包:

  • 确保vAPP实例云服务器和软件源云服务器所在网络可互通。
  • 确保脚本参数中正确配置软件源云服务器的内网IP地址。
  • 确保安全组出方向和入方向规则已全放通。
上传软件到软件源云服务器时传输过程意外终止

上传软件到软件源云服务器时传输过程意外终止:

  • 确保软件源云服务器存放软件的目录有读写权限。
  • 确保软件源云服务器上有足够的空间存放相关软件,如果空间不足需清理磁盘文件或者更换软件存储位置。
软件安常见问题

软件安装常见问题:

  • Apache、WordPress以及MySQL的版本安装必须跟操作系统匹配。
  • 确认Apache、WordPress以及MySQL的软件包是否上传到软件源云服务器并可以成功下载。
  • 确认WordPress服务器以及弹性云服务器磁盘大小是否合理配置。

附件

  • WordPress RTS模板(内置脚本)文件:

{

"heat_template_version": "2013-05-23",

"description": "",

"parameter_groups": [

{

"label": "WordPress服务器基本配置",

"description": "弹性云服务器的基本信息,包括名称、可用分区、镜像、规格、系统盘等信息。",

"parameters": [

"web1ServerName",

"web2ServerName",

"availabilityZone",

"imageId",

"flavor",

"volumeSize",

"volumeType",

"wordPressSourceUrl",

]

},

{

"label": "网络配置",

"description": "网络配置信息。",

"parameters": [

"serverPortNetwork",

"eipExternalNet"

]

},

{

"label": "负载均衡配置",

"description": "弹性负载均衡参数信息",

"parameters": [

"lbAlgorithm",

"protocol",

"listenerProtocolPort",

"memberProtocolPort",

"healthMonitorType"

]

},

{

"label": "MySQL服务器配置",

"description": "安装MySQL数据库的参数信息。",

"parameters": [

"dbServerName",

"mysqlSourceUrl",

"dbRootPassword",

"mysqlDatabaseName",

"mysqlUser",

"mysqlPassword"

]

}

],

"parameters": {

"dbServerName": {

"description": "用于部署数据库的服务器的名称。",

"label": "数据库服务器名称",

"default": "vAPP_ecs_MySQL",

"type": "string"

},

"eipExternalNet": {

"description": "弹性IP对应的外部网络名称或者ID。",

"label": "弹性IP的外部网络",

"type": "string"

},

"web1ServerName": {

"description": "WordPress服务器1的名称。",

"label": "云服务器名称",

"default": "vAPP_ecs_WordPress1",

"type": "string"

},

"web2ServerName": {

"description": "WordPress服务器2的名称。",

"label": "云服务器名称",

"default": "vAPP_ecs_WordPress2",

"type": "string"

},

"availabilityZone": {

"description": "指在同一地域下,电力、网络隔离的物理区域,可用分区之内内网互通,不同可用分区之间物理隔离。",

"label": "可用分区",

"type": "string"

},

"imageId": {

"description": "用于创建系统盘的镜像ID。",

"label": "镜像",

"type": "string"

},

"flavor": {

"description": "服务器的规格,包括内存、CPU、磁盘类型等信息。",

"label": "规格",

"type": "string"

},

"volumeSize": {

"description": "服务器的系统盘大小,以GB为单位。该值应大于或等于镜像的大小。",

"label": "系统盘大小",

"constraints": [

{

"range": {

"min": 1,

"max": 32768

},

"description": "取值范围1-32768之间。"

}

],

"type": "number"

},

"volumeType": {

"description": "服务器的系统盘类型。",

"label": "磁盘类型",

"type": "string"

},

"serverPortNetwork": {

"description": "服务器的网卡所属网络。",

"label": "网卡",

"type": "string"

},

"dbRootPassword": {

"description": "MySQLroot用户的密码。",

"label": "MySQL数据库root用户密码",

"hidden": true,

"type": "string"

},

"mysqlDatabaseName": {

"description": "WordPress使用的数据库名称。",

"label": "数据库名称",

"default": "wordpress",

"constraints": [

{

"length": {

"min": 1,

"max": 64

},

"description": "必须介于1到64个字符之间。"

},

{

"allowed_pattern": "^[a-zA-Z][a-zA-Z0-9]*$",

"description": "必须以字母开头,并且只包含字母数字字符。"

}

],

"type": "string"

},

"mysqlUser": {

"description": "通过WordPress访问数据库时使用的用户名。",

"label": "MySQL用户名称",

"default": "wordpress",

"constraints": [

{

"length": {

"min": 1,

"max": 64

},

"description": "必须介于1到64个字符之间。"

},

{

"allowed_pattern": "^[a-zA-Z][a-zA-Z0-9]*$",

"description": "必须以字母开头,并且只包含字母数字字符。"

}

],

"type": "string"

},

"mysqlPassword": {

"description": "通过WordPress访问数据库的登录密码。",

"label": "MySQL用户密码",

"hidden": true,

"type": "string"

},

"wordPressSourceUrl": {

"description": "WordPress安装包的下载地址。(例如:http://XX.XX.XX.XX/packages/sles/11/x86_64/wordpress/apache22_php53_wordpress49.tar.gz)",

"label": "WordPress下载地址",

"type": "string"

},

"mysqlSourceUrl": {

"description": "MySQL安装包的下载地址。(例如:http://XX.XX.XX.XX/packages/sles/11/x86_64/mysql/mysql-5.5.31-0.7.10.x86_64.tar.gz)",

"label": "MySQL下载地址",

"type": "string"

},

"lbAlgorithm": {

"type": "string",

"description": "该算法用于在池的成员之间分配负载。取值范围:ROUND_ROBIN, LEAST_CONNECTIONS, SOURCE_IP,分别表示轮询算法,最少连接,源IP算法。",

"label": "分配策略类型",

"constraints": [

{

"allowed_values": [

"ROUND_ROBIN",

"LEAST_CONNECTIONS",

"SOURCE_IP"

]

}

],

"default": "ROUND_ROBIN"

},

"protocol": {

"type": "string",

"description": "监听器的协议,支持TCP和HTTP,其取值必须与OS::Neutron::LBaaS::Listener.protocol保持一致。",

"label": "监听协议号",

"constraints": [

{

"allowed_values": [

"HTTP",

"TCP"

]

}

],

"default": "HTTP"

},

"listenerProtocolPort": {

"type": "number",

"description": "监听端口,取值范围[0, 65535],protocol为TCP时,protocol_port范围为[0-65535];protocol为HTTP时,protocol_port范围为[1-65535]。",

"label": "监听端口",

"constraints": [

{

"range": {

"min": 0,

"max": 65535

},

"description": "取值范围0-65535。"

}

]

},

"memberProtocolPort": {

"type": "number",

"description": "后端端口号,取值范围[0, 65535],端口0只在DR模式下有效。",

"label": "后端端口号",

"constraints": [

{

"range": {

"min": 0,

"max": 65535

},

"description": "取值范围0-65535。"

}

]

},

"healthMonitorType": {

"type": "string",

"description": "检查类型,可以为PING,TCP,HTTP,HTTPS。这里PING只在DR模式下有效,HTTPS只在非DR模式下有效,listener protocol为TCP时有效。",

"label": "健康检查类型",

"constraints": [

{

"allowed_values": [

"PING",

"TCP",

"HTTP"

]

}

],

"default": "HTTP"

}

},

"resources": {

"web1SysVolume": {

"type": "OS::Cinder::Volume",

"properties": {

"availability_zone": {

"get_param": "availabilityZone"

},

"image": {

"get_param": "imageId"

},

"name": "vAPP_web1Server_sysVolume",

"volume_type": {

"get_param": "volumeType"

},

"size": {

"get_param": "volumeSize"

}

}

},

"web1Server": {

"type": "OS::Nova::Server",

"properties": {

"flavor": {

"get_param": "flavor"

},

"availability_zone": {

"get_param": "availabilityZone"

},

"user_data": {

"get_resource": "web1Server_MultipartMime"

},

"user_data_format": "RAW",

"block_device_mapping_v2": [

{

"boot_index": "0",

"volume_id": {

"get_resource": "web1SysVolume"

}

}

],

"name": {

"get_param": "web1ServerName"

},

"networks": [

{

"port": {

"get_resource": "web1Port"

}

}

]

}

},

"web1Server_MultipartMime": {

"type": "OS::Heat::MultipartMime",

"properties": {

"parts": [

{

"subtype": "x-shellscript",

"type": "text",

"config": {

"get_resource": "Script_web1Server"

},

"filename": "Script_web1Server.sh"

}

]

}

},

"Script_web1Server": {

"type": "OS::Heat::SoftwareConfig",

"properties": {

"config": {

"str_replace": {

"template": {

"Fn::Join": [

"",

[

"#!/bin/bash -v\n",

"SOURCE_URL=source_url\n",

"LOCAL_TEMP=/opt/tmp\n",

"MYSQL_ROOT_PASSWORD=mysql_root_password\n",

"MYSQL_DATABASE_NAME=mysql_database_name\n",

"MYSQL_USER=mysql_user\n",

"MYSQL_PASSWORD=mysql_password\n",

"MYSQL_IP_ADDR=hosts_info\n",

"mkdir -p $LOCAL_TEMP\n",

"cd $LOCAL_TEMP\n",

"wget -qc $SOURCE_URL -O WordPress.tar.gz\n",

"tar -zxvf WordPress.tar.gz\n",

"rm WordPress.tar.gz\n",

"rpm -ivh apache/libapr1-1.3.3-11.18.19.1.x86_64.rpm\n",

"rpm -ivh apache/libapr-util1-1.3.4-12.22.21.2.x86_64.rpm\n",

"rpm -ivh apache/apache2-utils-2.2.12-1.38.2.x86_64.rpm\n",

"rpm -ivh apache/apache2-2.2.12-1.38.2.x86_64.rpm apache/apache2-prefork-2.2.12-1.38.2.x86_64.rpm\n",

"chkconfig apache2 on\n",

"service apache2 start\n",

"rpm -ivh php/php53-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-ctype-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-dom-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-iconv-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-json-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-tokenizer-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-xmlreader-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-xmlwriter-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-gd-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-gettext-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-mbstring-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-pdo-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-mysql-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-zlib-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-pear-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-suhosin-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh apache2-mod_php53-5.3.17-0.13.7.x86_64.rpm\n",

"service apache2 restart\n",

"sleep 10m\n",

"tar -zxvf wordpress-4.9.7.tar.gz -C /srv/www/htdocs\n",

"cd /srv/www/htdocs/wordpress\n",

"mv wp-config-sample.php wp-config.php\n",

"sed -i s/database_name_here/$MYSQL_DATABASE_NAME/ /srv/www/htdocs/wordpress/wp-config.php\n",

"sed -i s/username_here/$MYSQL_USER/ /srv/www/htdocs/wordpress/wp-config.php\n",

"sed -i s/password_here/$MYSQL_PASSWORD/ /srv/www/htdocs/wordpress/wp-config.php\n",

"sed -i s/localhost/$MYSQL_IP_ADDR/ /srv/www/htdocs/wordpress/wp-config.php"

]

]

},

"params": {

"source_url": {

"get_param": "wordPressSourceUrl"

},

"mysql_root_password": {

"get_param": "dbRootPassword"

},

"mysql_database_name": {

"get_param": "mysqlDatabaseName"

},

"mysql_user": {

"get_param": "mysqlUser"

},

"mysql_password": {

"get_param": "mysqlPassword"

},

"hosts_info": {

"get_attr": [

"dbPort",

"fixed_ips",

0,

"ip_address"

]

}

}

}

}

}

},

"web2SysVolume": {

"type": "OS::Cinder::Volume",

"properties": {

"availability_zone": {

"get_param": "availabilityZone"

},

"image": {

"get_param": "imageId"

},

"name": "vAPP_web2Server_sysVolume",

"volume_type": {

"get_param": "volumeType"

},

"size": {

"get_param": "volumeSize"

}

}

},

"web2Server": {

"type": "OS::Nova::Server",

"properties": {

"flavor": {

"get_param": "flavor"

},

"availability_zone": {

"get_param": "availabilityZone"

},

"user_data": {

"get_resource": "web2Server_MultipartMime"

},

"user_data_format": "RAW",

"block_device_mapping_v2": [

{

"boot_index": "0",

"volume_id": {

"get_resource": "web2SysVolume"

}

}

],

"name": {

"get_param": "web2ServerName"

},

"networks": [

{

"port": {

"get_resource": "web2Port"

}

}

]

}

},

"web2Server_MultipartMime": {

"type": "OS::Heat::MultipartMime",

"properties": {

"parts": [

{

"subtype": "x-shellscript",

"type": "text",

"config": {

"get_resource": "Script_web2Server"

},

"filename": "Script_web2Server.sh"

}

]

}

},

"Script_web2Server": {

"type": "OS::Heat::SoftwareConfig",

"properties": {

"config": {

"str_replace": {

"template": {

"Fn::Join": [

"",

[

"#!/bin/bash -v\n",

"SOURCE_URL=source_url\n",

"LOCAL_TEMP=/opt/tmp\n",

"MYSQL_ROOT_PASSWORD=mysql_root_password\n",

"MYSQL_DATABASE_NAME=mysql_database_name\n",

"MYSQL_USER=mysql_user\n",

"MYSQL_PASSWORD=mysql_password\n",

"MYSQL_IP_ADDR=hosts_info\n",

"mkdir -p $LOCAL_TEMP\n",

"cd $LOCAL_TEMP\n",

"wget -qc $SOURCE_URL -O WordPress.tar.gz\n",

"tar -zxvf WordPress.tar.gz\n",

"rm WordPress.tar.gz\n",

"rpm -ivh apache/libapr1-1.3.3-11.18.19.1.x86_64.rpm\n",

"rpm -ivh apache/libapr-util1-1.3.4-12.22.21.2.x86_64.rpm\n",

"rpm -ivh apache/apache2-utils-2.2.12-1.38.2.x86_64.rpm\n",

"rpm -ivh apache/apache2-2.2.12-1.38.2.x86_64.rpm apache/apache2-prefork-2.2.12-1.38.2.x86_64.rpm\n",

"chkconfig apache2 on\n",

"service apache2 start\n",

"rpm -ivh php/php53-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-ctype-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-dom-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-iconv-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-json-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-tokenizer-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-xmlreader-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php/php53-xmlwriter-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-gd-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-gettext-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-mbstring-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-pdo-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-mysql-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-zlib-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-pear-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh php-suggested/php53-suhosin-5.3.17-0.13.7.x86_64.rpm\n",

"rpm -ivh apache2-mod_php53-5.3.17-0.13.7.x86_64.rpm\n",

"service apache2 restart\n",

"sleep 10m\n",

"tar -zxvf wordpress-4.9.7.tar.gz -C /srv/www/htdocs\n",

"cd /srv/www/htdocs/wordpress\n",

"mv wp-config-sample.php wp-config.php\n",

"sed -i s/database_name_here/$MYSQL_DATABASE_NAME/ /srv/www/htdocs/wordpress/wp-config.php\n",

"sed -i s/username_here/$MYSQL_USER/ /srv/www/htdocs/wordpress/wp-config.php\n",

"sed -i s/password_here/$MYSQL_PASSWORD/ /srv/www/htdocs/wordpress/wp-config.php\n",

"sed -i s/localhost/$MYSQL_IP_ADDR/ /srv/www/htdocs/wordpress/wp-config.php"

]

]

},

"params": {

"source_url": {

"get_param": "wordPressSourceUrl"

},

"mysql_root_password": {

"get_param": "dbRootPassword"

},

"mysql_database_name": {

"get_param": "mysqlDatabaseName"

},

"mysql_user": {

"get_param": "mysqlUser"

},

"mysql_password": {

"get_param": "mysqlPassword"

},

"hosts_info": {

"get_attr": [

"dbPort",

"fixed_ips",

0,

"ip_address"

]

}

}

}

}

}

},

"dbSysVolume": {

"type": "OS::Cinder::Volume",

"properties": {

"availability_zone": {

"get_param": "availabilityZone"

},

"image": {

"get_param": "imageId"

},

"name": "vAPP_dbServer_sysVolume",

"volume_type": {

"get_param": "volumeType"

},

"size": {

"get_param": "volumeSize"

}

}

},

"dbServer": {

"type": "OS::Nova::Server",

"properties": {

"flavor": {

"get_param": "flavor"

},

"availability_zone": {

"get_param": "availabilityZone"

},

"user_data": {

"get_resource": "dbServer_MultipartMime"

},

"user_data_format": "RAW",

"block_device_mapping_v2": [

{

"boot_index": "0",

"volume_id": {

"get_resource": "dbSysVolume"

}

}

],

"name": {

"get_param": "dbServerName"

},

"networks": [

{

"port": {

"get_resource": "dbPort"

}

}

]

}

},

"dbServer_MultipartMime": {

"type": "OS::Heat::MultipartMime",

"properties": {

"parts": [

{

"subtype": "x-shellscript",

"type": "text",

"config": {

"get_resource": "Script_dbServer"

},

"filename": "Script_dbServer.sh"

}

]

}

},

"Script_dbServer": {

"type": "OS::Heat::SoftwareConfig",

"properties": {

"config": {

"str_replace": {

"template": {

"Fn::Join": [

"",

[

"#!/bin/bash -v\n",

"SOURCE_URL=source_url\n",

"LOCAL_TEMP=/opt/tmp\n",

"MYSQL_ROOT_PASSWORD=mysql_root_password\n",

"MYSQL_DATABASE_NAME=mysql_database_name\n",

"MYSQL_USER=mysql_user\n",

"MYSQL_PASSWORD=mysql_password\n",

"MYSQL_IP_ADDR=localhost\n",

"mkdir -p $LOCAL_TEMP",

"\n",

"cd $LOCAL_TEMP",

"\n",

"wget -qc $SOURCE_URL -O mysql.tar.gz",

"\n",

"tar -zxvf mysql.tar.gz",

"\n",

"rm mysql.tar.gz",

"\n",

"\n",

"# Install MySQL, create wordpress database and user",

"\n",

"rpm -ivh mysql/mysql-client-5.5.31-0.7.10.x86_64.rpm",

"\n",

"rpm -ivh mysql/mysql-5.5.31-0.7.10.x86_64.rpm",

"\n",

"chkconfig mysql on",

"\n",

"service mysql start",

"\n",

"mysqladmin -u root password $MYSQL_ROOT_PASSWORD",

"\n",

"mysql -uroot -p$MYSQL_ROOT_PASSWORD -e \"CREATE DATABASE IF NOT EXISTS ${MYSQL_DATABASE_NAME};GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE_NAME}.* TO '${MYSQL_USER}'@'localhost' IDENTIFIED BY '${MYSQL_PASSWORD}';GRANT ALL PRIVILEGES ON ${MYSQL_DATABASE_NAME}.* TO '${MYSQL_USER}'@'%' IDENTIFIED BY '${MYSQL_PASSWORD}';FLUSH PRIVILEGES;\"",

"\n",

"\n",

"service mysql restart",

"\n"

]

]

},

"params": {

"source_url": {

"get_param": "mysqlSourceUrl"

},

"mysql_root_password": {

"get_param": "dbRootPassword"

},

"mysql_database_name": {

"get_param": "mysqlDatabaseName"

},

"mysql_user": {

"get_param": "mysqlUser"

},

"mysql_password": {

"get_param": "mysqlPassword"

}

}

}

}

}

},

"web1Port": {

"type": "OS::Neutron::Port",

"properties": {

"network": {

"get_param": "serverPortNetwork"

}

}

},

"web2Port": {

"type": "OS::Neutron::Port",

"properties": {

"network": {

"get_param": "serverPortNetwork"

}

}

},

"dbPort": {

"type": "OS::Neutron::Port",

"properties": {

"network": {

"get_param": "serverPortNetwork"

}

}

},

"lbPort": {

"type": "OS::Neutron::Port",

"properties": {

"network": {

"get_param": "serverPortNetwork"

}

}

},

"floatingIP": {

"type": "OS::Neutron::FloatingIP",

"properties": {

"floating_network": {

"get_param": "eipExternalNet"

}

}

},

"fipAssociation": {

"type": "OS::Neutron::FloatingIPAssociation",

"properties": {

"floatingip_id": {

"get_resource": "floatingIP"

},

"port_id": {

"get_attr": [

"loadbalancer",

"vip_port_id"

]

}

}

},

"loadbalancer": {

"type": "OS::Neutron::LBaaS::LoadBalancer",

"properties": {

"admin_state_up": true,

"name": "lb_WordPress",

"vip_subnet": {

"get_attr": [

"lbPort",

"subnets",

0,

"id"

]

}

}

},

"listener": {

"type": "OS::Neutron::LBaaS::Listener",

"depends_on": "loadbalancer",

"properties": {

"admin_state_up": true,

"name": "listener",

"loadbalancer": {

"get_resource": "loadbalancer"

},

"protocol": {

"get_param": "protocol"

},

"protocol_port": {

"get_param": "listenerProtocolPort"

}

}

},

"pool": {

"type": "OS::Neutron::LBaaS::Pool",

"depends_on": "listener",

"properties": {

"admin_state_up": true,

"name": "pool",

"lb_algorithm": {

"get_param": "lbAlgorithm"

},

"listener": {

"get_resource": "listener"

},

"protocol": {

"get_param": "protocol"

}

}

},

"health_monitor": {

"type": "OS::Neutron::LBaaS::HealthMonitor",

"depends_on": "pool",

"properties": {

"admin_state_up": true,

"delay": 10,

"expected_codes": "200",

"http_method": "GET",

"max_retries": 3,

"pool": {

"get_resource": "pool"

},

"timeout": 20,

"type": {

"get_param": "healthMonitorType"

},

"url_path": "/"

}

},

"pool_member1": {

"type": "OS::Neutron::LBaaS::PoolMember",

"depends_on": "pool",

"properties": {

"admin_state_up": true,

"address": {

"get_attr": [

"web1Port",

"fixed_ips",

0,

"ip_address"

]

},

"pool": {

"get_resource": "pool"

},

"protocol_port": {

"get_param": "memberProtocolPort"

},

"subnet": {

"get_attr": [

"lbPort",

"subnets",

0,

"id"

]

},

"weight": 1

}

},

"pool_member2": {

"type": "OS::Neutron::LBaaS::PoolMember",

"depends_on": "pool",

"properties": {

"admin_state_up": true,

"address": {

"get_attr": [

"web2Port",

"fixed_ips",

0,

"ip_address"

]

},

"pool": {

"get_resource": "pool"

},

"protocol_port": {

"get_param": "memberProtocolPort"

},

"subnet": {

"get_attr": [

"lbPort",

"subnets",

0,

"id"

]

},

"weight": 1

}

}

},

"outputs": {

"dbServerPrivateIP": {

"description": "数据库服务器的私有IP地址。",

"value": {

"get_attr": [

"dbServer",

"first_address"

]

}

},

"wordPressURL": {

"description": "WordPress访问页面。",

"value": {

"str_replace": {

"template": "http://host:port/wordpress",

"params": {

"host": {

"get_attr": [

"floatingIP",

"floating_ip_address"

]

},

"port": {

"get_param": "listenerProtocolPort"

}

}

}

}

}

}

}

翻译
下载文档
更新时间:2019-08-15

文档编号:EDOC1100043090

浏览量:17957

下载量:563

平均得分:
本文档适用于这些产品
相关文档
相关版本
Share
上一页 下一页