WriteBash - 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.
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.
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.
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
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.If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.