May 31, 2017

How to install and configure Oracle Forms & Reports 12c fully unattended - Part 2

Important update! (June 14th, 2017): 

Please asure that all variables in setLocalEnv.sh are filled in correctly and adapted to Your environment. This especially for all variables regarding the Database Connection, like DB_PWD, DB_HOST, DB_PORT ... If not set correctly, the tool is not able to create the rcu repository which results in an error during runtime: 

Problem invoking WLST - traceback(innermost last):
(no code object) at line 0
File "/opt/wls/oracle/crFRExtension.py", line 143
changeDataSourceToXA('localSvcTblDataSource')

--------------------------------------------------------------------------------------------------------------------------


Part 2?? Yes! Part 1 - which covers the installation of FMW Infrastructure and Forms / Reports - can be found at Dirk Nachbars Blog: How to install and configure Oracle Forms & Reports 12c fully unattended - Part 1

The Task:

You have to create several new Forms 12c Domains / Environments

The Problem:

All oracle is providing to create Forms Domains is a Graphical User Interface. And there is no possibility of a 'silent' domain creation. In other words: Oracle does not support 'silent' domain creation.
Disadvantages:

  • each domain creation will take some time and needs manual input. 
  • possibility of typos during the create process is given,
  • standardization - which is essential imho - is not supported anymore 
  • no unattended installation, 
  • and so on ... name it.

The Solution:

Dirk Nachbar (http://dirknachbar.blogspot.ch/) and I created a toolset, based on a script written by Jan Peter Timmermann (https://jan-peter.me/), to do the whole stuff using scripts. But, You should know that oracle does not support silent installations officially. Nevertheless, it works very well, fast, reliable and repeatable.

The set consists of separate scripts to
  • set an appropriate environment to create the domain
  • install FMW Infrastructure software silently - if necessary (see Dirk Nachbars Blog for details)
  • install Forms / Reports software silently - if necessary (see Dirk Nachbars Blog for details)
  • create a domain
  • add necessary components for Forms / Reports to the domain and to finally form the forms / reports domain
  • create the webtier and - finally - 
  • configure the domain using forms config helper (see Dirk Nachbars Blog for details)

The scripts:

Lets start with the first script in the row - the crDomain.sh script which starts the whole process:
#!/bin/bash
#=====================================================================
# 
# $Id: crDomain.sh $
# $Name: basenv-16.05.final.c $ 
#
# PURPOSE: Script to create an Oracle Forms & Report WebLogic Domain
#
# PARAMETERS: none, all required parameters are taken from setLocalEnv.sh
#
# AUTHOR:  EDOREX AG, Robert Crames,  2017
#
# Modified : TRIVADIS AG, Dirk Nachbar,  2017 
#
#
#=====================================================================
# set -x

# Set Start Time
start_time=$(date +%s)

echo ${DOMAIN_NAME}

source $PWD/setLocalEnv.sh

echo $ORACLE_HOME


function wait4something
{
echo " "
echo "ENTER to proceed ..."
read
echo "The Installation Process is started ..."
}

echo "======================================================================================"
echo " Program  : crDomain.sh                                                ........"
echo "======================================================================================"

if [ -z "${WLST_HOME}" ]; then
    echo "Environment not correctly set - please verify"
    exit 1
fi

#--> install Domain 
if ! test -d "${DOMAIN_BASE}/${DOMAIN_NAME}"; then
   echo "=================================================="
   echo "Domain will be installed ..."
   echo "=================================================="
   if [  -z "${ADM_PWD}"  -o -z "${TEMPLATE}" -o -z "${ADMINPORT}" -o -z "${MW}" -o -z "${ADMINPORTSSL}" -o -z " ${DOMAIN_NAME}" ]; then
      echo "Environment not set - Exit"
      exit 1
   fi

   # In case we are facing problems with /dev/random
   export CONFIG_JVM_ARGS=-Djava.security.egd=file:/dev/./urandom:$CONFIG_JVM_ARGS

   ${WLST_HOME}/wlst.sh ${SCRIPT_HOME}/crDomain.py 

   mkdir -p  ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${AS_NAME}/security
   echo "username=${ADM_USER}" >  ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${AS_NAME}/security/boot.properties
   echo "password=${ADM_PWD}" >> ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${AS_NAME}/security/boot.properties

   if [ "${FORMS12C}" == "true" ]  || [ "${REPORTS12C}" == "true" ]; then
      echo "===========================================" 
      echo "Oracle Forms and Reports  will be configured"
      echo "==========================================="
      cd ${SCRIPT_HOME}
      ${SCRIPT_HOME}/crFRExtension.sh
      echo "DOMAIN with Forms and Reports is created"
   fi

   if [ "${WEBTIER12C}" == "true" ]; then
      echo "===========================================" 
      echo "Oracle Webtier will be configured"
      echo "==========================================="
      nohup ${DOMAIN_BASE}/${DOMAIN_NAME}/bin/startNodeManager.sh > /dev/null 2>&1 &
      echo "==========================================="
      echo " Node Manager starting, wait for 30 seconds"
      echo "==========================================="
      sleep 30
      nohup ${DOMAIN_BASE}/${DOMAIN_NAME}/startWebLogic.sh > /dev/null 2>&1 &
      echo "==========================================="
      echo "Admin Server ${AS_NAME} starting, wait for 2 Minutes"
      echo "==========================================="
      sleep 120
      cd ${SCRIPT_HOME}
      ${SCRIPT_HOME}/crWebtierDomain.sh
      echo "DOMAIN with OHS is created"
   fi

   # Set End Time
     finish_time=$(date +%s)
     echo "Finished"
     echo "Domain Build Time: $(( $((finish_time - start_time))/60))  minutes."
     echo "Start Domain manually by using startWeblogic.sh"
   else
     echo "Domain is already installed ..."
   fi


The crDomain.sh sources a file, which is responsible to set the correct environment for the following processes: setLocalEnv.sh:
# Location to the directory in which the create Domain scripts are residing
export SCRIPT_HOME=$PWD

# Directories
export ORACLE_BASE=/appl/oracle
export INT_ORACLE_HOME=$ORACLE_BASE/product/fmw-fr-12.2.1.2.0
export WL_HOME=$INT_ORACLE_HOME/wlserver
export WLST_HOME=$INT_ORACLE_HOME/oracle_common/common/bin
export MW=$INT_ORACLE_HOME
export DOMAIN_BASE=$ORACLE_BASE/user_projects/domains
export APPLICATION_BASE=$ORACLE_BASE/user_projects/applications
export APP_VZ=$APPLICATION_BASE

# install forms true / false
export FORMS12C=true
# install reports true / false
export REPORTS12C=true
# install OHS true / false
export WEBTIER12C=true
export OHS_COMPONENTNAME=ohs1
export OHS_LISTENPORT=7777
export OHS_SSLPORT=4443

# Domain specific
export TEMPLATE=$WL_HOME/common/templates/wls/wls.jar
export DOMAIN_NAME=FRTEST

# AdminServer
export AS_NAME=FRTESTAdminServer
export ADM_USER=weblogic
export ADM_PWD=welcome1
export ADMINPORT=7001 
export ADMINPORTSSL=7101
export AS_HOST=`hostname -f`

# Name and Port for the Forms Managed Server
export FORMS_MS_NAME=MS_FORMS
export FORMS12C_MS_PORT=9001

# Name and Port for the Reports Managed Server
export REPORTS_MS_NAME=MS_REPORTS
export REPORTS12C_MS_PORT=9002

# Move Reports Application into WLS_FORMS (true or false)
export REPORTS_IN_FORMS=false

# NodeManager
export NM_LISTENADDRESS=`hostname -f`
export NM_TYPE=SSL
export NM_PORT=5556
export NM_USERNAME=nodemanager
export NM_PWD=welcome1

# Repository Connect
export DBUSER=sys
export DBPWD=<Password of user sys>
export DBROLE=SYSDBA
export COMPONENTPWD=<Password to be used for component access>
export SCHEMA_PREFIX=$DOMAIN_NAME
export DB_HOST=<Hostname>
export DB_PORT=<Port, the database is listening on>
export DB_SERVICE=<Servicename of the repository database>
export DB_OMF=<true or false - set only to true if the database is prepared for that>
export DB_USER_PW=<Password to be used for repository schema owners>
export PWDFILE=$SCRIPT_HOME/passwords.txt

Set these parameters to values according Your needs. The variable names are selfexplaining ...


When all parameters are set, crDomain.py is the script which creates the basic domain:
#!/usr/bin/python

# Things to do:
# Logausgabe in File via redirect()

import os, sys
v_asName=os.environ['AS_NAME']
v_asUser=os.environ['ADM_USER']
v_webpw=os.environ['ADM_PWD']
v_adminport=os.environ['ADMINPORT']
v_adminportssl=os.environ['ADMINPORTSSL']
v_domainName=os.environ['DOMAIN_NAME']
v_template=os.environ['TEMPLATE']
v_javaHome=os.environ['JAVA_HOME']
v_setup_domain_base=os.environ['DOMAIN_BASE']
v_setup_application_base=os.environ['APPLICATION_BASE']
v_OracleHome=os.environ['INT_ORACLE_HOME']
v_dbhost=os.environ['DB_HOST']
v_dbport=os.environ['DB_PORT']
v_dbservice=os.environ['DB_SERVICE']
v_rcudbstr=v_dbhost+":"+v_dbport+":"+v_dbservice
v_SchemaPrefix=os.environ['SCHEMA_PREFIX']
v_pwdfile=os.environ['PWDFILE']
v_dbUser=os.environ['DBUSER']
v_dbPwd=os.environ['DBPWD']
v_dbRole=os.environ['DBROLE']
v_dbOmf=os.environ['DB_OMF']
v_componentPassword=os.environ['COMPONENTPWD']

def printHeader(headerText):
    print "\n======================================================================================"
    print "--> "+headerText
    print "======================================================================================\n"

def printInfo(infoText):
    print "-->: "+infoText

printHeader("Started: crDomain.py")

printHeader("Create password file")
os.system("echo "+v_dbPwd+">"+v_pwdfile)
os.system("echo " +v_componentPassword+ ">>"+v_pwdfile)
os.system("echo " +v_componentPassword+ ">>"+v_pwdfile)
os.system("echo " +v_componentPassword+ ">>"+v_pwdfile)
os.system("echo " +v_componentPassword+ ">>"+v_pwdfile)
os.system("echo " +v_componentPassword+ ">>"+v_pwdfile)

printHeader("Step: create repository - started")
printInfo("Drop repository "+v_SchemaPrefix)
os.system(v_OracleHome + "/oracle_common/bin/rcu -silent -dropRepository -databaseType ORACLE -connectString "+ v_rcudbstr +" -dbUser "+v_dbUser+" -dbRole "+v_dbRole+" -schemaPrefix "+v_SchemaPrefix+" -component STB -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -f <"+v_pwdfile)
printInfo("Repository "+v_SchemaPrefix+" dropped")

printInfo("Create repository "+v_SchemaPrefix+" - started")
os.system(v_OracleHome + "/oracle_common/bin/rcu -silent -createRepository -honorOMF "+ v_dbOmf +" -connectString "+ v_rcudbstr +" -dbUser "+v_dbUser+" -dbRole "+v_dbRole+" -useSamePasswordForAllSchemaUsers true -schemaPrefix "+v_SchemaPrefix+" -component STB -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -f < "+v_pwdfile)
printInfo("Repository "+v_SchemaPrefix+" created")

printHeader("Step: Read default template (always wls.jar!!)")
readTemplate(v_template)
printInfo("Template: "+v_template+" successfully read")   

printHeader("Step: Prepare Domain --> Set Domain Name to"+v_domainName)
cd('/')
cmo.setName(v_domainName)
printInfo("Step: Set Domain Name --> Successful")

printHeader("Step: Prepare Domain --> Set User Password")
cd('/')
cd('/Security/'+v_domainName+'/User/'+v_asUser)
cmo.setPassword(v_webpw)
printInfo("Step: Set User Password --> Successful")

printHeader('Step: Prepare Domain --> Set AdminServer Name ('+v_asName+') and Port ('+v_adminport+')')
cd('/')
cd('/Server/AdminServer')
cmo.setName(v_asName)
cd('/')
cd('/Server/'+v_asName)
cmo.setListenPort(int(v_adminport))
printInfo("Step: Set AdminServer Name --> Successful")

printHeader("Step: Prepare Domain --> Set Domain Properties")
setOption('OverwriteDomain', 'true')
setOption('ServerStartMode','prod')
printInfo("Step: Set Domain Properties --> Successful")

printHeader("Step: Prepare Domain --> Set JAVA_HOME in Domain")
setOption('JavaHome',v_javaHome)
printInfo("Step: Set JAVA_HOME in Domain --> Successful")

printHeader("Step: writeDomain and closeTemplate")
writeDomain(v_setup_domain_base+'/'+v_domainName)
closeTemplate()
printInfo("Step: writeDomain and closeTemplate --> Successful")

printHeader("Finished: crDomain.py")


Next in line is the script, to add forms / reports specific stuff to the domain. We called it: crFRExtension.sh (which calls crFRExtension.py):
#!/bin/bash
#=====================================================================
# 
# $Id: crDomain.sh $
# $Name: basenv-16.05.final.c $ 
#
# PURPOSE: Script to a WebLogic Domain with Forms & Reports
#          Script will be called by crDomain.sh
#
# PARAMETERS: none, all required parameters are taken from setLocalEnv.sh
#
# AUTHOR:  EDOREX AG, Robert Crames,  2017
#
# Modified : TRIVADIS AG, Dirk Nachbar,  2017 
#
#
#=====================================================================
echo "======================================================================================"
echo " Program  : crFRExtension.sh                                    ........"
echo "======================================================================================"

     # In case we are facing problems with /dev/random
     export CONFIG_JVM_ARGS=-Djava.security.egd=file:/dev/./urandom:$CONFIG_JVM_ARGS

     ${WLST_HOME}/wlst.sh ${SCRIPT_HOME}/crFRExtension.py 

     if [ "${FORMS12C}" == "true" ]; then
         mkdir -p  ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${FORMS_MS_NAME}/security
         echo "username=${ADM_USER}" >  ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${FORMS_MS_NAME}/security/boot.properties
         echo "password=${ADM_PWD}" >> ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${FORMS_MS_NAME}/security/boot.properties
     fi


     if [ "${REPORTS12C}" == "true" ]; then
        mkdir -p  ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${REPORTS_MS_NAME}/security
        echo "username=${ADM_USER}" >  ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${REPORTS_MS_NAME}/security/boot.properties
        echo "password=${ADM_PWD}" >> ${DOMAIN_BASE}/${DOMAIN_NAME}/servers/${REPORTS_MS_NAME}/security/boot.properties
     fi


crFRExtension.py:
#!/usr/bin/python

# Things to do:
#

import os, sys
v_forms=os.environ['FORMS12C']
v_formsMSName=os.environ['FORMS_MS_NAME']
v_formsPort=os.environ['FORMS12C_MS_PORT']
v_reports=os.environ['REPORTS12C']
v_reportsMSName=os.environ['REPORTS_MS_NAME']
v_reportsPort=os.environ['REPORTS12C_MS_PORT']
v_NMListenAddress=os.environ['NM_LISTENADDRESS']
v_NMType=os.environ['NM_TYPE']
v_NMPort=os.environ['NM_PORT']
v_NMUsername=os.environ['NM_USERNAME']
v_NMPwd=os.environ['NM_PWD']
v_domain=os.environ['DOMAIN_NAME']
v_dbhost=os.environ['DB_HOST']
v_dbport=os.environ['DB_PORT']
v_dbservice=os.environ['DB_SERVICE']
v_url="jdbc:oracle:thin:@//"+v_dbhost+':'+v_dbport+'/'+v_dbservice
v_pwd=os.environ['DB_USER_PW']
v_SchemaPrefix=os.environ['SCHEMA_PREFIX']
v_setup_domain_base=os.environ['DOMAIN_BASE']
v_setup_application_base=os.environ['APPLICATION_BASE']
v_reports_in_forms=os.environ['REPORTS_IN_FORMS']

def changeDatasourceToXA(datasource):
  print 'Change datasource '+datasource
  cd('/')
  cd('/JDBCSystemResource/'+datasource+'/JdbcResource/'+datasource+'/JDBCDriverParams/NO_NAME_0')
  set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
  set('UseXADataSourceInterface','True')
  cd('/JDBCSystemResource/'+datasource+'/JdbcResource/'+datasource+'/JDBCDataSourceParams/NO_NAME_0')
  set('GlobalTransactionsProtocol','TwoPhaseCommit')
  cd('/')

def printHeader(headerText):
    print "\n======================================================================================"
    print "--> "+headerText
    print "======================================================================================\n"

def printInfo(infoText):
    print "-->: "+infoText

printHeader("Started: crFRExtension.py")

try:
    if not ( v_forms == "true" or v_reports == "true" ):
       printInfo( "Forms and Reports flag are set to false")
       printInfo( "We will stop processing, please activate Forms or Reports")
       exit()
    printHeader( "readDomain "+v_domain+" started")
    readDomain(v_setup_domain_base+'/'+v_domain)
    printInfo( "readDomain successful")
except:
    printInfo( "readDomain failed")
    exit()

try:
    printHeader( "select and load templates")
    selectTemplate('Oracle HTTP Server (Collocated)')
    if v_forms == "true":
       selectTemplate('Oracle Forms')
    if v_reports == "true":
       selectTemplate('Oracle Reports Application')
       selectTemplate('Oracle Reports Server')
    printInfo( "select templates successful")
    loadTemplates()
    printInfo( "load templates successful")
except:
    printInfo( "select and load templates failed")
    exit()

printHeader("JDBC configuration")
try:
    printInfo("Configure LocalSvcTblDataSource")
    cd('/')
    cd('/JDBCSystemResource/LocalSvcTblDataSource/JdbcResource/LocalSvcTblDataSource')
    cd('JDBCDriverParams/NO_NAME_0')
    set('DriverName','oracle.jdbc.OracleDriver')
    set('URL', v_url)
    set('PasswordEncrypted', v_pwd)
    cd('Properties/NO_NAME_0')
    cd('Property/user')
    cmo.setValue(v_SchemaPrefix+'_STB')
    printInfo("Configure LocalSvcTblDataSource successful")
except:
    printInfo("Configure LocalSvcTblDataSource failed")
    exit()

try:
    printInfo("Configure opss-data-source")
    cd('/')
    cd('JDBCSystemResource/opss-data-source/JdbcResource/opss-data-source')
    cd('JDBCDriverParams/NO_NAME_0')
    set('DriverName','oracle.jdbc.OracleDriver')
    set('URL', v_url)
    set('PasswordEncrypted', v_pwd)
    cd('Properties/NO_NAME_0')
    cd('Property/user')
    cmo.setValue(v_SchemaPrefix+'_OPSS')
    printInfo("Configure opss-data-source successful")
except:
    printInfo("Configure opss-data-source failed")
    exit()

try:
    printInfo("Configure opss-audit-viewDS")
    cd('/')
    cd('JDBCSystemResource/opss-audit-viewDS/JdbcResource/opss-audit-viewDS')
    cd('JDBCDriverParams/NO_NAME_0')
    set('DriverName','oracle.jdbc.OracleDriver')
    set('URL', v_url)
    set('PasswordEncrypted', v_pwd)
    cd('Properties/NO_NAME_0')
    cd('Property/user')
    cmo.setValue(v_SchemaPrefix+'_IAU_VIEWER')
    printInfo("Configure opss-audit-viewDS successful")
except:
    printInfo("Configure opss-audit-viewDS failed")
    exit()

try:
    printInfo("Configure opss-audit-DBDS")
    cd('/')
    cd('JDBCSystemResource/opss-audit-DBDS/JdbcResource/opss-audit-DBDS')
    cd('JDBCDriverParams/NO_NAME_0')
    set('DriverName','oracle.jdbc.OracleDriver')
    set('URL', v_url)
    set('PasswordEncrypted', v_pwd)
    cd('Properties/NO_NAME_0')
    cd('Property/user')
    cmo.setValue(v_SchemaPrefix+'_IAU_APPEND')
    printInfo("Configure opss-audit-DBDS successful")
except:
    printInfo("Configure opss-audit-DBDS failed")
    exit()

try:
   printInfo("Modify Datasources: LocalSvcTblDataSource , opss-audit-DBDS, opss-audit-viewDS , opss-data-source")
   changeDatasourceToXA('LocalSvcTblDataSource')
   changeDatasourceToXA('opss-audit-DBDS')
   changeDatasourceToXA('opss-audit-viewDS')
   changeDatasourceToXA('opss-data-source')
   printInfo("Modify Datasources successful")
except:
   printInfo("Modify Datasources failed")

printHeader('Customize Domain Settings')
try:
    printInfo("Name and Ports of the Managed Servers will be modified")
    if v_forms == "true":
       cd('/')
       cd('/Server/WLS_FORMS')
       cmo.setName(v_formsMSName)
       cd('/')
       cd('/Server/'+v_formsMSName)
       cmo.setListenPort(int(v_formsPort))
    if v_reports == "true":
       cd('/')
       cd('/Server/WLS_REPORTS')
       cmo.setName(v_reportsMSName)
       cd('/Server/'+v_reportsMSName)
       cmo.setListenPort(int(v_reportsPort))
    printInfo("Modification of Name and Ports are successful")
except:
    printInfo("ERROR: Modification of Name and Ports are failed")

try:
    if v_reports_in_forms == 'false':
        printInfo("Reports are remaining in own Managed Server")
except:
    printInfo("x")

try:
    if v_reports_in_forms == 'true':
        printInfo("Trying Move Reports into Forms Managed Server")
        cd('/')
        cd('/AppDeployments/reports#12.2.1')
        set('Target','cluster_forms')
        cd('/')
        cd('/Library/oracle.reports.applib#12.2.1@12.2.1')
        set('Target','cluster_forms')
        printInfo("Move Reports into Forms Managed Server are successful")
except:
    printInfo("ERROR: Move Reports into Forms Managed Server failed")

try:
    printHeader("Nodemanager Configuration")
    cd('/')
    cd('/Machines/AdminServerMachine/NodeManager/AdminServerMachine')
    cmo.setNMType(v_NMType)
    cmo.setListenAddress(v_NMListenAddress)
    cmo.setListenPort(int(v_NMPort))
    cd('/')
    cd('/SecurityConfiguration/'+v_domain)
    cmo.setNodeManagerUsername(v_NMUsername)
    cmo.setNodeManagerPasswordEncrypted(v_NMPwd)
    printInfo("Nodemanager Configuration successful")
except:
    printInfo("ERROR: Nodemanager Configuration failed")

try:
    printHeader("AppDir will be set to "+v_setup_application_base)
    try:
        setOption('AppDir',v_setup_application_base)
    except Exception, e:
        print "Error Message "+ str(e)

    printInfo("Domain will be updated and saved")
    printInfo("... this can take up to 5 minutes")
    updateDomain()
    closeDomain()
    printHeader("Program End: crFRExtension.py")
    print "======================================================================================"

    exit()
except:
   print "Domain could not be saved"



After all, it's time to create the Webtier ... using crWebtierDomain.sh / crWebtierDomain.py:
#!/bin/bash
#=====================================================================
#
# $Id: crWebtierDomain.sh $
# $Name: basenv-16.05.final.c $
#
# PURPOSE: Script to configure Oracle HTTP Server for Oracle Forms & Reports
#
# PARAMETERS: none, all required parameters are taken from setLocalEnv.sh
#
# AUTHOR:  TRIVADIS AG, Dirk Nachbar,  2017
#
# Modified : 
#
#
#=====================================================================


echo "======================================================================================"
echo " Program  : crWebtierDomain.sh                                                ........"
echo "======================================================================================"

# Check the required Environment Variables for OHS COnfiguration
if [  -z "${OHS_COMPONENTNAME}"  -o -z "${OHS_LISTENPORT}" -o -z "${OHS_SSLPORT}" ]; then
   echo "Environment not set - Exit"
   exit 1
fi

# In case we are facing problems with /dev/random
export CONFIG_JVM_ARGS=-Djava.security.egd=file:/dev/./urandom:$CONFIG_JVM_ARGS

${WLST_HOME}/wlst.sh ${SCRIPT_HOME}/crWebtierDomain.py


echo "======================================================================================"
echo "Starting newly create OHS Component ${OHS_COMPONENTNAME} "
echo "======================================================================================"

echo ${NM_PWD} | ${DOMAIN_BASE}/${DOMAIN_NAME}/bin/startComponent.sh ${OHS_COMPONENTNAME} storeUserConfig

crWebtierDomain.py:

#!/usr/bin/python

# Things to do:
#

import os, sys
v_asUser=os.environ['ADM_USER']
v_webpw=os.environ['ADM_PWD']
v_adminport=os.environ['ADMINPORT']
v_as_host=os.environ['AS_HOST']
v_ohs_componentname=os.environ['OHS_COMPONENTNAME']
v_ohs_listenport=os.environ['OHS_LISTENPORT']
v_ohs_sslport=os.environ['OHS_SSLPORT']

connect(v_asUser, v_webpw, v_as_host+':'+v_adminport)

ohs_createInstance(instanceName=v_ohs_componentname, machine='AdminServerMachine', listenPort=v_ohs_listenport, sslPort=v_ohs_sslport)

That's it - basically ... If You want to know, how to install the necessary software (FMW Infrastructure plus Forms Reports) and to configure the domain using forms config helper, please have a look at Dirk Nachbar's Blog --> How to install and configure Oracle Forms & Reports 12c fully unattended - Part 1

Please leave comments, requests for enhancements or hints (in case we could do something better or with less overhead). 

Special thanks to Jan Peter Timmermann who shared important information, and by doing that, gave the initial input for the script set.


Share:

41 comments:

  1. I'm currently in the process of creating a docker for forms, so this is very timely.

    Issues so far:
    - Get a 'missing file' error when using DB_OMF. Appears to work with this set to false.
    - Had to comment out the changeDatasourceToXA code, and threw an 'unable to cast to java.sql.Driver'. Exception
    - MS_NAMES4FORMS/REPORTS should be FORMS_MS_NAME etc. in crFRExtension.sh
    - The content of crWebtierDomain.py just repeats the .sh

    Other than that, appears to be working! Really appreciate the time you've put into this.

    ReplyDelete
    Replies
    1. Hi Al Capone

      sorry for the delay - I'm currently on vacation ... Thanks a lot for Your comment. I will have a closer look at these issues asap - and fix / resolve these problems

      best regards
      Robert

      Delete
    2. Issues 3 and 4 are solved (Post is updated), Issues 1 and 2 are under investigation ...

      Delete
    3. Prerequisite for DB_OMF=true is that the Database is prepared for Oracle Managed Files. The parameter does not set the Database into that mode. When set to false the database is assumed to have no OMF support.

      Delete
    4. 1) Ok - I understand, thanks
      2) Not really sure what the requirement on making it an XA connection
      3/4) Great, thanks!!

      Delete
    5. 2) --> Could You please check whether or not the mbeans used in changeDatasourceToXA are available? And: What is the exact errormessage / errorstack when the wlst code (changeDatasourceToXA) is executed?

      Delete
  2. This is really awesome that you guys are doing this, we are just looking into docker for forms and this comes in handy, will execute and let you know. thanks.

    ReplyDelete
  3. Problem invoking WLST - traceback(innermost last):
    (no code object) at line 0
    File "/opt/wls/oracle/crFRExtension.py", line 143
    changeDataSourceToXA('localSvcTblDataSource')

    ReplyDelete
  4. Hi Jay-Omaha US

    Could You please check the mbeans used in that changeDataSourceToXA function? They all should be available in Your domain's environment. I'll check the function tomorrow morning and give feedback asap.

    best regards
    Robert

    ReplyDelete
  5. Thank You, guys, for forwarding the errormessage. Reason is, that the install procedure could not connect to the repository database and create the rcu repository. I'm pretty sure, that the lines

    # Repository Connect
    export DBPWD=
    export COMPONENTPWD=
    export DB_HOST=
    export DB_PORT=
    export DB_SERVICE=

    in Your setLocalEnv.sh file are still empty. Please fill in the necessary information and retry.

    I will make an update in my blogpost ...

    BTW: Was my fault ... sorry for that

    ReplyDelete
  6. Oh, thanks for your reply Robert.
    looks like 1 problem with changeDataSourceToXA('localSvcTblDataSource') was missing indentation and not aligned with other calls.
    SyntaxError: inconsistent dedent
    corrected that i get the
    [EL Severe]: ejb: --java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to java.sql.Driver

    for some reason, opss ds seems to be failing but log is not getting created, checking it.

    ReplyDelete
  7. Hi Robert,
    whatever i do, i am not seeing the typical formsweb.cfg file under domains. I only see it under forms/templates/config. That tells me that some step is still missing?
    the ohs_createInstance also has problems finding machine name
    ohs_createInstance(instanceName=v_ohs_componentname, machine='AdminServerMachine', listenPort=v_ohs_listenport, sslPort=v_ohs_sslport)
    Since we dont give machine name while creating domain, i think its empty and not matching anything ( i tried changing to name under config.xml)

    ReplyDelete
  8. Jay, good morning ...

    Seems to be a little difficult ;-) ... would You mind to send some more information to this email address: robert.crames.blog@gmail.com

    I would like to know:
    - OS ... manufacturer and release
    - Database Release and Edition
    - FMW Infrastructure Release
    - Forms / Reports Release

    would be great to have a copy of Your setLocalEnv.sh (replace passwords by text 'password', and all identifying stuff like hostnames by a replacement name - for example host.domain.com) as well as an output file of Your run of crDomain.sh (start crDomain.sh and 'tee' all output to a file --> ./crDomain.sh | tee -a crDomain.log (or something like that))

    best regards
    Robert

    ReplyDelete
  9. Hi Robert,

    I have the same Jay issue:

    find next output of the command:


    [oracle@oralino install]$ ./crFRExtension.sh
    ======================================================================================
    Program : crFRExtension.sh ........
    ======================================================================================

    Initializing WebLogic Scripting Tool (WLST) ...

    Welcome to WebLogic Server Administration Scripting Shell

    Type help() for help on available commands


    ======================================================================================
    --> Started: crFRExtension.py
    ======================================================================================


    ======================================================================================
    --> readDomain FRTEST started
    ======================================================================================

    -->: readDomain successful

    ======================================================================================
    --> select and load templates
    ======================================================================================

    -->: select templates successful
    -->: load templates successful

    ======================================================================================
    --> JDBC configuration
    ======================================================================================

    -->: Configure localSvcTblDataSource
    -->: Configure localSvcTblDataSource successful
    -->: Configure opss-data-source
    -->: Configure opss-data-source successful
    -->: Configure opss-audit-viewDS
    -->: Configure opss-audit-viewDS successful
    -->: Configure opss-audit-DBDS
    -->: Configure opss-audit-DBDS successful
    -->: Modify Datasources: LocalSvcTblDataSource , opss-audit-DBDS, opss-audit-viewDS , opss-data-source
    Change datasource LocalSvcTblDataSource
    Change datasource opss-audit-DBDS
    Change datasource opss-audit-viewDS
    Change datasource opss-data-source
    -->: Modify Datasources successful

    ======================================================================================
    --> Customize Domain Settings
    ======================================================================================

    -->: Name and Ports of the Managed Servers will be modified
    -->: Modification of Name and Ports are successful
    -->: Reports are remaining in own Managed Server

    ======================================================================================
    --> Nodemanager Configuration
    ======================================================================================

    -->: Nodemanager Configuration successful

    ======================================================================================
    --> AppDir will be set to /u00/appl/oracle/user_projects/applications
    ======================================================================================

    -->: Domain will be updated and saved
    -->: ... this can take up to 5 minutes
    [EL Severe]: ejb: 2017-06-16 21:51:28.399--ServerSession(532446437)--java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to java.sql.Driver
    Error: runCmd() failed. Do dumpStack() to see details.
    Domain could not be saved




    ReplyDelete
  10. and here are a copy of my updated setLocalEnv.sh
    ---------------------------

    [oracle@oralino install]$ cat ./setLocalEnv.sh
    # Location to the directory in which the create Domain scripts are residing
    export SCRIPT_HOME=$PWD

    export JDK_SOURCE=jdk-8u131-linux-x64.tar.gz
    export JDK_SOURCE_TAR=jdk-8u131-linux-x64.tar
    export JDK_REL=1.8.0_131

    # Directories
    export ORACLE_BASE=/u00/appl/oracle
    export INT_ORACLE_HOME=$ORACLE_BASE/product/fmw-fr-12.2.1.2.0
    export ORACLE_HOME=$ORACLE_BASE/product/fmw-fr-12.2.1.2.0
    export WL_HOME=$INT_ORACLE_HOME/wlserver
    export WLST_HOME=$INT_ORACLE_HOME/oracle_common/common/bin
    export MW=$INT_ORACLE_HOME
    export DOMAIN_BASE=$ORACLE_BASE/user_projects/domains
    export APPLICATION_BASE=$ORACLE_BASE/user_projects/applications
    export APP_VZ=$APPLICATION_BASE

    # install forms true / false
    export FORMS12C=true
    # install reports true / false
    export REPORTS12C=true
    # install OHS true / false
    export WEBTIER12C=true
    export OHS_COMPONENTNAME=ohs1
    export OHS_LISTENPORT=7777
    export OHS_SSLPORT=4443

    # Domain specific
    export TEMPLATE=$WL_HOME/common/templates/wls/wls.jar
    export DOMAIN_NAME=FRTEST

    # AdminServer
    export AS_NAME=FRTESTAdminServer
    export ADM_USER=weblogic
    export ADM_PWD=system00
    export ADMINPORT=7001
    export ADMINPORTSSL=7101
    export AS_HOST=`hostname -f`

    # Name and Port for the Forms Managed Server
    export FORMS_MS_NAME=MS_FORMS
    export FORMS12C_MS_PORT=9001

    # Name and Port for the Reports Managed Server
    export REPORTS_MS_NAME=MS_REPORTS
    export REPORTS12C_MS_PORT=9002

    # Move Reports Application into WLS_FORMS (true or false)
    export REPORTS_IN_FORMS=false

    # NodeManager
    export NM_LISTENADDRESS=`hostname -f`
    export NM_TYPE=SSL
    export NM_PORT=5556
    export NM_USERNAME=nodemanager
    export NM_PWD=system00

    # Repository Connect
    export DBUSER=sys
    export DBPWD=system00
    export DBROLE=SYSDBA
    export COMPONENTPWD=system00
    export SCHEMA_PREFIX=$DOMAIN_NAME
    export DB_HOST=192.168.0.19
    export DB_PORT=1521
    export DB_SERVICE=ORCL
    export DB_OMF=true
    export DB_USER_PW=system00
    export PWDFILE=$SCRIPT_HOME/passwords.txt

    [oracle@oralino install]$

    ReplyDelete
  11. Hi Khaled,

    thank You for the information. Could You please send the AdminServer logfile where the 'cannot be cast' messages are in, send to robert.crames.blog@gmail.com?
    Next: Are You able to connect to the repository database, using the EZConnect connect string? Is the database a EE or SE - and what version?
    best regards Robert

    ReplyDelete
  12. Hello,

    First of all, thank you for this good work.

    Just to mention that the Python os.environ method caches the environment variables when it is first called.
    So, even if you restart the server, the value returned by os.environ will never be the new one.

    ReplyDelete
    Replies
    1. Hi Tim,

      thank You for Your valuable input. I had a look into phyton's documentation and found:
      "This mapping is captured the first time the os module is imported, typically during Python startup as part of processing site.py. Changes to the environment made after this time are not reflected in os.environ, except for changes made by modifying os.environ directly.'

      Nevertheless - to be sure, I'll create a sample script to check that. Keep You up2date ...

      best regards
      Robert

      Delete
    2. Finally I have moved the RCU data loading in the crDomain.sh script as I think you don't need to be connected to WLST to execute it.

      I have also added a check on available components and a final check to list all schemas loaded.

      Note that the following script only load data in a pre-created RCU done by a DBA.

      echo Creating password file
      echo $DB_PWD > $PWD_FILE
      echo $COMPONENT_PWD >> $PWD_FILE
      echo $COMPONENT_PWD >> $PWD_FILE
      echo $COMPONENT_PWD >> $PWD_FILE
      echo $COMPONENT_PWD >> $PWD_FILE
      echo $COMPONENT_PWD >> $PWD_FILE

      echo List Available Components
      $ORACLE_HOME/oracle_common/bin/rcu -silent -listComponents

      echo Loading Data in RCU in DB $DB_CONNECT_STRING
      $ORACLE_HOME/oracle_common/bin/rcu -silent -dataLoad -databaseType ORACLE -connectString ${DB_CONNECT_STRING} -dbUser ${DB_USER} -dbRole ${DB_ROLE} -useSamePasswordForAllSchemaUsers true -schemaPrefix ${SCHEMA_PREFIX} -component STB -component IAU -component IAU_APPEND -component IAU_VIEWER -component OPSS -f < ${PWD_FILE}

      echo List Repository schemas in DB $DB_CONNECT_STRING
      $ORACLE_HOME/oracle_common/bin/rcu -silent -listSchemas -databaseType ORACLE -connectString ${DB_CONNECT_STRING} -dbUser ${DB_USER} -dbRole ${DB_ROLE} -schemaPrefix ${SCHEMA_PREFIX} -f < ${PWD_FILE}

      Delete
    3. Hi Tim,

      great job :-) ... and happy to see, that our (Dirk's and my) scriptset is a basis for other admins solutions.

      regarding the 'move': my intention to place the rcu creation in the wlst script was, to have all stuff related to a certain 'task block' on one place. But, You are absolutely right, You can handle that in crDomain.sh as well.

      Thank you or sharing Your enhancements.

      best regards
      Robert

      Delete
    4. Thank you FOR sharing Your enhancements, not or ...

      Delete
  13. Hi Robert,
    Sorry for the delayed reply.
    I finally fixed all my issues and actually running in a docker container now.
    1) Changed XADataSource to OracleDriver jdbc driver like other ones.
    cd('/JDBCSystemResource/'+datasource+'/JdbcResource/'+datasource+'/JDBCDriverParams/NO_NAME_0')
    set('DriverName','oracle.jdbc.OracleDriver')

    2) Had issues with my oracle db -xe 11g docker containter, changed that and my RCU schemas were fine after that

    my only question, how do i add machine name (AdminServerMachine) to the domain creation of the admin server so that i could create the OHS instance property, otherwise, it gives error.

    ReplyDelete
    Replies
    1. Hi Jay-Omaha

      great to hear that You've fixed the issues ... :-)

      Regarding Your question: Could You please describe that in more detail? I ask, because after the domain is created, the AdminServerMachine is already attached to all Managed Servers and the Admin Server.

      best regards
      Robert

      Delete
  14. Actually, had to add this in crDomain.py to get this to work.
    create('AdminServerMachine','Machine')

    ReplyDelete
    Replies
    1. Hi Jay,

      there is something wrong either with Your environment or with the scripts. creation of 'AdminServerMachine' is part of crFRExtension.py and done automatically.
      Additionally, the configuration of the XA datasources - that should work out of the box ...
      Could You please provide a list of releases and versions of the software You are using?

      kind regards
      Robert

      Delete
  15. Hi,

    I want to create another OHS instance how it can be added to the script and another weblogic instances and multiple forms reports weblogic managed servers How it can be added.

    Thanks
    Keshav

    ReplyDelete
    Replies
    1. Hi Keshav,

      just to be sure that I understood Your questions correctly. You want to add ...

      - another OHS Instance on the same system, in addition to the 'standard one? Or, instead of the original one, another OHS in a different path?
      - additional WLS Managed Servers for Forms and Reports on the same or on a remote system?

      best regards
      Robert

      Delete
    2. I'm interested in your reply in this. i.e. multiple forms and reports managed servers clustered across multiple servers. This scenario is closer to my real working environment.

      and BTW I used WLS console to record my manual work on GUI to produce a py script, and modify it before applying to other env. but your scripts are beautiful anyway.

      thanks

      Delete
  16. Hi,

    Thank you for this post. The scripts posted here worked for me. My only concern is how is that even though my 'ohs1' component is not running (ie. only the node manager, admin server and MS_FORMS are running), I can still launch my forms application in my browser. I did run enable_ohs as part of my configuration. Any idea why?

    Thanks.

    ReplyDelete
  17. Is this going to work with 12.2.1.3 since form setup is two parts not one.

    ReplyDelete
    Replies
    1. To be honest: I do not know at this very moment ... Have to check that. But, just in case, if You've tested it: Please let me know or leave a comment here.

      Delete
    2. Hi Omar,

      I have setup the same configuration in 12.2.1.3 and did some changes and then it works perfectly fine atleast till domain configuration without OHS part.

      Hi Robert,

      i am facing during OHS setup. i am getting below error.

      Connecting to t3://hostname:port with userid weblogic ...
      This Exception occurred at Thu Aug 13 15:25:21 CEST 2020.
      javax.naming.CommunicationException: Failed to initialize JNDI context, tried 2 time or times totally, the interval of each time is 0ms.
      t3://hostname:port: Destination XX.XX.XX.XX, 8001 unreachable.; nested exception is:
      java.net.ConnectException: Connection refused (Connection refused); No available router to destination.; nested exception is:
      java.rmi.ConnectException: No available router to destination. [Root exception is java.net.ConnectException: t3://hostname:port: Destination XX.XX.XX.XX, port unreachable.; nested exception is:
      java.net.ConnectException: Connection refused (Connection refused); No available router to destination.; nested exception is:
      java.rmi.ConnectException: No available router to destination.]
      Problem invoking WLST - Traceback (innermost last):
      File "/opt/forms/soft/scripts/createWebTierDomain.py", line 15, in ?
      File "", line 19, in connect
      File "", line 553, in raiseWLSTException

      Delete
  18. Thank you very much for this. I am truly grateful.

    ReplyDelete
  19. Fix your Oracle Database Installation Issue with Remote DBA Services
    Precisely when business development is principal and you require mission basic help, Oracle Advanced Customer Support Services passes on a gave empower gathering, proactive course, and affirmation associations. This mission basic help is gone on through the Oracle Solution Support Center, our most aggregate yearly help advantage offering over the whole Oracle IT stack - from applications, middleware, and database through servers, putting away, and structure gadgets.
    Gets our Online Oracle DB Support or Database Administration for Oracle to decide your issues as for Oracle
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete
  20. When running the script I get: mkdir: cannot create directory ‘/user_projects’: Permission denied. This happens regardless of any permission I have. I used 777 and still get that error! I also tried to create the directory before running the script and still wasn't able to create the boot.properties files due to permission issues!

    ReplyDelete
  21. Both articles (Dirk's and your's are great and are actually saving time.
    I am on the way to prepare an upgrade 10.3.0.6 weblo with Forms and Reports to 12.2.1.4.0. I will install the new version next to the old one. I need to do that for 4 env : DEV, REC, UAT, PRD. There are at least 70 VMs in target. SO i would like to install fully unattended (Thks again). But i need also to cluster 16 Forms Managed Server (1 /VM) and 16 Reports Managed Server (1/VM) that i need to configure without graphical environment, Dirk'post on frmconfighelper was a great help for the Forms part as i suppose i can use the script to add Forms managed server to the cluster (forms_cluster) but,

    How to do this for reports ?

    Thank you for your answer and Best Regards from France

    ReplyDelete
  22. Hello Robert,

    thanks to you and Dirk for providing the scripts. Great help for us!
    Currently we would like to set up a process to install Weblogic / Forms unattended - Reports we don't need.

    The following steps work very well:

    - install FMW Infrastructure software
    - install Forms / Reports software
    - install RCU repository

    But when we create the Forms domain the AdminServer don't start.
    In AdminServer.out we see the following errors:


    <Server subsystem failed. Reason: A MultiException has 5 exceptions. They are:
    1. weblogic.management.ManagementException: [Management:141266]Parsing failure in config.xml: The following failures occurred:
    -- Reference to AdminServerMachine by [icisfrm]/Servers[AdminServer]/Machine is ambigous;
    The following beans share this name:
    - weblogic.management.configuration.MachineMBeanImpl@a633453a([icisfrm]/Machines[AdminServerMachine])
    - weblogic.management.configuration.UnixMachineMBeanImpl@a633453a([icisfrm]/Machines[AdminServerMachine])
    -- Reference to AdminServerMachine by [icisfrm]/Servers[WLS_FORMS]/Machine is ambigous;
    The following beans share this name:
    - weblogic.management.configuration.MachineMBeanImpl@a633453a([icisfrm]/Machines[AdminServerMachine])
    - weblogic.management.configuration.UnixMachineMBeanImpl@a633453a([icisfrm]/Machines[AdminServerMachine])
    -- Reference to AdminServerMachine by [icisfrm]/SystemComponents[forms1]/Machine is ambigous;
    The following beans share this name:
    - weblogic.management.configuration.MachineMBeanImpl@a633453a([icisfrm]/Machines[AdminServerMachine])
    - weblogic.management.configuration.UnixMachineMBeanImpl@a633453a([icisfrm]/Machines[AdminServerMachine])
    .
    2. java.lang.IllegalStateException: Unable to perform operation: create on weblogic.management.provider.internal.RuntimeAccessImpl
    3. java.lang.IllegalStateException: Unable to perform operation: post construct on weblogic.management.provider.internal.RuntimeAccessService
    4. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of weblogic.t3.srvr.FinalThreadLocalService errors were found
    5. java.lang.IllegalStateException: Unable to perform operation: resolve on weblogic.t3.srvr.FinalThreadLocalService


    When we create the domain without WLS_FORMS the AdminServer starts errorless.

    Kind regards
    Frank

    ReplyDelete
  23. Hi Frank, I'll have a closer look at this problem (and ask my colleague) and get back to You. What's the OS You're using for this installation?

    ReplyDelete
  24. Hi Robert,

    thank you for your fast reply.
    Our OS is:

    $ cat /etc/redhat-release
    Red Hat Enterprise Linux Server release 7.9 (Maipo)

    Kind regards
    Frank

    ReplyDelete
  25. Hi Robert,

    I found our error! It was a misconfiguration by us.
    We had a double configuration of AdminServerMachine:

    wls:/offline> readDomain('/oracle/mwfr12c/user_projects/domains/icisfrm')
    wls:/offline/icisfrm>cd ('/Machines')
    wls:/offline/icisfrm/Machine>ls()
    drw- AdminServerMachine
    drw- AdminServerMachine
    wls:/offline/icisfrm/Machine>

    After deleting the following code sequence in crDomain.py
    ##############################################################
    printHeader('Step: Create Unix Machine --> Set Machine Name ('+v_MachineName+') and Port ('+v_nmPort+')')
    cd('/')
    create(v_MachineName, 'UnixMachine')
    cd('Machine/' + v_MachineName)
    create(v_MachineName, 'NodeManager')
    cd('NodeManager/'+v_MachineName)
    set('ListenAddress', v_nmListenAddress)
    set('ListenPort',int(v_nmPort))
    set('NMType','ssl')

    cd('/Servers/'+v_asName)
    set('Machine',v_MachineName)
    printInfo("Step: Create Unix Machine --> Successful")
    #############################################################

    the domain will be created and started without errors.

    Kind regards
    Frank

    ReplyDelete
  26. Hi Robert,
    Thanks for this great post and need your help with ohs components installation, its giving error -
    Problem invoking WLST traceback (innermost last):
    while looking at AdminServer logs -
    Failed to find valid OHS installation

    ReplyDelete

Note: Only a member of this blog may post a comment.

Copyright © Robert Crames' Oracle Database and Middleware Blog | Powered by Blogger
Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com