Script auto start SAP HANA when reboot server

by Daniel Pham
Published: Updated:

Script auto start SAP HANA when reboot server. Today I am going to give you a script that can do this.

If you have installed SAP HANA, you will know it is quite difficult and expensive. Every time you reboot the server, you will have to start the programs manually.

I wrote a script to automatically do this.

About script auto start SAP HANA

I have uploaded this script to my personal repository. You can download it at this link.

The script is completely free, before you use it, you need to modify the information to fit your system.

script-auto-start-sap-hana-when-reboot-server
Script auto start SAP HANA when reboot server.

Explain the script

When you read the script, you will see there are 3 main processing functions.

  • f_sap_start_HDB: this function is used to start the database.
  • f_sap_start_instance01 : this function is used to start instance 01. During startup of instance 01, it will request to start instance 02.
  • f_sap_start_instance02: this function is used to start instance 02.

For the f_sap_start_HDB function, after starting it, I use the info command to get the status information of the database. It has the following content.

hdbadm       4563     4545   2.8    5905080    3569264      \_ hdbnameserver
hdbadm       4791     4545   0.8    1455692     189248      \_ hdbcompileserver
hdbadm       4794     4545   0.2    1661012     125584      \_ hdbpreprocessor
hdbadm       4842     4545   1.0    6103436    3496388      \_ hdbdocstore -port 30040
hdbadm       4845     4545   0.7    3712920     964596      \_ hdbdpserver -port 30011
hdbadm       4848     4545  25.5   36272000   33607728      \_ hdbindexserver -port 30003
hdbadm       4851     4545   0.8    3942948    1052924      \_ hdbxsengine -port 30007
hdbadm       5672     4545   0.2    2688232     241040      \_ hdbdiserver -port 30025
hdbadm       5675     4545   0.3    2972728     312312      \_ hdbwebdispatcher

I will count the string in the status of the database, if there are 9 keywords that I have defined, the database has successfully started. Conversely, if the database starts to fail.

Next, the f_sap_start_instance01 function will read the return value of the f_sap_start_HDB function, if it is true, it will start instance 01, if it is false, exit the program.

And I also do the same thing with the status information of instance 01, if it returns true then it will start instance 02. otherwise exit the script.

How to use the script to auto start SAP HANA

First, download the script to your server with the following command.

sudo wget https://gitlab.com/Danny_Pham/WriteBash.com/raw/master/Utilities/11-Script_automatically_start_SAP_HANA_when_reboot_server.sh

Next, you change the information needed to match your system.

You then move the script to the local bin directory and assign the execution permissions.

sudo mv 11-Script_automatically_start_SAP_HANA_when_reboot_server.sh /usr/local/bin/SAPAutoStart.sh
sudo chmod 700 /usr/local/bin/SAPAutoStart.sh

And then you create the file systemd for this script so it can automatically execute the script every time the server reboots.

sudo nano /etc/systemd/system/SAPAutoStart.service

Copy the following content to this file.

[Unit]
After=network.target

[Service]
ExecStartPre=/bin/sleep 30
ExecStart=/usr/local/bin/SAPAutoStart.sh

[Install]
WantedBy=default.target

And finally, you reload the daemon and enable the script.

sudo systemctl daemon-reload && sudo systemctl enable SAPAutoStart

Conclusion

I tested the script on my SAP HANA server. It takes about 10 minutes to start the SAP program successfully. In case of a failed startup, the script will exit; You will have to check and launch it manually. Hope this script is helpful for you.

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating

You may also like

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.

SUPPORT US

FOLLOW US

Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

2
0
Would love your thoughts, please comment.x
()
x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.