Hello everyone,
today, I want to share 2 scripts that I have written for starting and stopping a 2 Node Forms&Reports 12C Cluster in one-go. This scripts makes our lifes easy, as they provide an automated way of controlling FMW 12C cluster components.
Using these scripts, the admin can start all the services running across 2 nodes with a single command by connecting to a single node.
Using these scripts, an admin can connect to a node (primary node) and start/stop all the Forms&Reports services (including OHS instances, managed server ,admin server etc) with only running one simple command.
In addition to that, I wrote these scripts by taking the dependencies between the components into account. That is, if a component is dependent to another component , that dependent component is started after the component, that it depends on.
Likewise, if a component is dependent on another component, that dependent component is stopped before the component that it depends on.
Before running these script, we configure the ssh equivalency between node1 and node2. The environment that I wrote this script was Solaris and it was very easy to enable the ssh equivalency between the FMW OS users. Anyways, the same method for enabling the ssh equivalency works for Linux as well.
So, we enable ssh equiv. because the scripts connects from node1 to node2 using ssh.
Actually, one way ssh equiv is enough.. (node1 should be able to connect to node2 using ssh --without password)
In addition to that, there is also one other requirement. That is, we create a directory called /<your_mount_point>/startstop_script and put our script files there. (we create this directory both on node1 and node2)
In order to start the services , we use the script called FRMRP_START.sh
For stopping the services, we use the script called FRMRP_STOP.sh
So, we only execute "sh FRMRP_START.sh" command to start all the services. (to start the services both on node1 and node2)
Similarly, we only execute " sh FRMRP_STOP.sh" command to stop all the services. (to stop the services both on node1 and node2)
Pretty handy right? :) We just execute a script , we wait a little and our full WLS stack including High Available Forms and Reports services are started/stopped. no need to remember the nohup commands, no need to create multiple ssh connections, no need to connect to the weblogic console for starting the managed servers, no need to remember the command for starting the ohs instances and so on... no need to spend energy while starting/stopping multiple FMW components across multiple server nodes:)
In order to start all the services (across a 2 node - FMW Forms&Reports 12C cluster)
We connect to node 1 using FMW OS user
We cd to the directory where our scripts are located -> /uo1/startstop_scripts
We execute FRMRP_START.sh
In order to stop all the services (across a 2 node - FMW Forms&Reports 12C cluster)
We connect to node 1 using FMW OS user
We cd to the directory where our scripts are located -> /u01/startstop_scripts
We execute FRMRP_STOP.sh
The codes of the scripts are as follows;
--Note that, the directory paths used in these scripts should be modified according to your env..
Alternatively, the scripts can be enhanced to make use of of env variables or bash script variables rather than using direct directory paths. I was on the field and wrote these scripts there.. I could actually wrote them better to take the direct path dependencies and the ssh equivalency requirements away, but still these scripts are okay and they are already tested & used in a production environment.
Also note that, there are 3 phyton scripts that you will see below. These phyton scripts are internally executed by FRMRP_START.sh and FRMRP_STOP.sh scripts. So these phyton scripts should also be located in the script directory (/<your_mount_point>/startstop_script).
#Set the domain env.
. /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/setDomainEnv.sh
# Starting NodeManager 1 on node1
echo Starting Node Manager 1
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startNodeManager.sh > /tmp/nohup_nodemanager.out 2>&1 &
# Starting NodeManager 2 on node2
echo Starting Node Manager 2
ssh <node2hostname> '/u01/FMWHOME/oracle_home/oracle_common/common/bin/wlst.sh /u01/startstop_scripts/startnodemgr2.py'
# Starting the managed servers on Node 1
echo Starting the managed servers on Node 1
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_FORMS > /tmp/nohup_wlsforms.out 2>&1 &
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_REPORTS > /tmp/nohup_wlsreports.out 2>&1 &
#Starting the managed servers on Node 2
echo Starting the managed servers on Node 2
ssh <node2hostname> 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_FORMS1 > /tmp/nohup_wlsforms1.out 2>&1 &'
ssh <node2hostname> 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_REPORTS1 > /tmp/nohup_wlsreports1.out 2>&1 &'
# Starting Web Tier OHS1
echo Starting Web Tier OHS1
/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startComponent.sh ohs1
# Starting Web Tier OHS2
echo Starting Web Tier OHS2
/u01/FMWHOME/oracle_home/oracle_common/common/bin/wlst.sh /u01/startstop_scripts/startohs2.py
echo Script completed.
echo The logs are under /tmp.. nohup_* files.
Note that, FRMRP_START.sh script needs 2 additional/helper scripts in order to be able to run successfully. See below->
# Set the domain environment
. /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/setDomainEnv.sh
# Stopping Managed Servers on node1
echo Stopping Managed Servers on node1
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_FORMS > /tmp/nohup_wlsforms.out 2>&1 &
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_REPORTS > /tmp/nohup_wlsreports.out 2>&1 &
# Stopping Managed Servers on node2
echo Stopping Managed Servers on node2
ssh node2hostname 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_FORMS1 > /tmp/nohup_wlsforms1.out 2>&1 &'
ssh node2hostname 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_REPORTS1 > /tmp/nohup_wlsreports1.out 2>&1 &'
# Stopping Web Tier OHS1
echo Stopping Web Tier OHS1
/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopComponent.sh ohs1
# Stopping Web Tier OHS2
echo stopping Web Tier OHS2 using WLST in foreground.
/u01/FMWHOME/oracle_home/oracle_common/common/bin/wlst.sh /u01/startstop_scripts/stopohs2.py
# Stopping Node Manager 1 on node1
stopohs2.py script
nmConnect('nodemanager','xxxx','forms02.oracle.com','5556','base_domain','/u01/FMWHOME/oracle_home/user_projects/domains/base_domain','ssl');
nmKill(serverName='ohs2', serverType='OHS');
exit();
today, I want to share 2 scripts that I have written for starting and stopping a 2 Node Forms&Reports 12C Cluster in one-go. This scripts makes our lifes easy, as they provide an automated way of controlling FMW 12C cluster components.
Using these scripts, the admin can start all the services running across 2 nodes with a single command by connecting to a single node.
Using these scripts, an admin can connect to a node (primary node) and start/stop all the Forms&Reports services (including OHS instances, managed server ,admin server etc) with only running one simple command.
In addition to that, I wrote these scripts by taking the dependencies between the components into account. That is, if a component is dependent to another component , that dependent component is started after the component, that it depends on.
Likewise, if a component is dependent on another component, that dependent component is stopped before the component that it depends on.
Before running these script, we configure the ssh equivalency between node1 and node2. The environment that I wrote this script was Solaris and it was very easy to enable the ssh equivalency between the FMW OS users. Anyways, the same method for enabling the ssh equivalency works for Linux as well.
So, we enable ssh equiv. because the scripts connects from node1 to node2 using ssh.
Actually, one way ssh equiv is enough.. (node1 should be able to connect to node2 using ssh --without password)
In addition to that, there is also one other requirement. That is, we create a directory called /<your_mount_point>/startstop_script and put our script files there. (we create this directory both on node1 and node2)
In order to start the services , we use the script called FRMRP_START.sh
For stopping the services, we use the script called FRMRP_STOP.sh
So, we only execute "sh FRMRP_START.sh" command to start all the services. (to start the services both on node1 and node2)
Similarly, we only execute " sh FRMRP_STOP.sh" command to stop all the services. (to stop the services both on node1 and node2)
Pretty handy right? :) We just execute a script , we wait a little and our full WLS stack including High Available Forms and Reports services are started/stopped. no need to remember the nohup commands, no need to create multiple ssh connections, no need to connect to the weblogic console for starting the managed servers, no need to remember the command for starting the ohs instances and so on... no need to spend energy while starting/stopping multiple FMW components across multiple server nodes:)
In order to start all the services (across a 2 node - FMW Forms&Reports 12C cluster)
We connect to node 1 using FMW OS user
We cd to the directory where our scripts are located -> /uo1/startstop_scripts
We execute FRMRP_START.sh
In order to stop all the services (across a 2 node - FMW Forms&Reports 12C cluster)
We connect to node 1 using FMW OS user
We cd to the directory where our scripts are located -> /u01/startstop_scripts
We execute FRMRP_STOP.sh
The codes of the scripts are as follows;
--Note that, the directory paths used in these scripts should be modified according to your env..
Alternatively, the scripts can be enhanced to make use of of env variables or bash script variables rather than using direct directory paths. I was on the field and wrote these scripts there.. I could actually wrote them better to take the direct path dependencies and the ssh equivalency requirements away, but still these scripts are okay and they are already tested & used in a production environment.
Also note that, there are 3 phyton scripts that you will see below. These phyton scripts are internally executed by FRMRP_START.sh and FRMRP_STOP.sh scripts. So these phyton scripts should also be located in the script directory (/<your_mount_point>/startstop_script).
FRMRP_START.sh script:
. /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/setDomainEnv.sh
# Starting NodeManager 1 on node1
echo Starting Node Manager 1
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startNodeManager.sh > /tmp/nohup_nodemanager.out 2>&1 &
# Starting NodeManager 2 on node2
echo Starting Node Manager 2
ssh <node2hostname> '/u01/FMWHOME/oracle_home/oracle_common/common/bin/wlst.sh /u01/startstop_scripts/startnodemgr2.py'
# Starting WebLogic Admin Server
echo Starting Admin Server
echo We just wait here for 60 secs
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startWebLogic.sh > /tmp/nohup_adminserver.out 2>&1 &
sleep 60
echo Starting Admin Server
echo We just wait here for 60 secs
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startWebLogic.sh > /tmp/nohup_adminserver.out 2>&1 &
sleep 60
# Starting the managed servers on Node 1
echo Starting the managed servers on Node 1
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_FORMS > /tmp/nohup_wlsforms.out 2>&1 &
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_REPORTS > /tmp/nohup_wlsreports.out 2>&1 &
#Starting the managed servers on Node 2
echo Starting the managed servers on Node 2
ssh <node2hostname> 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_FORMS1 > /tmp/nohup_wlsforms1.out 2>&1 &'
ssh <node2hostname> 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startManagedWebLogic.sh WLS_REPORTS1 > /tmp/nohup_wlsreports1.out 2>&1 &'
echo Starting Web Tier OHS1
/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/startComponent.sh ohs1
# Starting Web Tier OHS2
echo Starting Web Tier OHS2
/u01/FMWHOME/oracle_home/oracle_common/common/bin/wlst.sh /u01/startstop_scripts/startohs2.py
echo Script completed.
echo The logs are under /tmp.. nohup_* files.
Helper Scripts for FRMRP_START.sh:
These scripts were written with phyton and they were written to be executed by WLST. They are for starting nodemanager and OHS instances remotely. (for starting node2's nodemanager and OHS from node1)
starthos2.py script (Located on node1)
nmConnect('nodemanager',xxxxx,'node2.oracle.com','5556','base_domain','/u01/FMWHOME/oracle_home/user_projects/domains/base_domain','ssl');
nmStart(serverName='ohs2', serverType='OHS');
exit();
startnodemgr2.py script (Located on node2)
startNodeManager(verbose='true',NodeManagerHome='/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/nodemanager',ListenPort='5556',ListenAddress='xxxxx.node2.oracle.com')
exit()
nmConnect('nodemanager',xxxxx,'node2.oracle.com','5556','base_domain','/u01/FMWHOME/oracle_home/user_projects/domains/base_domain','ssl');
nmStart(serverName='ohs2', serverType='OHS');
exit();
startnodemgr2.py script (Located on node2)
startNodeManager(verbose='true',NodeManagerHome='/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/nodemanager',ListenPort='5556',ListenAddress='xxxxx.node2.oracle.com')
exit()
FRMRP_STOP.sh script:
. /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/setDomainEnv.sh
# Stopping Managed Servers on node1
echo Stopping Managed Servers on node1
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_FORMS > /tmp/nohup_wlsforms.out 2>&1 &
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_REPORTS > /tmp/nohup_wlsreports.out 2>&1 &
# Stopping Managed Servers on node2
echo Stopping Managed Servers on node2
ssh node2hostname 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_FORMS1 > /tmp/nohup_wlsforms1.out 2>&1 &'
ssh node2hostname 'nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopManagedWebLogic.sh WLS_REPORTS1 > /tmp/nohup_wlsreports1.out 2>&1 &'
# Stopping Web Tier OHS1
echo Stopping Web Tier OHS1
/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopComponent.sh ohs1
# Stopping Web Tier OHS2
echo stopping Web Tier OHS2 using WLST in foreground.
/u01/FMWHOME/oracle_home/oracle_common/common/bin/wlst.sh /u01/startstop_scripts/stopohs2.py
# Stopping Node Manager 1 on node1
echo Stopping Node Manager 1 on node1
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopNodeManager.sh > /tmp/nohup_nodemanager.log 2>&1 # Stopping Node Manager 2 on node2
echo Stopping Node Manager 2 on node2
ssh node2hostname '/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopNodeManager.sh'
# Stopping Weblogic Admin Server
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopNodeManager.sh > /tmp/nohup_nodemanager.log 2>&1 # Stopping Node Manager 2 on node2
echo Stopping Node Manager 2 on node2
ssh node2hostname '/u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopNodeManager.sh'
# Stopping Weblogic Admin Server
echo Stopping Weblogic Admin Server
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopWebLogic.sh > /tmp/nohup_adminserver.out 2>&1
echo Script completed.
echo Check /tmp for the script logs.. nohup_* files.
nohup /u01/FMWHOME/oracle_home/user_projects/domains/base_domain/bin/stopWebLogic.sh > /tmp/nohup_adminserver.out 2>&1
echo Script completed.
echo Check /tmp for the script logs.. nohup_* files.
Helper Script for FRMRP_STOP.sh:
This script was written with phyton and it was written to be executed by WLST. This script is for stopping the OHS instance remotely. (for stopping node2's OHS instance from node1)
nmConnect('nodemanager','xxxx','forms02.oracle.com','5556','base_domain','/u01/FMWHOME/oracle_home/user_projects/domains/base_domain','ssl');
nmKill(serverName='ohs2', serverType='OHS');
exit();