Skip to content

aws-samples/automate-sap-hana-high-availability-test

Automate SAP HANA High Availability Test on AWS

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0

This is an open source repo with sample code to automate the High Availability testing for SAP HANA. This can be either run alone or integrated with the previous solution provided by this team Install SAP With Jenkins and Ansible.

SAP Software covered with this code:

  • SAP HANA - SAP In-Memory Database - verion 1909 - running on RedHat

You can check more details on how to use this repo on this blog post:

In the end of the execution, this solution generates an HTML report presenting all the finds and successes/failures of the run. Example below:

Pre requirements for running this code

  1. One SAP landscape comprised of:
    1. Two SAP HANA instances with High Availability (HA) previously configured.
    2. One SAP ASCS instance
    3. One SAP PAS instance
  2. One AWS IAM Role with the following permissions configured on your local AWS CLI:
    1. ec2:StartInstances on all instances
    2. ec2:RebootInstances on all instances
    3. ec2:StopInstances on all instances
  3. Capture a snapshot of each of the instances you’re involving in this scenario.

Actions performed by this code in your SAP HANA servers

This code will run several commands in your SAP HANA servers to test its High Availability configuration state. They are listed below:

  1. HANA - READ commands
    1. crm_mon -A1
    2. HDB proc
    3. hdbnsutil -sr_state
    4. hdbsql -i "instance number" -u "system user" -p "system user password" -d SYSTEMDB -m SELECT 1 from users
    5. hdbuserstore list
    6. python systemReplicationStatus.py
    7. sapcontrol -nr "instance number" -function GetProcessList
  2. HANA - WRITE commands
    1. echo 'b' > /proc/sysrq-trigger
    2. HDB kill -9
    3. HDB start
    4. HDB stop
    5. hdbnsutil -sr_changemode --mode="mode"
    6. hdbsql -i "instance number" -u "system user" -p "system user password" -d SYSTEMDB -m "BACKUP DATA FOR {{ GLOBAL_HANA_SID | upper }} USING FILE ('data_bck')"
    7. hdbsql -i "instance number" -u "system user" -p "system user password" -d SYSTEMDB -m "BACKUP DATA USING FILE ('system_backup')"
    8. kill -9 "pid"
    9. pcs node standby
    10. pcs node unstandby
  3. ASCS - READ commands
    1. sapcontrol -nr "instance number" -function EnqGetStatistic
  4. PAS - READ commands
    1. R3trans -d
  5. CONTROLLER (locally) - WRITE commands
    1. aws ec2 start-instances --region "region" --instance-ids "crashed instance id"
    2. aws ec2 reboot-instances --region "region" --instance-ids "crashed instance id"

Building a lab environment

If you want to build a lab environment to run this code on, take a look at this two other repos:

  1. Terraform code to spin up a new SAP landscape
  2. Jenkins, Ansible and Terraform to create infrastructure and installation with one click

How to run

  1. Have access to a terminal on a Linux or Mac computer.
  2. Have an AWS CLI configured locally
  3. For each of your servers (HANA Primary, HANA Secondary, ASCS and PAS), update the below information on the file ```hosts.yaml```
    1. ansible_host
    2. ansible_user
    3. ansible_ssh_private_key_file
  4. Open the var_file.yaml and fill in the required information:
Field Default value Comments
Information for HANA
INPUT_HANA_SID AD0 Your HANA SID
INPUT_HANA_INSTANCE_NUMBER 00 Your HANA instance number
INPUT_SYSTEM_USER SYSTEM Username for the SYSTEM default user. This will be used to check if a backup is available before starting the tests
INPUT_SYSTEM_PASSWORD P@ssw0rd Password for the SYSTEM user. This will be used to check if a backup is available before starting the tests
INPUT_HANA_SYNC_MODE SYNC HANA replication mode
Information for ASCS
INPUT_ASCS_SID AD0 Your ASCS SID
INPUT_ASCS_INSTANCE_NUMBER 00 Your ASCS instance number
Information for PAS
INPUT_PAS_SID AD0 Your PAS SID
INPUT_PAS_INSTANCE_NUMBER 00 Your PAS instance number
INPUT_CHECK_R3_TRANS true Whether to check the R3trans command on PAS after database failovers or not
Information for AWS CLI
INPUT_AWS_REGION us east-1 The region where your instances are
INPUT_AWS_CLI_PROFILE default The profile you configured for your AWS CLI on Pre requisites, item 2
INPUT_PRIVATE_SSH_KEY /my path/to/pemFile.pem Path to the SSH key for Ansible to SSH into your instances
  1. And finally, run "how_to_run.sh"

In the end, the generated HTML report will be opened using your default browser automatically.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages