

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 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*

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

此模式概述使用 Amazon CloudWatch 和 Amazon Simple Notification Service (Amazon SNS) 監控和設定適用於 SAP 應用程式和 SAP HANA 資料庫服務的 Red Hat Enterprise Linux (RHEL) Pacemaker 叢集警示的步驟。

組態可讓您在 CloudWatch 日誌串流、指標篩選條件和警示的協助下，監控 SAP SCS 或 ASCS、Enqueue Replication Server (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 會設定 來傳送電子郵件或行動通知。
+ 適用於 ABAP 的 SAP ASCS/ERS 或適用於 Java 的 SCS/ERS，以及 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 及更新版本

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

**目標技術堆疊 **
+ RHEL Pacemaker 警示事件驅動型代理程式
+ Amazon Elastic Compute Cloud (Amazon EC2)
+ CloudWatch 警示
+ CloudWatch 日誌群組和指標篩選條件
+ Amazon SNS

**目標架構 **

下圖說明此解決方案的元件和工作流程。

![\[監控 SAP RHEL Pacemaker 叢集的架構\]](http://docs.aws.amazon.com/zh_tw/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 代理程式 （統一） 是一種工具，可從 EC2 執行個體收集系統層級指標、日誌和追蹤，並從應用程式擷取自訂指標。
+ Pacemaker 警示代理程式 （適用於 RHEL 7.3 和更新版本） 是一種工具，可在發生變更時啟動動作，例如當資源在 Pacemaker 叢集中停止或重新啟動時。

## 最佳實務
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-best-practices"></a>
+ 如需在 上使用 SAP 工作負載的最佳實務 AWS，請參閱 AWS Well-Architected Framework 的 [SAP Lens](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 提醒。
+ 一律檢查 RPM 套件的 RHEL 高可用性 (HA) 版本是否有 **pc**、Pacemaker AWS 和 fencing 代理程式。

## 史詩
<a name="monitor-sap-rhel-pacemaker-clusters-by-using-aws-services-epics"></a>

### 設定 Amazon SNS
<a name="set-up-sns"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 建立 SNS 主題。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/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_tw/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_tw/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>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 檢查叢集狀態。 | 使用 **pcs 狀態**命令來確認資源已上線。 | SAP Basis 管理員 | 

### 設定 Pacemaker 警示
<a name="configure-pacemaker-alerts"></a>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 在主要叢集執行個體上設定 Pacemaker 警示代理程式。 | 登入 pimary 叢集中的 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>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 安裝 CloudWatch 代理程式。 | 有數種方法可在 EC2 執行個體上安裝 CloudWatch 代理程式。若要使用命令列：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/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_tw/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>


| 任務 | Description | 所需的技能 | 
| --- | --- | --- | 
| 設定 CloudWatch 日誌群組。 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/prescriptive-guidance/latest/patterns/monitor-sap-rhel-pacemaker-clusters-by-using-aws-services.html)CloudWatch 代理程式會將 Pacemaker 警示檔案以日誌串流的形式傳輸至 CloudWatch 日誌群組。 | AWS 管理員 | 
| 設定 CloudWatch 指標篩選條件。 | 指標篩選條件可協助您搜尋模式，例如 CloudWatch 日誌串流`stop <cluster-resource-name>`中的 。識別此模式時，指標篩選條件會更新自訂指標。[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/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_tw/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_tw/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 上手動部署 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)( AWS 網站上的 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)