Asponte Labs > Blog Detail

Web Content Viewer- Asponte Custom Skin

Actions

Managing WebSphere Portal using systemd

  • Created By: Ryan Mullett
  • Updated: January 26, 2017
  • Tags: portal, websphere

Background

Anyone who has done admin work on a Linux system in the past few years knows that for 99% of installs today you will be using an OS that has replaced the traditional init system with systemd. While this can allow for more control in some instances, it is also more work to get up and running than just dropping an init script for startup procedures on a server. This leaves us having to not only write a startup script, but to also create a service in order to go the officially supported route and startup the way that RedHat and many others recommend. While systemd is technically backwards compatible with init scripts, systemd does not observe numbering of the scripts which can lead to dependency issues and failed script startups (not something we are looking to touch for our Portal!).

 

The Script

For this blog, I am using the same setup I had for my post on changing the portal hostname of a contained cluster. This mean I have a seld-contained cluster all on the same host with DB2/DMGR/IHS/Portal all on the same system. The script will likely need to be modified to fit into a new environment, and I have had to make small tweaks here and there removing and adding sections based on what I am running on a system. This script should be dropped in /usr/local/sbin/portalsystem.sh and the PASSWORD variable unfortunately will need to be changed to your password for your WAS environment. Running the script will require you to pass in start/stop/restart depending on what you want to do.

#! /bin/bash
WAS_HOME="/opt/IBM/WebSphere/AppServer"
WAS_PROFILE_NAME="dmgr01"
WAS_APP_SERVER="WebSphere_Portal"
#WAS_WEB_SERVER="webserver1"
PORTAL_HOME="/opt/IBM/WebSphere/wp_profile/"
USERNAME="admin"
PASSWORD="password"

start() {

#start db2 instances
for i in `/opt/ibm/db2/V10.5/bin/db2ilist`;
do
 su - $i -c "db2start"
done

"${WAS_HOME}/profiles/${WAS_PROFILE_NAME}/bin/startManager.sh"
"${PORTAL_HOME}/bin/startNode.sh"
"${PORTAL_HOME}/bin/startServer.sh" WebSphere_Portal

#Start IHS Instance
/opt/IBM/HTTPServer/bin/apachectl -k start
}

stop() {
#stop IHS Instance
/opt/IBM/HTTPServer/bin/apachectl -k stop

"${WAS_HOME}/profiles/${WAS_PROFILE_NAME}/bin/stopManager.sh" -username $USERNAME -password $PASSWORD
"${PORTAL_HOME}/bin/stopServer.sh" WebSphere_Portal -username $USERNAME -password $PASSWORD
"${PORTAL_HOME}/bin/stopNode.sh" -username $USERNAME -password $PASSWORD

#stop db2 instances
for i in `/opt/ibm/db2/V10.5/bin/db2ilist`;
do

 su - $i -c "db2stop"

done

}

#restart IHS/DB2/DMGR/Portal
restart(){
stop
start
}

case $1 in
        start|stop|restart) "$1" ;;
esac

The Service

Once you have confirmed that your script is able to start/stop/restart your portal environment, you can move onto creating the actual Daemon that will control portal. We want to put this file in /etc/systemd/system/websphere.service.

[Unit]
Description=IBM Portal Cluster
 
[Service]
Type=oneshot
ExecStart=/usr/local/sbin/portalsystem.sh start
ExecStop=/usr/local/sbin/portalsystem.sh stop
ExecReload=/usr/local/sbin/portalsystem.sh restart
User=root
RemainAfterExit=yes
 
[Install]
WantedBy=default.target

Once you have this setup, you can control WebSphere using systemctl start websphere. If you want to run Portal at startup you can utilize systemctl enable websphere which will automatically run the websphere.service at startup and start your WebSphere service.

Complementary Content
${loading}