

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用开源工具自动安装 SAP 系统
<a name="install-sap-systems-automatically-by-using-open-source-tools"></a>

*Guilherme Sesterheim，Amazon Web Services*

## Summary
<a name="install-sap-systems-automatically-by-using-open-source-tools-summary"></a>

此模式介绍了如何使用开源工具创建以下资源，以自动安装 SAP 系统：
+ SAP S/4HANA 1909 数据库
+ 一个 SAP ABAP 中央服务 (ASCS) 实例
+ 一个 SAP 主应用程序服务器 (PAS) 实例

HashiCorp Terraform 创建 SAP 系统的基础架构，Ansible 配置操作系统 (OS) 并安装 SAP 应用程序。Jenkins 运行安装。

这种设置将 SAP 系统的安装变成了可重复的过程，有助于提高部署效率和质量。

**注意**  
此模式中提供的示例代码适用于高可用性（HA）系统和非高可用性系统。

## 先决条件和限制
<a name="install-sap-systems-automatically-by-using-open-source-tools-prereqs"></a>

**先决条件**
+ 一个有效的 Amazon Web Services account
+ 包含所有 SAP 媒体文件的 Amazon Simple Storage Service (Amazon S3) 存储桶
+ 具有[访问密钥和私有密钥](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html)、并有以下权限的 AWS Identity and Access Management (IAM) 主体：
  + **只读权限：**Amazon Route 53、AWS Key Management Service (AWS KMS)
  + **读写权限：**亚马逊 S3、亚马逊弹性计算云（亚马逊）、亚马逊弹性文件系统（亚马逊 EFS EC2）、IAM、亚马逊、亚马逊 CloudWatch、亚马逊 DynamoDB
+ Route 53 [私有托管区域](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html)
+ 在 Amazon Marketplace 中订阅 [Red Hat Enterprise Linux for SAP with HA and Update Services 8.2](https://aws.amazon.com/marketplace/pp/prodview-5grz5a5thx7c2) 亚马逊机器映像（AMI）
+ [AWS KMS 客户托管密钥](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html#aws-managed-customer-managed-keys)
+ [Secure Shell (SSH) 密钥对](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)
+ 一个 [Amazon EC2 安全组](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-security-groups.html)，允许从你安装 Jenkins 的主机名在端口 22 上进行 SSH 连接（主机名很可能是**本地主**机）
+  HashiCorp 已安装和@@ [配置的 Vagrant](https://www.vagrantup.com/)
+ [VirtualBox](https://www.virtualbox.org/)由 Oracle 安装和配置
+ 熟悉 Git、Terraform、Ansible 以及 Jenkins

**限制**
+ 仅 SAP S/4HANA 1909 针对此特定场景进行了全面测试。如果您使用其他版本的 SAP HANA，则需要修改此模式中的示例 Ansible 代码。
+ 此模式中的示例程序适用于 Mac OS 和 Linux 操作系统。部分命令只能在基于 Unix 的终端中运行。但是，您可通过使用不同的命令和 Windows 操作系统，以获得类似的结果。

**产品版本**
+ SAP S/4HANA 1909
+ Red Hat Enterprise Linux (RHEL) 8.2 或更高版本

## 架构
<a name="install-sap-systems-automatically-by-using-open-source-tools-architecture"></a>

下图介绍了使用开源工具在 Amazon Web Services account 中自动安装 SAP 系统的示例工作流：

![使用开源工具在 AWS 账户中自动安装 SAP 系统的示例工作流。](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/aaf11dac-38cc-4e89-be86-51d4409cf238/images/d7902f9d-f1be-461f-b69b-cf3c663c8f2f.png)


下图显示了如下工作流：

1. Jenkins 通过运行 Terraform 和 Ansible 代码编排 SAP 系统安装的运行。

1. Terraform 代码构建 SAP 系统基础设施。

1. Ansible 代码配置操作系统和安装 SAP 应用程序。

1. Amazon 实例上安装了 SAP S/4HANA 1909 数据库、ASCS 实例和包含所有已定义先决条件的 PAS 实例。 EC2 

**注意**  
此模式中的示例设置会自动在您的 AWS 账户中创建 Amazon S3 存储桶，以存储 Terraform 状态文件。

**技术堆栈**
+ Terraform
+ Ansible
+ Jenkins
+ SAP S/4HANA 1909 数据库
+ SAP ASCS 实例
+ SAP PAS 实例
+ Amazon EC2 

## 工具
<a name="install-sap-systems-automatically-by-using-open-source-tools-tools"></a>

**AWS 服务**
+ [亚马逊弹性计算云 (Amazon EC2)](https://docs.aws.amazon.com/ec2/?id=docs_gateway) 在 AWS 云中提供可扩展的计算容量。您可以根据需要启动任意数量的虚拟服务器，并快速扩展或缩减它们。
+ [AWS Identity and Access Management (AWS IAM) ](https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html)通过控制验证和授权使用您 AWS 资源的用户，帮助您安全地管理对您 AWS 资源的访问。
+ [AWS Key Management Service (AWS KMS)](https://docs.aws.amazon.com/kms/latest/developerguide/overview.html) 可帮助您创建和控制加密密钥以保护您的数据。
+ [Amazon Virtual Private Cloud (Amazon VPC)](https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html) 可帮助您将 AWS 资源启动到您定义的虚拟网络中。此虚拟网络类似于您在自己的数据中心内运行的传统网络，具有使用 AWS 可扩展基础设施的优势。

**其他工具**
+ [HashiCorp Terraform](https://www.terraform.io/docs) 是一款命令行界面应用程序，可帮助您使用代码来配置和管理云基础架构和资源。
+ [Ansible](https://www.ansible.com/) 是一款开源配置即代码 (CaC) 工具，可帮助实现应用程序、配置和 IT 基础设施的自动化。
+ [Jenkins](https://www.jenkins.io/) 是一款开源自动化服务器，它使开发人员能够构建、测试和部署其软件。

**代码**

此模式的代码可在 GitHub [aws-install-sap-with-jenkins-](https://github.com/aws-samples/aws-install-sap-with-jenkins-ansible) ansible 存储库中找到。

## 操作说明
<a name="install-sap-systems-automatically-by-using-open-source-tools-epics"></a>

### 配置先决条件
<a name="configure-the-prerequisites"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 将您的 SAP 媒体文件添加至 Amazon S3 存储桶。 | [创建包含所有 SAP 媒体文件的 Amazon S3 存储桶](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)。请务必遵守 [Launch Wizard 文档](https://docs.aws.amazon.com/launchwizard/latest/userguide/launch-wizard-sap-software-install-details.html)中 **S/4HANA** 的 AWS Launch Wizard 文件夹层次结构。 | 云管理员 | 
| 安装 VirtualBox。 | [VirtualBox](https://www.virtualbox.org/)由 Oracle 安装和配置。 | DevOps 工程师 | 
| 安装 Vagrant。 | 通过以下方式安装和配置 [Vagrant](https://www.vagrantup.com/)。 HashiCorp | DevOps 工程师 | 
| 配置 Amazon Web Services account。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/install-sap-systems-automatically-by-using-open-source-tools.html) | 常规 AWS | 

### 构建和运行您的 SAP 安装
<a name="build-and-run-your-sap-installation"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 从中克隆代码存储库 GitHub。 | 在上克隆 [aws-install-sap-with-jenkins-an](https://github.com/aws-samples/aws-install-sap-with-jenkins-ansible) sible 存储库。 GitHub | DevOps 工程师 | 
| 启动 Jenkins 服务。 | 打开 Linux 终端。然后，导航至包含克隆代码存储库文件夹的本地文件夹，并运行以下命令：<pre>sudo vagrant up</pre>Jenkins 启动大约需要 20 分钟。成功后，该命令会返回**服务已启动并正在运行**消息。 | DevOps 工程师 | 
| 在 Web 浏览器中打开并登录 Jenkins。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/install-sap-systems-automatically-by-using-open-source-tools.html) | DevOps 工程师 | 
| 配置 SAP 系统安装参数。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/install-sap-systems-automatically-by-using-open-source-tools.html)[See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/install-sap-systems-automatically-by-using-open-source-tools.html)您可根据您的使用案例按需配置其他非必需参数。例如，您可以更改实例的 SAP 系统 ID (SID)、SAP 系统的默认密码、名称和标签。所有必需变量的名称开头都有**（必填）**。 | AWS 系统管理员、 DevOps 工程师 | 
| 运行您的 SAP 系统安装。 | [See the AWS documentation website for more details](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/install-sap-systems-automatically-by-using-open-source-tools.html)有关管道操作步骤的信息，请参阅 AWS Blog 上的[使用开源工具自动化 SAP 安装](https://aws.amazon.com/blogs/awsforsap/automating-sap-installation-with-open-source-tools/)中的**了解管道操作步骤**部分。如果发生错误，请将光标移至所示红色错误框，然后选择**日志**。显示错误管道操作步骤日志。大多数错误的原因是参数设置不正确。 | DevOps 工程师，AWS 系统管理员 | 

## 相关资源
<a name="install-sap-systems-automatically-by-using-open-source-tools-resources"></a>
+ [DevOps 适用于 SAP — SAP 安装：从 2 个月到 2 小时](https://videos.itrevolution.com/watch/707351918/)（DevOps 企业峰会视频库）