使用 Deployment Manager 在 Google Cloud 上自动执行 SAP 部署

Cloud Deployment Manager 是一种可自动创建和管理 Google Cloud 资源的服务,您可用它来自动部署 Google Cloud 基础架构。

对于部分特选的 SAP 解决方案和支持数据库(例如 SAP HANA),Google Cloud 提供了预定义的 Cloud Deployment Manager 配置模板,可用于部署满足 SAP 可支持性要求和最佳做法的 Google Cloud 基础架构。

支持的 SAP 解决方案

Google Cloud 为以下 SAP 解决方案提供 Cloud Deployment Manager 配置:

模板部署的内容

Google Cloud 为 SAP 部署提供的所有 Deployment Manager 模板都可配置或部署以下元素:

  • 一个或多个 Compute Engine 虚拟机
  • 您指定的一个操作系统映像
  • 一个或多个永久性磁盘
  • (可选)您指定用于虚拟机的 Identity and Access Management (IAM) 服务账号
  • SAP 部署所需的 Google Cloud API
  • (可选)每个虚拟机实例的网络标记
  • (可选)每个虚拟机实例的公共 IP 地址
  • 最新版本的 Google Cloud's Agent for SAP

对于 SAP HANA,Deployment Manager 模板还会部署以下内容:

  • 针对 /hana/shared/hanabackup 的存储卷
  • (可选)SAP HANA 系统本身
  • 1 个主实例主机、最多 15 个工作器主机和最多 3 个备用主机(针对具有主机自动故障切换功能的 SAP HANA 横向扩容系统)
  • 1 个 Linux 高可用性集群(针对 SAP HANA 纵向扩容系统)

对于 SAP NetWeaver,Deployment Manager 模板还会部署以下内容:

  • 针对 /sapmnt/usr/sap 的多个存储卷,以及一个交换卷

每个 SAP 部署的 Deployment Manager 文件

SAP 的每个预定义 Deployment Manager 配置都包含下面一组文件:

  • YAML 配置文件 template.yaml
  • Python 模板文件 deployment-type.py,例如 sap_hana.pysap_hana_scaleout.py,sap_nw.py
  • Python 架构文件 deployment-type.py.schema,例如 sap_hana.py.schemasap_hana_scaleout.py.schema,sap_nw.py.schema
  • 至少一个 shell 脚本(startup.shstartup.ps1

您可以在 template.yaml 配置文件中指定 Google Cloud 资源的属性。

完成 template.yaml 配置文件

为 SAP 部署提供的 template.yaml 配置文件符合 Deployment Manager 定义的标准。

为 SAP 提供的配置文件包括主要资源定义,定义后面的注释部分包含使用频率较低的高级属性。以下示例摘自 SAP HANA 的 template.yaml 文件:

resources:
- name: sap_hana
  type: https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/sap_hana/sap_hana.py
  #
  # By default, this configuration file uses the latest release of the deployment
  # scripts for SAP on Google Cloud.  To fix your deployments to a specific release
  # of the scripts, comment out the type property above and uncomment the type property below.
  #
  # type: https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/202103111102/dm-templates/sap_hana/sap_hana.py
  #
  properties:
    instanceName: [VM_NAME]
    instanceType: [MACHINE_TYPE]
    zone: [ZONE]
    subnetwork: [SUBNETWORK]
    linuxImage: family/[IMAGE_FAMILY]
    linuxImageProject: [IMAGE_PROJECT]
    sap_hana_deployment_bucket: [MEDIA_BUCKET]
    sap_hana_sid: [SID]
    sap_hana_instance_number: [INSTANCE_NUMBER]
    sap_hana_sidadm_password: [PASSWORD]
    sap_hana_system_password: [PASSWORD]
    sap_hana_scaleout_nodes: [NUMBER_OF_WORKER_NODES]
    #
    # --- Advanced Options ---
    # The following advanced options are not usually needed. To use an advanced option, remove
    # the comment indicator, #, before the parameter name and specify an appropriate value.
    #
    # networkTag: [TAG]
    #    Adds network tags to your instance. This is useful if you do routing or define
    #    firewall rules by tags. By default, no tags are added to your VM. Multiple tags
    #    can be assigned by separating them with commas
    #
     ...

如需使用高级属性,请移除注释字符 #,并指定属性值。

如需详细了解配置文件,请参阅 Deployment Manager 基础知识

模板版本控制

通过在 YAML 配置文件的 type 属性中指定版本时间戳,您可以控制 SAP 部署使用的 Deployment Manager 模板的版本。

默认情况下,当您下载新的 template.yaml 配置文件时,type 属性指定 latest 作为版本,这意味着您的部署始终使用最新版本的 Deployment Manager 模板。

type 属性后面的注释中,有一种可选的 type 属性规范,其中包含下载 template.yaml 文件时最新可用版本的时间戳。例如:

resources:
- name: sap_hana
  type: https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/sap_hana/sap_hana.py
  #
  # By default, this configuration file uses the latest release of the deployment
  # scripts for SAP on Google Cloud.  To fix your deployments to a specific release
  # of the scripts, comment out the type property above and uncomment the type property below.
  #
  # type: https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/202103111102/dm-templates/sap_hana/sap_hana.py
  #
  properties:
  ...

如果您需要所有部署都使用同一模板版本,请将包含 latesttype 属性规范替换为包含时间戳的 type 属性规范。例如:

resources:
- name: sap_hana
  type: https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/202103111102/dm-templates/sap_hana/sap_hana.py
  properties:
  ...

指定时间戳时,所有部署都使用与指定时间戳对应的 Deployment Manager 模板版本。

您可以在 Google Cloud Console 中查看用于 SAP 部署的 Deployment Manager 模板版本,方法是点击“部署”页面上的部署名称,然后点击部署属性下的展开的配置视图 (Expanded config VIEW)。版本的时间戳显示在 metadata 部分中的 startup-script 之后,如以下示例所示:

metadata:
  items:
  - key: startup-script
    value: curl -s https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/202103111102/dm-templates/sap_hana/startup.sh
      | bash -s https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/202103111102/dm-templates

使用一个配置文件部署多个资源

您可使用一个配置文件部署多个资源,方式是向该文件添加更多资源定义。

对于 SAP 部署,请复制预定义资源的 -nametypeproperties: 部分,然后将其粘贴到下方,创建新的资源定义。

在每个资源定义中,请务必为以下各项指定唯一值:

  • name
  • instanceName

运行部署

可通过发出以下命令开始部署:

gcloud deployment-manager deployments create [DEPLOYMENT-NAME] --config [TEMPLATE-NAME].yaml

如果您希望在实际部署任何 Google Cloud 资源之前先预览部署结果,请在该命令后附加 --preview 标志。

开始部署时,Deployment Manager 会根据 deployment-type.py.schema 文件中包含的定义验证 template.yaml 文件中的规范。如果验证成功,Deployment Manager 将使用 template.yamldeployment-type.py 文件中的资源定义来创建 Google Cloud 资源。

Deployment Manager 处理完成后,Deployment Manager 会在 Cloud Shell 中对它创建的每个资源显示 COMPLETED,并将控制权传递给 Shell 脚本。

Shell 脚本会进一步配置已部署的资源,并在 Cloud Logging 中记录配置进度。直到 Shell 脚本处理完成后,SAP 部署才会完成。

Deployment Manager 还会在 Google Cloud 控制台中的部署页面上创建一个条目,您可在其中找到有关部署的额外详细信息。

模板的高级自定义

除了在 YAML 配置文件中添加虚拟机定义或其他细微更改之外,如果您是高级用户,则还能够以其他方式自定义 Google Cloud 提供的 Deployment Manager 模板,但这样做存在风险。

如果您修改了模板,则您需对修改后的模板负责,包括确保模板是最新的且 Deployment Manager 可对其进行处理。您还需要负责确保修改后的模板部署的 Google Cloud 基础架构和 SAP 系统满足 SAP 和 Google Cloud 的可支持性要求(包括 SAP 要求)。

如果修改 Deployment Manager 模板,还会使 Google Cloud 更难支持您的部署。Cloud Customer Care 中的 SAP 专家熟悉未修改的模板和他们部署的配置,但不熟悉您独特的自定义设置。如果您需要 Google Cloud 支持使用自定义模板的部署或配置,请准备好对您的自定义设置进行说明,而且需等待较长时间,支持请求才能得到解决。

在修改 Google Cloud 针对 SAP 提供的 Deployment Manager 模板之前,请确保您有一个具备相应技能的技术团队,他们可就更改提出建议、评估更改对系统性能的影响,并帮助排查以后可能会出现的问题。如果您没有这样的团队,实现合作伙伴Google Cloud 专业服务的专家可为您提供帮助。

如需进行更改,您需要了解以下内容:

  • 适用于 SAP 产品的 SAP 文档和 SAP 说明中定义的 SAP 可支持性要求。
  • Deployment Manager 及部署、配置和模板的使用方式。请参阅 Deployment Manager 文档
  • Python 或 Shell 脚本语言(具体取决于您所作更改的类型)。

高级自定义的类型

被视为高级自定义设置的修改包括:

  • 部署后脚本中的自定义处理或操作。这是在部署中添加高级自定义设置的推荐方法。
  • 除受支持的 Red Hat Enterprise Linux for SAP 或 SUSE Linux Enterprise Server for SAP 版本之外使用的其他操作系统类型。
  • 对作为模板的一部分提供的后端脚本的修改:
    • Shell 脚本(bash 或 Powershell)。
    • Python 动态配置和架构文件。
  • 对于高可用性部署:
    • Pacemaker 配置设置的自定义。如果您发现缺少特定功能,请在文档页面上提供反馈。
    • 对包含备用节点的 HANA 横向扩容部署的默认模板的更改。

无论您进行哪种类型的更改,都请确保您的更改生成的 SAP 系统在适用于您系统的 SAP 产品文档和 SAP 说明定义的支持范围内。

可自定义的模板文件

Google Cloud 建议您仅对 .yaml 配置文件进行自定义,但您也可以修改其他 Deployment Manager 文件,只要生成的 SAP 系统满足 SAP 可支持性要求即可。

您需要修改哪些文件取决于您需要进行的更改类型。

如需针对您的环境专属的属性值添加额外的验证检查,您可以向 deployment-type.py.schema 文件添加属性定义。

deployment-type.py 文件中,您可以进行如下更改:

  • 针对配置文件中的值添加额外的计算,例如 IP 地址范围或磁盘大小。请注意,更改磁盘大小可能会导致配置不满足 SAP 支持要求,尤其是对 SAP HANA 而言。
  • 添加额外的虚拟机实例元数据。
  • 调整磁盘名称。

下载模板文件

如需下载文件,您可以先将红色斜体文本替换为所需模板的值,然后使用以下命令:

wget https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/template-directory/file-name.py
wget https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/template-directory/file-name.py.schema
wget https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/template-directory/startup.sh
wget https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/template-directory/template.yaml

例如,如果您需要下载 SAP HANA 纵向扩容部署的模板文件,请使用以下命令:

wget https://storage.cloud.google.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/sap_hana/sap_hana.py
wget https://storage.cloud.google.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/sap_hana/sap_hana.py.schema
wget https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/sap_hana/startup.sh
wget https://storage.googleapis.com/cloudsapdeploy/deploymentmanager/latest/dm-templates/sap_hana/template.yaml

使用修改后的模板文件

模板文件修改完成后,将其上传到 Cloud Storage 存储分区或 Web 服务器,并将 template.yaml 和其他文件中的网址更新为文件位置。

部署后脚本

您可以使用部署后脚本执行额外的操作,例如触发 SAP NetWeaver 应用的安装、监控代理等。

建议使用部署后脚本进行自定义部署,因为只有在按照 SAP 可支持性要求配置 Google Cloud 基础架构后,这些脚本才能获得控制权。

如需显示部署后脚本的状态消息,您需要对这些脚本进行编码,将消息写入日志。如需了解详情,请参阅 Cloud Logging 文档

Deployment Manager 写入 Cloud Shell 或本地 Google Cloud CLI 会话的消息中不包含部署后脚本的状态。

获取适用于 SAP 的 Deployment Manager 模板支持

如果您在解决适用于 SAP 的 Deployment Manager 模板问题时需要帮助,请收集所需的诊断信息,并与 Cloud Customer Care 联系。如需查看所需的诊断信息列表,请参阅适用于 SAP 的 Deployment Manager 模板诊断信息