

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

# 使用 AWS 服务监控 SAP RHEL Pacemaker 集群
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services"></a>

*Harsh Thoria、Randy Germann 和 RAVEENDRA Voore，Amazon Web Services*

## Summary
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-summary"></a>

此模式概述了使用亚马逊和 CloudWatch 亚马逊简单通知服务 (Amazon SNS) Simple Notification Service 监控和配置适用于 SAP 应用程序和 SAP HANA 数据库服务的红帽企业 Linux (RHEL) Pacemaker 集群的警报的步骤。

该配置使您能够借助 CloudWatch 日志流、指标筛选器和警报监控 SAP SCS 或 ASCS、入队复制服务器 (ERS) 和 SAP HANA 群集资源处于 “已停止” 状态时。Amazon SNS 会向基础设施或 SAP Basis 团队发送电子邮件，告知已停止集群的状态。

您可以使用 AWS CloudFormation 脚本或 AWS 服务控制台为此模式创建 AWS 资源。此模式假设您使用的是控制台；它不提供 CloudFormation 脚本或涵盖 CloudWatch 和 Amazon SNS 的基础设施部署。Pacemaker 命令用于设置集群提醒配置。

## 先决条件和限制
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-prereqs"></a>

**先决条件**
+ 一个活跃的 AWS 账户。
+ Amazon SNS 设置为发送电子邮件或移动通知。
+  ASCS/ERS 适用于 ABAP 或 SCS/ERS Java 的 SAP，以及 SAP HANA 数据库 RHEL Pacemaker 集群。有关说明，请参阅：
  + [SAP HANA 集群设置](https://docs.aws.amazon.com/sap/latest/sap-hana/sap-hana-on-aws-manual-deployment-of-sap-hana-on-aws-with-high-availability-clusters.html)
  + [SAP Netweaver 集群设置 ABAP/Java ](https://docs.aws.amazon.com/sap/latest/sap-netweaver/sap-netweaver-ha-configuration-guide.html)

**限制**
+ 此解决方案目前适用于 RHEL 版本 7.3 及更高版本的基于 Pacemaker 的集群。尚未在 SUSE 操作系统上测试过。

**产品版本**
+ RHEL 7.3 及更高版本

## 架构
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-architecture"></a>

**目标技术堆栈**
+ RHEL Pacemaker 提醒事件驱动型代理
+ 亚马逊弹性计算云（亚马逊 EC2）
+ CloudWatch 警报
+ CloudWatch 日志组和指标筛选器
+ Amazon SNS

**目标架构**

下图显示了此解决方案的组件和工作流。

![\[用于监控 SAP RHEL Pacemaker 集群的架构\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/images/pattern-img/ca4d282e-eadd-43fd-8506-3dbeb43e4db6/images/bfc96678-1fd3-47b6-8f09-bf7cf7c4a92c.png)


**自动化和扩展**
+ 您可以使用 CloudFormation 脚本自动创建 AWS 资源。还可以使用其他指标筛选器来扩展和覆盖多个集群。

## 工具
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-tools"></a>

**AWS 服务**
+ [Amazon CloudWatch](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) 可帮助您实时监控您的 AWS 资源和运行的应用程序 AWS 的指标。
+  [Amazon Simple Notification Service（Amazon SNS）](https://docs.aws.amazon.com/sns/latest/dg/welcome.html)可帮助您协调和管理发布者与客户端（包括 Web 服务器和电子邮件地址）之间的消息交换。

**工具**
+ CloudWatch agent（unified）是一种工具，用于从 EC2 实例收集系统级指标、日志和跟踪，并从您的应用程序中检索自定义指标。
+ Pacemaker 提醒代理（适用于 RHEL 7.3 及更高版本）可在 Pacemaker 集群中发生变化（例如资源停止或重新启动）时触发操作。

## 最佳实践
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-best-practices"></a>
+ 有关在上使用 SAP 工作负载的最佳实践 AWS，请参阅 Well-Architecte AWS d Framework 的 [SAP 镜头](https://docs.aws.amazon.com/wellarchitected/latest/sap-lens/sap-lens.html)。
+ 考虑为 SAP HANA 集群设置 CloudWatch 监控所涉及的成本。有关详情，请参阅 [CloudWatch 文档](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_billing.html)。
+ 考虑使用寻呼机或工单机制处理 Amazon SNS 提醒。
+ 请务必查看 P **C**、Pacemaker 和围栏代理的 RPM 软件包的 RHEL 高可用性 (HA) 版本。 AWS 

## 操作说明
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-epics"></a>

### 设置 Amazon SNS
<a name="set-up-sns"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 创建一个 SNS 主题。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html) | AWS 管理员 | 
| 修改 SNS 主题的访问策略。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html) | AWS 系统管理员 | 
| 订阅 SNS 主题。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html)您的 Web 浏览器将显示来自 Amazon SNS 的确认响应。 | AWS 系统管理员 | 

### 确认集群的设置
<a name="confirm-the-setup-of-the-cluster"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 检查集群状态。 | 使用 **pcs status** 命令确认资源处于联机状态。 | SAP Basis 管理员 | 

### 配置 Pacemaker 提醒
<a name="configure-pacemaker-alerts"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 在主集群实例上配置 Pacemaker 提醒代理。 | 登录主集群中的 EC2 实例并运行以下命令：<pre>install --mode=0755 /usr/share/pacemaker/alerts/alert_file.sh.sample<br />touch /var/lib/pacemaker/alert_file.sh<br />touch /var/log/pcmk_alert_file.log<br />chown hacluster:haclient /var/log/pcmk_alert_file.log<br />chmod 600 /var/log/pcmk_alert_file.log<br />pcs alert create id=alert_file description="Log events to a file." path=/var/lib/pacemaker/alert_file.sh<br />pcs alert recipient add alert_file id=my-alert_logfile value=/var/log/pcmk_alert_file.log</pre> | SAP Basis 管理员 | 
| 在辅助集群实例上配置 Pacemaker 提醒代理。 | 登录辅助群集中的辅助群集 EC2 实例并运行以下命令：<pre>install --mode=0755 /usr/share/pacemaker/alerts/alert_file.sh.sample<br />touch /var/lib/pacemaker/alert_file.sh<br />touch /var/log/pcmk_alert_file.log<br />chown hacluster:haclient /var/log/pcmk_alert_file.log<br />chmod 600 /var/log/pcmk_alert_file.log</pre> | SAP Basis 管理员 | 
| 确认 RHEL 提醒资源已创建。 | 使用以下命令验证是否已创建提醒资源：<pre>pcs alert</pre>命令的输出将如下所示：<pre>[root@xxxxxxx ~]# pcs alert <br />Alerts:<br /> Alert: alert_file (path=/var/lib/pacemaker/alert_file.sh)<br />  Description: Log events to a file.<br />  Recipients:<br />   Recipient: my-alert_logfile (value=/var/log/pcmk_alert_file.log)</pre> | SAP Basis 管理员 | 

### 配置代 CloudWatch 理
<a name="configure-the-cw-agent"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 安装代 CloudWatch 理。 | 有几种方法可以在 EC2 实例上安装 CloudWatch 代理。使用命令行：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html)有关详情，请参阅 [CloudWatch 文档](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-EC2-Instance.html)。 | AWS 系统管理员 | 
| 将 IAM 角色附加到 EC2 实例。 | 要使 CloudWatch 代理能够从实例发送数据，您必须将 IAM **CloudWatchAgentServerRole**角色附加到每个实例。或者，您可以将 CloudWatch 代理策略添加到现有的 IAM 角色中。有关详情，请参阅 [CloudWatch 文档](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent-commandline.html)。 | AWS 管理员 | 
| 将 CloudWatch 代理配置为监视主群集实例上的 Pacemaker 警报代理日志文件。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html) | AWS 管理员 | 
| 在主群集和辅助群集实例上启动 CloudWatch 代理。 | 要启动代理，请在主群集和辅助群集中的 EC2 实例上运行以下命令：<pre>sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m<br />ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json</pre> | AWS 管理员 | 

### 设置 CloudWatch 资源
<a name="set-up-cw-resources"></a>


| Task | 说明 | 所需技能 | 
| --- | --- | --- | 
| 设置 CloudWatch 日志组。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html) CloudWatch 代理会将 Pacemaker 警报文件作为 CloudWatch 日志流传输到日志组。 | AWS 管理员 | 
| 设置 CloudWatch 指标筛选条件。 | 指标筛选器可帮助您搜索模式，例如`stop <cluster-resource-name>`在 CloudWatch 日志流中。识别出此模式后，指标筛选器会更新自定义指标。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html)当指标筛选器在步骤 4 中识别出模式时，它会将 CloudWatch 自定义指标的值更新`sapcluster_abc`为 **1**。 CloudWatch 警报会`SAP-Cluster-QA1-ABC`监控该指标，`sapcluster_abc`并在指标值变为 **1** 时发出 SNS 通知。这表示集群资源已停止，需要采取措施。 | AWS 管理员、SAP Basis 管理员 | 
| 为 SAP ASCS/SCS 和 ERS CloudWatch 指标设置指标警报。 | 根据单个指标创建警报：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html) | AWS 管理员 | 
| 为 SAP HANA CloudWatch 指标设置指标警报。 | 重复上一个任务中设置 CloudWatch 指标警报的步骤，并进行以下更改：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html) | AWS 管理员 | 

## 相关资源
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-resources"></a>
+ [集群事件的触发脚本](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html-single/high_availability_add-on_reference/index#ch-alertscripts-HAAR)（RHEL 文档）
+ 使用@@ [向导创建 CloudWatch 代理配置文件](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html)（CloudWatch 文档）
+ 在@@ [服务器上安装和运行 CloudWatch 代理](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html)（CloudWatch 文档）
+ [基于静态阈值创建 CloudWatch 警报](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ConsoleAlarms.html)（CloudWatch 文档）
+ 使用@@ [高可用性集群在 AWS HANA 上手动部署 SAP HANA（ AWS 网站上有](https://docs.aws.amazon.com/sap/latest/sap-hana/sap-hana-on-aws-manual-deployment-of-sap-hana-on-aws-with-high-availability-clusters.html) SAP 文档）
+ [SAP NetWeaver 指南](https://docs.aws.amazon.com/sap/latest/sap-netweaver/welcome.html)（ AWS 网站上有 SAP 文档）

## 附件
<a name="attachments-ca4d282e-eadd-43fd-8506-3dbeb43e4db6"></a>

要访问与此文档相关联的其他内容，请解压以下文件：[attachment.zip](samples/p-attach/ca4d282e-eadd-43fd-8506-3dbeb43e4db6/attachments/attachment.zip)