Starting and Stopping Oracle Reports Servers with WLST

Posted by Dirk Nachbar on Wednesday, September 06, 2017 with No comments
Normally people are using to start and stop their Oracle Reports Servers the by Oracle provided scripts startComponent.sh and stopComponent.sh in the $DOMAIN_HOME/bin.

The problem with this set of scripts is, that they really take long time to complete and you need to execute it for each Reports Server:
cd $DOMAIN_HOME/bin
# Lets measure the time
time ./startComponent.sh rep_server1
Starting system Component rep_server1 ...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Reading domain from /u00/app/oracle/user_projects/domains/demo_domain
 
Connecting to Node Manager ...
<Sep 6, 2017 8:45:02 PM CEST> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true.> 
<Sep 6, 2017 8:45:02 PM CEST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG128 to HMACDRBG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true.> 
<Sep 6, 2017 8:45:02 PM CEST> <Info> <Security> <BEA-090909> <Using the configured custom SSL Hostname Verifier implementation: weblogic.security.utils.SSLWLSHostnameVerifier$NullHostnameVerifier.> 
Successfully Connected to Node Manager.
Starting server rep_server1 ...
Successfully started server rep_server1 ...
Successfully disconnected from Node Manager.

Exiting WebLogic Scripting Tool.

Done

real   0m22.784s
user   0m37.029s
sys    0m2.065s

As you can see, the time to startup a single Oracle Reports Server can be up to 22 seconds (depending on your server, might be a bit lesser or more) and on top the execution for the startComponent.sh is only for one Oracle Reports Server, so in case you have multiple Oracle Reports Servers, you need to execute the startComponent.sh for each Reports Server . . .

With a simple Python Script for WLST you can perform the startup task much quicker and you can perform within one execution of my Python Script multiple startups and shutdowns for several Oracle Reports Servers.

You will need files for that:
  • domain.properties: which contains the required connect informations for the Node Manager and a comma separated list of your Oracle Reports Servers
  • start_stop_reports.py: a Python Script with named arguments to start or stop your provided Reports Servers within the domain.properties file
domain.properties:
# Replace with your Port of Node Manager
nm.port=5556
# Replace with your Hostname
nm.host=localhost
# Replace with your Password
nm.password=welcome1
# Replace with your Username
nm.username=nodemanager
# Replace your Domain Name
domain.name=demo_domain
# Replace your Domain Home
domain.home=/u00/app/oracle/user_projects/domains/demo_domain
# Replace with your Reports Server Name
reports.servers=rep_server1,rep_server2,rep_server3

start_stop_reports.py:
# ============================================================
#
# Script: start_stop_reports.py
#
# Author: Dirk Nachbar, http://dirknachbar.blogpost.com
#
# Purpose: Start / Stop Script for a list of Oracle Reports Servers
#
# ============================================================

import sys
import re
import os
from datetime import datetime
from java.io import File
from java.io import FileOutputStream
from java.io import FileInputStream
 
func=''
propfile=''
 
def helpUsage():
   print 'Usage: start_stop_reports.py [-help]'
   print '      [-function] provide function either start or stop'
   print '      [-propfile] provide the property file'
   exit()
 
for i in range(len(sys.argv)):
   if sys.argv[i] in ("-help"):
           helpUsage()
   elif sys.argv[i] in ("-function"):
           if i+1 < len(sys.argv):
                   func = sys.argv[i+1]
   elif sys.argv[i] in ("-propfile"):
           if i+1 < len(sys.argv):
                   propfile = sys.argv[i+1]
 
if len(func)==0 or len(propfile)==0:
   print 'Missing required arguments (-func, -propfile)'
   print ' '
   helpUsage()
 
# Load Connection Properties
propInputStream = FileInputStream(propfile)
configProps = Properties()
configProps.load(propInputStream)
nmPort=configProps.get("nm.port")
nmHost=configProps.get("nm.host")
nmPassword=configProps.get("nm.password")
nmUser=configProps.get("nm.username")
domainName=configProps.get("domain.name")
domainHome=configProps.get("domain.home")
reportsServers=configProps.get("reports.servers")
 
# Connect to Node Manager
nmConnect(nmUser, nmPassword, nmHost, nmPort, domainName, domainHome, 'ssl')
 
# Perform startup of defined Oracle Reports Servers
if func=="start":
   print 'Starting configured Reports Servers'
   for repserver in reportsServers.split(','):
      print 'Starting Reports Server: ' +repserver
      nmStart(serverName=repserver, serverType='ReportsServerComponent')
 
# Perform stop of defined Oracle Reports Servers
if func=="stop":
   print 'Stopping configured Reports Servers'
   for repserver in reportsServers.split(','):
      print 'Stopping Reports Server: ' +repserver
      nmKill(serverName=repserver, serverType='ReportsServerComponent')


The execution of the script is really straight forward:
Usage: start_stop_reports.py [-help]
      [-function] provide function either start or stop
      [-propfile] provide the property file


# Just call the script with wlst and provide the required parameters
# e.g. for starting all defined Reports Servers (rep_server1,rep_server2,rep_server3)

$ORACLE_HOME/oracle_common/common/bin/wlst.sh start_stop_reports.py -func start -propfile domain.properties

# e.g. for stopping all defined Reports Servers (rep_server1,rep_server2,rep_server3)

$ORACLE_HOME/oracle_common/common/bin/wlst.sh start_stop_reports.py -func stop -propfile domain.properties


Now let's see how long it will take to startup 3 Oracle Reports Servers with my above solution:
# Let's measure the time to execute
time $ORACLE_HOME/oracle_common/common/bin/wlst.sh start_stop_reports.py -func start -propfile domain.properties
Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to Node Manager ...
<Sep 6, 2017 9:15:17 PM CEST> <Info> <Security> <BEA-090905> <Disabling the CryptoJ JCE Provider self-integrity check for better startup performance. To enable this check, specify -Dweblogic.security.allowCryptoJDefaultJCEVerification=true.> 
<Sep 6, 2017 9:15:17 PM CEST> <Info> <Security> <BEA-090906> <Changing the default Random Number Generator in RSA CryptoJ from ECDRBG128 to HMACDRBG. To disable this change, specify -Dweblogic.security.allowCryptoJDefaultPRNG=true.> 
<Sep 6, 2017 9:15:17 PM CEST> <Info> <Security> <BEA-090909> <Using the configured custom SSL Hostname Verifier implementation: weblogic.security.utils.SSLWLSHostnameVerifier$NullHostnameVerifier.> 
Successfully Connected to Node Manager.
Starting configured Reports Servers
Starting Reports Server: rep_server1
Starting server rep_server1 ...
Successfully started server rep_server1 ...
Starting Reports Server: rep_server2
Starting server rep_server2 ...
Successfully started server rep_server2 ...
Starting Reports Server: rep_server3
Starting server rep_server3 ...
Successfully started server rep_server3 ...

real   0m13.602s
user   0m22.066s
sys    0m0.915s

As you can see with my solution, you will need only 13 seconds to startup three Oracle Reports Servers and thats just with one command instead of calling startComponent.sh or stopComponent.sh three times and each execution takes around 22 seconds.


Reaktionen: