Oracle Fusion Middleware & Application Server

Tuesday, August 22, 2017

Parsing Named Arguments into Python Scripts

If you are coming from the Shell Script World, you are used to parse Named Arguments into your Shell Script, e.g "-u" for Username, "-p" for Password and so on. With Python Scripts you normally pass ordered arguments into your Python Script, so you are bond with the arguments in a fixed order, while passing Named Arguments you can reshuffle them in any order.

A typical Shell Script Snippet would look like that:

export UserName=""
export PassWord=""
export URL=""

while getopts u:p:c: CurOpt; do
    case ${CurOpt} in
        u) UserName="${OPTARG}"  ;;
        p) PassWord="${OPTARG}"  ;;
        c) URL="${OPTARG}"       ;;
        ?) Usage                 ;;
    esac
done

shift $((${OPTIND}-1))

# Call a function for checking of given Parameter Values
CheckInputParams

The same you can achieve for your Python Scripts to be used with the Oracle WebLogic Server command line tool wlst.

import sys

uname=''
pword=''
url=''

def helpUsage():
   print 'Usage: test.py [-help]'
   print '      [-username] Username for the connect'
   print '      [-password] Password for the connect User'
   print '      [-url] URL for the connect'
   exit()

for i in range(len(sys.argv)):
   if sys.argv[i] in ("-help"):
           helpUsage()
   elif sys.argv[i] in ("-url"):
           if i+1 < len(sys.argv):
                   url = sys.argv[i+1]
   elif sys.argv[i] in ("-username"):
           if i+1 < len(sys.argv):
                   uname = sys.argv[i+1]
   elif sys.argv[i] in ("-password"):
           if i+1 < len(sys.argv):
                   pword = sys.argv[i+1]

if len(uname)==0 or len(pword)==0 or len(url)==0:
   print 'Missing required arguments (-url, -username, -password)'
   print ' '
   helpUsage()


connect(uname,pword,url)

#
# Perform your Tasks
#

exit()

Now you can call your Python Script with wlst and provide the required Named Arguments in any order you like, e.g.:

# Using Named Argument -help
wlst.sh test.py -help

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Usage: test.py [-help]
      [-username] Username for the connect
      [-password] Password for the connect User
      [-url] URL for the connect

Exiting WebLogic Scripting Tool.


# Using Named Arguments -username / -password / -URL
wlst.sh test.py -username weblogic -url t3://localhost:7001 -password Welcome1

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to t3://localhost:7001 with userid weblogic ...
. . .
. . .
Successfully connected to Admin Server "DEMOAdminServer" that belongs to domain "DEMODomain".

Exiting WebLogic Scripting Tool.


# Using Named Arguments, but forgot to pass a value for Argument -Password
wlst.sh test2.py -username weblogic -url t3://localhost:7001 -password

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Missing required arguments (-url, -username, -password)

Usage: test.py [-help]
      [-uname] Username for the connect
      [-password] Password for the connect User
      [-url] URL for the connect

Exiting WebLogic Scripting Tool.

With a simple small Python Block you can easily pass Named Arguments into your Python Scripts in the same way you know it with Shell Scripts.

Monday, August 21, 2017

Configure Single Sign On for Cloud Control 13c against Active Directory

In many cases you want to use your Microsoft Active Directory Login to be authenticated against your Oracle Cloud Control 13c.

Here is a step by step solution how to implement Single Sign On for your Oracle Cloud Control against Microsoft Active Directory.

Lets assume following Environment:

  • AD Domain = DEMO.COM
  • Microsoft AD Server = adserver.demo.com
  • AD LDAP Port = 389
  • Cloud Control 13c Server = cloudcontrol13c.demo.com

Windows Steps


Connect to the Windows Server Hosting your Active Directory and execute following steps

1. Create a corresponding Service Account for the Oracle Management Server (OMS) in your Active Directory:


Name the to be created Service Account = your Cloud Control Server
dsadd user="cn=<ServiceAccountName>,cn=users,dc=<Domain>,dc=<TLD>" -disabled no -pwd <Password for ServiceAccountName> -canchpwd no -mustchpwd no -pwdneverexpirer yes

# For Example
dsadd user="cn=cloudcontrol13c,cn=users,dc=demo,dc=com" -disabled no -pwd Welcome1 -canchpwd no -mustchpwd no -pwdneverexpirer yes

2. Create a keytab file:


ktpass -princ HTTP/<ServiceAccountName>.<Domain>.<TLD>@;.<Domain>.<TLD> -mapuser <ServiceAccountName> -crypto all -ptype KRB5_NT_PRINCIPAL -out c:\temp\krb5.keytab

# For Example:
ktpass -princ HTTP/cloudcontrol13c.demo.com@DEMO.COM -mapuser cloudcontrol13c -crypto all -ptype KRB5_NT_PRINCIPAL -out c:\temp\krb5.keytab

Afterwards transfer the above created keytab file named krb5.keytab to your Cloud Control 13c Server.

Cloud Control Steps


Now connect to your Server which is Hosting your Oracle Cloud Control 13c and perform following steps.

1. Create the Active Directory Authentication Provider


emctl config auth ad -ldap_host "<AD-Servername>" -ldap_port "<LDAP-PORT>" \
ldap_principal "cn=<ServiceAccountName>,cn=users,dc=<Domain>,dc=<TLD>" -ldap_credential "<Password for ServiceAccountName>" \
-user_base_dn "cn=users,dc=<Domain>,dc=<TLD>" -Group_base_dn "cn=groups,dc=<Domain>,dc=<TLD>" \
-sysman_pwd "<SYSMAN Password>"

# For Example:
emctl config auth ad -ldap_host "adserver.demo.com" -ldap_port "389" \
ldap_principal "cn=cloudcontrol13c,cn=users,dc=demo,dc=com" -ldap_credential "Welcome1" \
-user_base_dn "cn=users,dc=demo,dc=com" -Group_base_dn "cn=groups,dc=demo,dc=com" \
-sysman_pwd "Welcome1"

# Now restart your OMS
emctl stop oms -all
emctl start oms

After the restart of your OMS, connect to the WebLogic Server Console of your Oracle Cloud Control 13c, usually its the SSL Port 7101 (https://<CloudControlServer>:7101/console )
Select in the Domain Structure "Security Realms" and navigate to "Providers / Authentication"


Open the Authentication Provider EM_AD_Provider and navigate to "Configuration / Provider Specific"



Align following Attributes (activate at first in the Change Center the "Lock & Edit" Mode):

Original Attributes:
  • All Users Filter: <empty>
  • User From Name Filter: (&cn=%u) (objectclass=user))
  • User Name Attribute: cn
  • User Object Class: user
New Attributes:
  • All Users Filter: (&(sAMAccountName=*) (objectclass=user))
  • User From Name Filter: (&(sAMAccountName=%u) (objectclass=user))
  • User Name Attribute: sAMAccountName
  • User Object Class: user
Save the modifications and Activate them in the Change Center.

2. Create the JAAS Configuration File krb5Login.conf

The next step is to create the required JAAS Configuration File krb5Login.conf within the DOMAIN_HOME of your Cloud Control 13c.

# for Oracle (SUN) JDK
com.sun.security.jgss.krb5.initiate {
    com.sun.security.auth.module.Krb5LoginModule required
    principal="HTTP/cloudcontrol13c.demo.com@DEMO.COM"
    useKeyTab=true keyTab=/etc/krb5.keytab
    storeKey=true debug=true;
};
com.sun.security.jgss.krb5.accept {
    com.sun.security.auth.module.Krb5LoginModule required
    principal="HTTP/cloudcontrol13c.demo.com@DEMO.COM"
    useKeyTab=true keyTab=/etc/krb5.keytab
    storeKey=true debug=true;
};

# For IBM JDK (under AIX)
com.ibm.security.jgss.krb5.initiate {
    com.ibm.security.auth.module.Krb5LoginModule REQUIRED
    principal="http/cloudcontrol13c.demo.com"
    useKeytab="FILE:/etc/krb5.keytab"
    credsType=initiator
    debug=true;
};
com.ibm.security.jgss.krb5.accept {
    com.ibm.security.auth.module.Krb5LoginModule REQUIRED
    principal="http/cloudcontrol13c.demo.com"
    useKeytab="FILE:/etc/krb5.keytab"
    credsType=acceptor
    debug=true;
};

3. Align setDomainEnv.sh

Now we need to align the setDomainEnv.sh in the DOMAIN_HOME/bin directory. Search for the 2 lines:
EXTRA_JAVA_PROPERTIES="-Djavax.management.builder.initial=weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder ${EXTRA_JAVA_PROPERTIES}"
export EXTRA_JAVA_PROPERTIES
and add below this 2 lines following block:

if [ "${SERVER_NAME}" = "EMGC_OMS1" ] ; then
     EXTRA_JAVA_PROPERTIES="-Djava.security.krb5.realm=%lt;Domain>.<TLD> -Djava.security.krb5.kdc=<AD-Servername> -Djava.security.auth.login.config=<Path to krb5Login.conf>/krb5Login.conf -Djavax.security.auth.useSubjectCredsOnly=false -Dweblogic.security.enableNegotiate=true ${EXTRA_JAVA_PROPERTIES}"
     export EXTRA_JAVA_PROPERTIES
fi

# For Example:
if [ "${SERVER_NAME}" = "EMGC_OMS1" ] ; then
     EXTRA_JAVA_PROPERTIES="-Djava.security.krb5.realm=DEMO.COM -Djava.security.krb5.kdc=adserver.demo.com -Djava.security.auth.login.config=/u00/app/oracle/product/gc_inst_13cR1/user_projects/domains/GCDomain/krb5Login.conf -Djavax.security.auth.useSubjectCredsOnly=false -Dweblogic.security.enableNegotiate=true ${EXTRA_JAVA_PROPERTIES}"
     export EXTRA_JAVA_PROPERTIES
fi

5. Configure Single Sign On within OMS

The next step is to create an external role within OMS, this external role must be named exactly the same as your corresponding AD Group for the OMS Users

emcli create_role -name="oracle_dba" -type="EXTERNAL_ROLE" -desc="Active Directory Group for oracle_dba"

Now configure the SSO for the OMS

emctl set property -name oracle.sysman.core.security.sso.type -value "OTHER"
emctl set property -name oracle.sysman.core.security.auth.is_external_authentication_enabled -value "true"
emctl set property -name oracle.sysman.emSDK.sec.DirectoryAuthenticationType -value "SSO"
emctl set property -name oracle.sysman.core.security.auth.autoprovisioning -value "true"

After that perform a restart of your OMS:

emctl stop oms -all
emctl start oms

Now, when you are connecting the first time to the Cloud Control 13c and logging in with your AD-User, there will be automatically created the SSO User within your Cloud Control 13c and you can connect with your AD-User and corresponding AD-Password.

Thursday, July 27, 2017

Check Composite State of Oracle SOA Suite by Command Line

I was currently fighting a bit with the monitoring of Oracle SOA Suite 12c Composites.

The goal was to check the state of deployed Composites on an Oracle SOA Suite 12c with following requirements/dependencies:

  • No Oracle Cloud Control
  • Capture only Active Composites and not Retired Composites
After some discussions with colleagues and a lot of Google and serveral tests with Python Scripts in wlst, I came to following solution:

  • one main Pythin Script, called check_composite_state.py which is checking the State of a non retired given Composite Name for a given Partition|Folder and a given Managed Server
  • one property file called domain.properties which will be used by the Python Script in order to build the required connect string to the Admin Server of the SOA Suite
  • one wrapper Shell Script, which takes the required 3 Arguments (Name of Managed Server, Composite Name and Partition|Folder Name)

Property File domain.properties
# Replace the below given values with your settings
admin.url=wlssoa1:7001
admin.userName=weblogic
admin.password=Oracle12c

Python Script check_composite_state.py
# ============================================================
#
# Script: check_composite_state.py
#
# Author: Dirk Nachbar, http://dirknachbar.blogpost.com
#
# Purpose: Checks the state of a given Composite
#          for Oracle SOA Suite 12c
#
# ============================================================

import sys;
from java.util import Date
from java.text import SimpleDateFormat
from java.io import File
from java.io import FileOutputStream
from java.io import FileInputStream

# Load the WLS Connection Credential and establish the connection
propInputStream = FileInputStream("domain.properties")
configProps = Properties()
configProps.load(propInputStream)
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")
managedServer=sys.argv[1]
compositeName=sys.argv[2]
partitionName=sys.argv[3]

# Initialization of Logfile
f = File('logs/' + compositeName + '.log')
fos = FileOutputStream(f)
theInterpreter.setOut(fos)

# Perform the Connect to the AdminServer of the SOA Suite
connect(adminUserName,adminPassword,adminURL)

domainRuntime()

for n in mbs.queryNames(ObjectName('oracle.soa.config:Location=' + managedServer + ',partition=' + partitionName + ',j2eeType=SCAComposite,name="' + compositeName + '",*'), None):
    RetiredFlag = mbs.getAttribute(n,'Mode')
    if RetiredFlag != 'retired':
        print 'Name: ' + mbs.getAttribute(n, 'Name')
        print 'Mode: ' + mbs.getAttribute(n,'Mode')
        print 'State: ' + mbs.getAttribute(n,'State')


Wrapper Shell Script check_composite_state.sh
In line 13 of the Script, align the Variable OracleHome to your Oracle Home Location
In line 66 of the Script, align the directory location were to find the check_composite_state.py Python Script
#!/bin/bash
# ============================================================
#
# Script: check_composite_state.sh
#
# Author: Dirk Nachbar, http://dirknachbar.blogspot.com
#
# Purpose: Wrapper Script to check the state of a given Composite
#          for Oracle SOA Suite 12c
#
# ============================================================

OracleHome=/data/oracle/product/fmw-soa-12.2.1.2.0

#---------------------------------------------------------------------
Usage()
#
# PURPOSE: Displays the Usage of the script
#---------------------------------------------------------------------
{
cat << EOF
Usage: check_composite_state.sh -s <ManagedServer> -c <CompositeName> -p <Partition|Folder>
       Monitoring script for SOA Suite Composite

Parameters:
   -s: Name of the Managed SOA Server
   -c: Name of Composite to be checked
   -p: Name of Parition | Folder

e.g. check_composite_state.sh -s soa_server1 -c PayPal -p default

EOF
exit 1
}

#---------------------------------------------------------------------
CheckParams()
#
# PURPOSE: Checks the input Parmeter
#---------------------------------------------------------------------
{
    if [ "${ManagedServer}" = "" ] ; then
        echo "ERR: Missing parameter(s), the flags -s must be used."
        Usage
    fi

    if [ "${CompositeName}" = "" ] ; then
        echo "ERR: Missing parameter(s), the flags -c must be used."
        Usage
    fi

    if [ "${Partition}" = "" ] ; then
        echo "ERR: Missing parameter(s), the flags -p must be used."
        Usage
    fi

}

#---------------------------------------------------------------------
CallCheckCompositeState()
#
# PURPOSE: Calls the check_composite_state.py Script
#---------------------------------------------------------------------
{

${OracleHome}/oracle_common/common/bin/wlst.sh /home/oracle/check_composite_state.py ${ManagedServer} ${CompositeName} ${Partition}

}

#---------------------------------------------------------------------
# MAIN
#---------------------------------------------------------------------

ManagedServer=''
CompositeName=''
Partition=''

while getopts s:c:p:h: CurOpt; do
    case ${CurOpt} in
        s) ManagedServer="${OPTARG}" ;;
        c) CompositeName="${OPTARG}" ;;
        p) Partition="${OPTARG}"     ;;
        h) Usage           exit 1    ;;
        ?) Usage           exit 1    ;;
    esac
done
shift $((${OPTIND}-1))

if [ $# -ne 0 ]; then
    Usage
fi

# Check Input Parameters
CheckParams

# Start the Check State of Composite
CallCheckCompositeState

Create the 3 above provided files in one location, align the said Variables and/or directory location and create a subdirectory called "logs" in the directory. Than call the Wrapper Shell Script with following options:
#
# ./check_composite_state.sh -s <Name of Managed Server> -c <Composite Name> -p <Partition|Folder>
# for example:
./check_composite_state.sh -s soa_server1 -c PayPal -p default


Under the directory logs you will find an outfile with naming convention CompositeName.log with the Status of your Composite
cd logs
cat PayPal.log

Connecting to t3://wlssoa1:7001 with userid weblogic ...
Successfully connected to Admin Server "DEVAdminServer" that belongs to domain "dev_domain".

Warning: An insecure protocol was used to connect to the server.
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

Location changed to domainRuntime tree. This is a read-only tree
with DomainMBean as the root MBean.
For more help, use help('domainRuntime')

Name: PayPal [1.0]
Mode: active
State: on



Happy Composite State Checking ... :-)

Thursday, July 20, 2017

Oracle Forms 12c oracle.security.jps.JpsException Error after Database change

My current huge Oracle Forms 12c Migration Project is still going on and every day we have some new problems.

After the DBA's were moving our Repository Database for the new Oracle Forms 12c environments (without any notice to us ...), nothing were working again on our environment :-)

So the first step, were to stop all processes from our Oracle Forms 12c environment:
  • Reports Server
  • all Managed Servers containing Oracle Reports and Oracle Forms Applications
  • Admin Server
Next step, we aligned the 4 JDBC Connections under $DOMAIN_HOME/config/jdbc in order to point to the new Database Server location:
  • LocalSvcTblDataSource-jdbc.xml
  • opss-audit-jdbc.xml
  • opss-auditview-jdbc.xml
  • opss-datasource-jdbc.xml
After that I tried to startup the Admin Server ... after some seconds the Admin Server stopped directly and in the corresponding logfile of the Admin Server I could find following error message:
<BEA-000362> <Server failed. Reason:
There are 1 nested errors:
oracle.security.jps.JpsException: oracle.security.jps.service.policystore.PolicyStoreException: javax.persistence.PersistenceException: java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to java.sql.Driver
        at oracle.security.jps.internal.config.OpssCommonStartup.start(OpssCommonStartup.java:215)
        at oracle.security.jps.wls.JpsWlsStartup.start(JpsWlsStartup.java:104)
        at oracle.security.jps.JpsStartup.start(JpsStartup.java:210)
        at oracle.security.jps.wls.JpsDefaultService.start(JpsDefaultService.java:74)
        . . .
        . . .
Caused by: oracle.security.jps.service.policystore.PolicyStoreException: javax.persistence.PersistenceException: java.lang.ClassCastException: oracle.jdbc.xa.client.OracleXADataSource cannot be cast to java.sql.Driver
        at oracle.security.jps.internal.policystore.rdbms.JpsDBDataManager.processJPAException(JpsDBDataManager.java:2658)
        at oracle.security.jps.internal.policystore.rdbms.JpsDBDataManager.existsTable(JpsDBDataManager.java:1682)
        . . .
        . . .

I verfied once again, if all JDBC Connections were defined correctly and I didn't found any typomistake or error ...

Finally, I came across the configuration files for the Oracle Platform Security for Java Configuration Files jps-config.xml and jps-config-jse.xml under $DOMAIN_HOME/config/fmwconfig. Within these 2 Configuration Files you also have to align the changed Database Server location.

In jps-config.xml go to line 22 and align the following line with your new settings:
# Line 22
<property name="jdbc.url" value="jdbc:oracle:thin:@//dbserver:listener_port/DB_ServiceName"/>

In the jps-config-jse.xml you have to align 2 lines with your new settings, line number 20 and line number 168:
# Line 20
<property name="jdbc.url" value="jdbc:oracle:thin:@//dbserver:listener_port/DB_ServiceName"/>

# Line 168
<property name="audit.loader.jdbc.string" value="jdbc:oracle:thin:@//dbserver:listener_port/DB_ServiceName"/>
After that you can startup your Admin Server and your Managed Servers for your Oracle Forms 12c environment without any problems :-)

Wednesday, July 19, 2017

Oracle Container Registry - First Impressions

After my long holiday, I discovered today that the Oracle Container Registry is now world wide accessible :-) before the Oracle Container Registry were only accessible from USA, Australia and UK.

The Oracle Container Registry contains several types of Docker images:
  • Database: Oracle Enterprise Edition, Oracle Standard Edition and Instant Client
  • Java: Oracle Java SE
  • Middleware: Oracle Coherence, Oracle Tuxedo, Oracle WebLogic Server, Oracle WebTier
  • MySQL: MySQL Community Server
  • OS: Oracle Linux, Container Registry
  • OpenStack: contains currently 95 API's and so on ...
At first you need to access the website https://container-registry.oracle.com , click on the top right to sign in, you will need an OTN Account and follow the registration process.


After you have completed your registration to the Oracle Container Registry just Sign In and you will be directed automatically to following website:


From this point you can get down to Docker Image you are interested, for example the Middleware Section:


Within each Main Section you will find different Repositores, e.g. Oracle Coherence, Oracle Tuxedo, Oracle WebLogic Server and Oracle Web Tier.

When you select a specific Repository, e.g. Oracle WebLogic Server, you will be directed to the Repository Info Page:



On this page you will find various informations about the Repository and informations how to pull the Image, how to create e.g. a WebLogic Domain with an Admin Server and so on.

Let's try it.

# At First Login with your Docker
# to the Oracle Container Registry
din@server> docker login container-registry.oracle.com
Username: xx@xx.xxx
Password: 
Email: xx@xx.xxx
WARNING: login credentials saved in /home/din/.docker/config.json
Login Succeeded

# Now let's pull the Oracle WebLogic Server
din@server> docker pull container-registry.oracle.com/middleware/weblogic
Using default tag: latest

Please login prior to pull:
Username: xx@xx.xxx
Password: 
Email: xx@xx.xxx
latest: Pulling from middleware/weblogic
78a05301de27: Pull complete 
1bd2d038d806: Pull complete 
4b7f2458c2b0: Pull complete 
9b1f6785ca2d: Pull complete 
b83e45ee2903: Pull complete 
Digest: sha256:f42f1a6036e240c32e9438dfba3a883da7f99d10b26a1ca6efe6e0e2f5187af9
Status: Downloaded newer image for container-registry.oracle.com/middleware/weblogic:latest

# Now let's start the Oracle WebLogic Domain
din@server> docker run -d -p 7001:7001 container-registry.oracle.com/middleware/weblogic:12.2.1.1
7cdddadc00d8c60d3f310d98bd5f1f0e35d55c305c97195142849ae2bc02772c

# Wait some minutes and check the Container ID in order
# to grep from the logs the newly generated password
# for the WebLogic Admin User
din@server> docker ps
CONTAINER ID        IMAGE                                                        COMMAND                  CREATED              STATUS              PORTS                    NAMES
7cdddadc00d8        container-registry.oracle.com/middleware/weblogic:12.2.1.1   "/u01/oracle/createAn"   About a minute ago   Up About a minute   0.0.0.0:7001->7001/tcp   condescending_swartz

din@server> docker logs 7cdddadc00d8 | grep password
    Oracle WebLogic Server Auto Generated Admin password: d76074ec
*  password assigned to an admin-level user.  For *

Now you can open your Browser and access the following website http://localhost:7001/console and login with the Username weblogic and the password you retrieved from the above shown docker logs command.



There are some small pain points:

  • The current Release of the Oracle WebLogic Server is only 12.2.1.1.0, so its not the actual latest Release
  • The acceptance of the Oracle Standard Terms and Restrictions are only valid for 8 hours, so if you want to pull something new after one day, you have to get back to the Oracle Container Registry Website and re-accept the Oracle Standard Terms and Restrictions

But nevertheless, the Oracle Container Registry is a great option provided by Oracle to get quickly Docker Images for the main product line without any pain to write your own Docker Build Files.

Additional Note 21st July 2017: The above mentioned 8 hours expiration time of the acceptance of the Oracle Standard Terms and Restrictions is no longer valid, Thanks @MikeRaab for the hint


Tuesday, July 18, 2017

Oracle Forms 12c Java Web Start only shows Splash Screen

I am currently working in a project for migrating several Oracle Forms 11g Applications to Oracle Forms 12c.
One requirement within this project is to use Oracle Forms 12c with Java Web Start in order to get rid of any kind of browser dependencies and to be independent from the classical Java Applet.

The configuration of Java Web Start usage within the formsweb.cfg is really straight forward and simple, just follow the Oracle Documentation.

The first test failed as usual :-) I was copying the jnlp file to my local desktop, got a JDK 1.8.0 Update 121 on my local desktop and run following command from the command line:

cd $JAVA_HOME/bin
./javaws /home/oracle/test_webstart.jnlp


What happened was that just the Java Logo Splash Screen showed up for a second and disappeared ...


Cool, I was trying the same on different laptops, every time the same result.

After some investigations, I found the solution, simply open your Java Control Panel (Windows User: System Control and search for Java / Linux User: start from $JAVA_HOME/bin the binary jcontrol / Mac Users: Open System Preferences and click Java) and click the button "Settings..." under the Section "General / Temporary Internet Files"


Check if the Checkbox in front of "Keep temporary files on my computer." is activated.



Mark the Checkbox in front of "Keep temporary files on my computer.", Click OK and in the Main Java Control Panel click the button "Apply".



Now your Oracle Forms should work as Java Web Start Application :-)


Tuesday, June 6, 2017

Find all configured SystemComponents in Oracle Fusion Middleware - The RESTFul way

Today, just a quick post on how to find all your configured System Components within an Oracle Fusion Middleware / Oracle WebLogic Server Environment.

Let's say you are having an Oracle Forms & Reports Environment based on an Oracle WebLogic Server. Within your environment you have configured various so called System Components, and you need to know all the names and the corresponding System Component Type, like:
  • Oracle HTTP Server (OHS)
  • Oracle Reports Standalone Servers
  • Oracle Forms
With the Oracle WebLogic Server RESTFul Management Services you are able to list them all by name and including the type of System Component.

Simply run following cURL command against your WebLogic Server hosting your Oracle Fusion Middleware Components:

# Align the password of your Oracle WebLogic User
# Align the hostname and port of your WebLogic Server
curl \
--user weblogic:Oracle12c \
-H X-Requested-By:MyClient \
-H Accept:application/json \
-H Content-Type:application/json \
-d "{
     fields: [ 'name' ], links: [],
      children: {
         systemComponents: {
             fields: [ 'name' , 'componentType'],
             links: []
                            }
                 }
}" -X POST http://localhost:7001/management/weblogic/latest/domainConfig/search

{
    "name": "FRDEVEL",
    "systemComponents": {"items": [
        {
            "componentType": "FORMS",
            "name": "forms1"
        },
        {
            "componentType": "OHS",
            "name": "ohs1"
        },
        {
            "componentType": "ReportsToolsComponent",
            "name": "reptools1"
        },
        {
            "componentType": "ReportsServerComponent",
            "name": "rep_server1"
        },
        {
            "componentType": "ReportsServerComponent",
            "name": "rep_server2"
        }
    ]}


Unfortunately you can not filter over componentType, as this is not a collection and therefor a query restriction on the componentType will be ignored :-(

This method is a bit quicker then going through your $DOMAIN_HOME/system_components folder and get all your configured System Components.


Wednesday, May 31, 2017

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

Today, I will have a novelty on my blog. This blogpost is driven by a joint venture between 3 consultants based in 2 countries (Switzerland and Germany) and working for 3 different consulting companies (Robert Crames = Edorex, Jan-Peter Timmermann = AuraPlayer and myself = Trivadis).

As we three consultants, Robert Crames (https://robertcrames.blogspot.ch), Jan-Peter Timmermann (https://jan-peter.me ) and myself are intensively working with Oracle Fusion Middleware Products, which also covers Oracle Forms & Reports, we’re stumbling over following problem with Oracle Forms & Reports 12c:

  • Missing possibility during the WebLogic Domain creation for Forms & Reports to use a “record” Feature
Different contacts with Oracle and researches within My Oracle Support, confirmed that the “record” feature is no longer available within Oracle Forms & Reports 12c.
Therefore, in case you will have to create on several servers Oracle Forms & Reports environments, you will need a lot of patience while clicking through the Configuration Wizard for WebLogic Domain creation. So automation is quite impossible for a complete installation and configuration ☹

So, the joint venture (Robert, Jan-Peter and myself) we were pooling our knowledge and created a script set for “How to install and configure an Oracle Forms & Reports 12c environment completely unattended and silent”.

Here I will present the first part:
  • Installation of JDK
  • Installation of Oracle WebLogic Server Infrastructure 12.2.1.2.0
  • Installation of Oracle Forms & Reports 12.2.1.2.0
The above steps are requiring following files:
  • setLocalEnv.sh
    • here we define all necessary values for the installation, e.g. ORACLE_BASE, JDK Release, ORACLE_HOME and so on
  • silent_jdk.sh
    • installs under the Oracle Software Owner a private JDK
  • silent_wls_infra.sh
    • Install the Oracle WebLogic Server Infrastructure 12.2.1.2.0
    • Requires setLocalEnv.sh, oraInst.loc and response_file_wls_infra.rsp
  • silent_forms.sh
    • Installs the Oracle Forms & Reports 12.2.1.2.0 over the prior installed Oracle WebLogic Server Infrastructure
    • Requires setLocalEnv.sh, oraInst.loc and response_file_forms.rsp
Place the following files all under one directory, e.g. /u00/app/oracle/install.


Download the required Oracle Software Installation sources and place them as well in the same directory as the script set
First lets have a quick look on the setLocalEnv.sh. I will just explain the for now required variables, the remaining variables will be described in Robert’s Blogpost

For the first steps, we need to have a look on following environment variables in the setLocalEnv.sh
  • JDK_SOURCE: here we define the JDK installation source file (tar.gz)
  • JDK_REL: is the JDK Release, the syntax is for JDK 8 = 1.8.0_<updateversion>
  • ORACLE_BASE: defines our ORACLE_BASE
  • INT_ORACLE_HOME: defines our target ORACLE_HOME
  • The remaining variables will be explained in Robert's second Blogpost
# 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_REL=1.8.0_131

# 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=
export DBROLE=SYSDBA
export COMPONENTPWD=
export SCHEMA_PREFIX=$DOMAIN_NAME
export DB_HOST=
export DB_PORT=
export DB_SERVICE=
export DB_OMF=true
export DB_USER_PW=welcome1
export PWDFILE=$SCRIPT_HOME/passwords.txt

The first script to execute is the silent_jdk.sh, this script simply unpacks the JDK under the defined $ORACLE_BASE/product/jdk$JDK_REL
silent_jdk.sh

#!/bin/bash
#=====================================================================
#
# $Id: silent_jdk.sh $
#
# PURPOSE: Script to install JDK
#
# PARAMETERS: none
#
# NOTES:   setLocalEnv.sh must be present and aligned
#
# AUTHOR:  Dirk Nachbar, https://dirknachbar.blogspot.com
#
# MODIFIED:
#
#
#=====================================================================

source setLocalEnv.sh

mkdir -p ${ORACLE_BASE}/product/
cp ${JDK_SOURCE} ${ORACLE_BASE}/product/
cd ${ORACLE_BASE}/product/
gunzip ${JDK_SOURCE}
JDK_TAR=${JDK_SOURCE::-3}
tar -xvf ${JDK_TAR}
rm ${ORACLE_BASE}/product/${JDK_TAR}


The next step is to install the Oracle WebLogic Server Infrastructure 12.2.1.2.0, here we are using the silent installation option with a response file and an oraInst.loc file

silent_wls_infra.sh

#!/bin/bash
#=====================================================================
#
# $Id: silent_wls_infra.sh $
#
# PURPOSE: Script to install WebLogic Infrastructure
#
# PARAMETERS: none
#
# NOTES:   setLocalEnv.sh must be present and aligned
#
# AUTHOR:  Dirk Nachbar, https://dirknachbar.blogspot.com
#
# MODIFIED:
#
#
#=====================================================================

source setLocalEnv.sh

export JAVA_HOME=${ORACLE_BASE}/product/jdk${JDK_REL}
export PATH=$JAVA_HOME/bin:$PATH

java -jar fmw_12.2.1.2.0_infrastructure.jar -silent -responseFile ${SCRIPT_HOME}/response_file_wls_infra.rsp -jreLoc ${JAVA_HOME} -invPtrLoc ${SCRIPT_HOME}/oraInst.loc


The referenced response file for the silent_wls_infra.sh Installation script looks as follows
response_file_wls_infra.rsp

[ENGINE]
#DO NOT CHANGE THIS.
Response File Version=1.0.0.0.0
[GENERIC]
#Set this to true if you wish to skip software updates
DECLINE_AUTO_UPDATES=true
#My Oracle Support User Name
MOS_USERNAME=
#My Oracle Support Password
MOS_PASSWORD=<SECURE VALUE>
#If the Software updates are already downloaded and available on your local system, then specify the path to the directory where these patches are available and set SPECIFY_DOWNLOAD_LOCATION to true
AUTO_UPDATES_LOCATION=
#Proxy Server Name to connect to My Oracle Support
SOFTWARE_UPDATES_PROXY_SERVER=
#Proxy Server Port
SOFTWARE_UPDATES_PROXY_PORT=
#Proxy Server Username
SOFTWARE_UPDATES_PROXY_USER=
#Proxy Server Password
SOFTWARE_UPDATES_PROXY_PASSWORD=<SECURE VALUE>
#The oracle home location. This can be an existing Oracle Home or a new Oracle Home
ORACLE_HOME=/appl/oracle/product/fmw-fr-12.2.1.2.0
#Set this variable value to the Installation Type selected. e.g. Fusion Middleware Infrastructure, Fusion Middleware Infrastructure With Examples.
INSTALL_TYPE=Fusion Middleware Infrastructure
#Provide the My Oracle Support Username. If you wish to ignore Oracle Configuration Manager configuration provide empty string for user name.
MYORACLESUPPORT_USERNAME=
#Provide the My Oracle Support Password
MYORACLESUPPORT_PASSWORD=<SECURE VALUE>
#Set this to true if you wish to decline the security updates. Setting this to true and providing empty string for My Oracle Support username will ignore the Oracle Configuration Manager configuration
DECLINE_SECURITY_UPDATES=true
#Set this to true if My Oracle Support Password is specified
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
#Provide the Proxy Host
PROXY_HOST=
#Provide the Proxy Port
PROXY_PORT=
#Provide the Proxy Username
PROXY_USER=
#Provide the Proxy Password
PROXY_PWD=<SECURE VALUE>
#Type String (URL format) Indicates the OCM Repeater URL which should be of the format [scheme[Http/Https]]://[repeater host]:[repeater port]
COLLECTOR_SUPPORTHUB_URL=

The referenced oraInst.loc file for the silent_wls_infra.sh Installation script looks as follows
oraInst.loc
inst_group=oinstall
inventory_loc=/u00/app/oracle/oraInventory

The last step is to install the Oracle Forms & Reports 12.2.1.2.0 components over the prior installed Oracle WebLogic Server Infrastructure 12.2.1.2.0.
With this step is one speciality, I am replacing the originally provided frmconfighelper.sh script with my modified version described in my Blogpost https://dirknachbar.blogspot.ch/2017/05/oracle-forms-12c-frmconfighelper.html

For this installation step we are using the silent_forms.sh, which is referencing a corresponding response file and the same oraInst.loc as we used before for the Oracle WebLogic Server Infrastructure installation

silent_forms.sh

#!/bin/bash
#=====================================================================
#
# $Id: silent_forms.sh $
#
# PURPOSE: Script to install Oracle Forms and Reports
#           on top of existing WebLogic Server Infrastructure Installation
#
# PARAMETERS: none
#
# NOTES:   setLocalEnv.sh must be present and aligned
#          Modified frmconfighelper.sh will be provided
#                   with more functions
#
# AUTHOR:  Dirk Nachbar, https://dirknachbar.blogspot.com
#
# MODIFIED:
#
#
#=====================================================================

source setLocalEnv.sh

export JAVA_HOME=${ORACLE_BASE}/product/jdk${JDK_REL}

./fmw_12.2.1.2.0_fr_linux64.bin -silent -responseFile ${SCRIPT_HOME}/response_file_forms.rsp -jreLoc ${JAVA_HOME} -invPtrLoc ${SCRIPT_HOME}/oraInst.loc

mv ${MW}/forms/provision/frmconfighelper.sh ${MW}/forms/provision/frmconfighelper.sh.org
cp ${SCRIPT_HOME}/frmconfighelper.sh ${MW}/forms/provision/
chmod +x ${MW}/forms/provision/frmconfighelper.sh


The referenced response file response_file_forms.rsp for the silent_forms.sh Installation script looks as follows

[ENGINE]
#DO NOT CHANGE THIS.
Response File Version=1.0.0.0.0
[GENERIC]
#Set this to true if you wish to skip software updates
DECLINE_AUTO_UPDATES=true
#My Oracle Support User Name
MOS_USERNAME=
#My Oracle Support Password
MOS_PASSWORD=<SECURE VALUE>
#If the Software updates are already downloaded and available on your local system, then specify the path to the directory where these patches are available and set SPECIFY_DOWNLOAD_LOCATION to true
AUTO_UPDATES_LOCATION=
#Proxy Server Name to connect to My Oracle Support
SOFTWARE_UPDATES_PROXY_SERVER=
#Proxy Server Port
SOFTWARE_UPDATES_PROXY_PORT=
#Proxy Server Username
SOFTWARE_UPDATES_PROXY_USER=
#Proxy Server Password
SOFTWARE_UPDATES_PROXY_PASSWORD=<SECURE VALUE>
#The oracle home location. This can be an existing Oracle Home or a new Oracle Home
ORACLE_HOME=/u00/app/oracle/product/fmw-fr-12.2.1.2.0
#Set this variable value to the Installation Type selected as either Standalone Forms Builder OR Forms and Reports Deployment
INSTALL_TYPE=Forms and Reports Deployment

Putting all together, just create all the above described files into one directory on your Linux Server, e.g. /u00/app/oracle/install. Make the *.sh scripts executable (chmod +x *.sh) and execute them in following order:
cd /u00/app/oracle/install
chmod +x *.sh
./silent_jdk.sh
./silent_wls_infra.sh
./silent_forms.sh

Now, you have the base for the next steps, described by Robert Crames in his Blogpost http://robertcrames.blogspot.ch/2017/05/how-to-install-and-configure-oracle.html

After you are done with reading and applying Robert’s Part, stay tuned for my next Blogpost “How to automate Multiple Managed Servers for Oracle Forms”


Tuesday, May 16, 2017

Oracle Forms 12c: frmconfighelper - enable_ohs

Yesterday I was blogging about how to create new Forms Managed Servers and how to deploy a new formsapp into them with the frmconfighelper tool (http://dirknachbar.blogspot.com/2017/05/oracle-forms-122120-multiple-managed.html).

Today I was testing the function enable_ohs from the frmconfighelper tool, which is mainly dedicated to generate a forms.conf file in your Oracle HTTP Server which contains the directives for your Forms Environment.

oracle@server> cd $ORACLE_HOME/forms/provision
oracle@server> ./frmconfighelper.sh
using log file /home/oracle/frmconfighelper/logs/frmconfighelper_2017_05_15_20_49_31.log ..........
-----------------------------------------------------------------
   Forms configuration helper script                             
-----------------------------------------------------------------
 This script helps administrators perform some of the Forms      
 related configuration tasks                                     
                                                                 
**Important**: - Please backup the Weblogic domain before        
                 performing any administration tasks on it using 
                 this script.                                    
               - You can run enable_sso, enable_webgate          
                 and enable_sso_ssl options  only once.          
                                                                 
 frmconfighelper.sh <option> <arguments>                         
                                                                 
 options:                                                        
    - enable_ohs <domain-home> <ohs-instance> <forms-managed-server1-host> 
                 <forms-managed-server1-port> [<forms-managed-server2-host> 
                 <forms-managed-server2-port>..]                    
. . .
. . .

As you can see from the above listing, the tool will generate a forms.conf file under the $DOMAIN_HOME/config/fmwconfig/components/OHS/<OHS_INSTANCE>/moduleconf with your provided Servers on which your Forms Managed Servers are running and their Port.
But the disadvantage of the function enable_ohs is, that:

  • the Location tag in the forms.conf is hardcoded with /forms
  • the directive is only for a Forms Cluster Environment
In case you have just a single Managed Server, you can not use it.
In case you have created a new Managed Server with an own defined Context Root (see my blogpost from 15th May 2017) you can not use it.
So, I had a closer look on the frmconfighelper.sh and did some modifications, so that I have now 2 functions for enable_ohs:
  • enable_ohs_cluster
  • enable_ohs_single
You can find my modified frmconfighelper.sh here for download, as its too long to provided here as inline text: https://drive.google.com/file/d/0Bziqha1Q1rglcng4dGhDM0p6TDA/view?usp=sharing
Transfer the new version to your target server, make a backup copy of the original frmconfighelper.sh under $ORACLE_HOME/forms/provision and place my modified frmconfighelper.sh in the same location.

The enable_ohs_cluster is mainly the same as the original version, just extended for one parameter for the Root-Context of your Formsapp

oracle@server> ./frmconfighelper.sh
. . .
. . .
 enable_ohs_cluster:                                             
    - domain-home    : Domain Home directory                     
    - ohs-instance   : OHS instance name (example ohs1)          
    - Forms Context  : Root Context (example forms)              
    - forms-managed-server(n)-host : Forms managed server host   
    - forms-managed-server(n)-port : Forms managed server port   
. . .
. . .
 examples:                                                       
                                                                 
  enable ohs cluster routing to forms managed servers                    
 ./frmconfighelper.sh enable_ohs_cluster /scratch/user_projects/domain/base_domain ohs1 sales wlshost.example.com 9001 wlshost.example.com 9010

The enable_ohs_single is newly added and will generate you a forms.conf with the correct directive for a single Forms Managed Server and the flexibility to provide your own Root-Context.
oracle@server> ./frmconfighelper.sh
. . .
. . .
 enable_ohs_single:                                              
    - domain-home    : Domain Home directory                     
    - ohs-instance   : OHS instance name (example ohs1)          
    - Forms Context  : Root Context (example forms)              
    - forms-managed-server-host : Forms managed server host      
    - forms-managed-server-port : Forms managed server port   
. . .
. . .
 examples: 

  enable ohs single routing to forms managed server              
  ./frmconfighelper.sh enable_ohs_single /scratch/user_projects/domain/base_domain ohs1 finance wlshost.example.com 9020

After you have executed either the enable_ohs_cluster or enable_ohs_single function, keep in mind that you have to restart your OHS, so that the newly added config file will be captured by the OHS.

Monday, May 15, 2017

Oracle Forms 12.2.1.2.0 - Multiple Managed Servers via frmconfighelper

In October 2016 I was blogging how to create multiple Oracle Forms 12c Multiple Managed Servers.
In case you are already on the latest Oracle Forms 12.2.1.2.0 Release, you can now create in a really comfortable way multiple Oracle Forms Managed Servers and deploy the necessary formsapp into your newly created Managed Server.

Since Oracle Forms 12.2.1 there is a small not really well know tool added to Oracle Forms - frmconfighelper. According the documentation (12.2.1.0.0 / 12.2.1.1.0 / 12.2.1.2.0) the frmconfighelper tool contains 5 functions (http://docs.oracle.com/middleware/12212/formsandreports/deploy-forms/GUID-AE8C9D19-BC55-4AD7-A6F0-A36843E3FE83.htm#FSDEP860) :
  • enable_ohs
  • deploy_app
  • update_app
  • enable_sso
  • enable_webgate
But when you call the frmconfighelper in Forms 12.2.1.2.0 you will find some functions which are not documented :-)

oracle@server> cd $ORACLE_HOME/forms/provision
oracle@server> ./frmconfighelper
using log file /home/oracle/frmconfighelper/logs/frmconfighelper_2017_05_15_20_49_31.log ..........
-----------------------------------------------------------------
   Forms configuration helper script                             
-----------------------------------------------------------------
 This script helps administrators perform some of the Forms      
 related configuration tasks                                     
                                                                 
**Important**: - Please backup the Weblogic domain before        
                 performing any administration tasks on it using 
                 this script.                                    
               - You can run enable_sso, enable_webgate          
                 and enable_sso_ssl options  only once.          
                                                                 
 frmconfighelper.sh <option> <arguments>                         
                                                                 
 options:                                                        
    - enable_ohs <domain-home> <ohs-instance> <forms-managed-server1-host> 
                 <forms-managed-server1-port> [<forms-managed-server2-host> 
                 <forms-managed-server2-port>..]                    
                                                                 
    - create_machine <wls-machine-name> <machine-host-name>      
                                                                 
    - create_managed_server <managed-server-name> <wls-machine-name> 
                            <managed-server-port> <standalone>   
                                                                 
    - deploy_app <new-context-root> <new-servlet-alias> <target>
                                                                 
    - update_app <new-context-root> <new-servlet-alias>
                                                                 
    - enable_sso <oam-host> <oam-port> <ohs-host> <ohs-port>     
                 <domain-home> <ohs-instance>                    
                                                                 
    - enable_sso_ssl <oam-host> <oam-port> <ohs-host> <ohs-ssl-port> 
                     <ohs-non-ssl-port> <domain-home> <ohs-instance> 
                                                                 
    - enable_webgate <domain home> <ohs-instance> 
                                                                 
    - help (or no option): prints help                           
                                                                 
-----------------------------------------------------------------
 options description:                                            
                                                                 
. . .
. . .

As you can see, under Oracle Forms 12.2.1.2.0 the frmconfighelper contains in reality 8 functions, so 3 more than documented:
  • create_machine
  • create_managed_server
  • enable_sso_ssl
Within this blogpost I will focus on the create_managed_server function in combination with the function deploy_app.

Lets say, you have a running Oracle Forms & Reports 12.2.1.2.0 environment with the 2 classical Managed Servers MS_FORMS & MS_REPORTS.
Now you are having the requirements to create a new Managed Server called MS_HR_APP for an independent Oracle Forms Application. Under Forms 11g you can achieve this by following the MOS Note 955822.1 which was not really straight forward. Now with Oracle Forms 12.2.1.2.0 you just need 2 commands :-)

The first command is using the function create_managed_server, which comes with following options:

  • create_managed_server:
    • managed-server-name: Managed server name - wls-machine-name : WLS machine name
    • managed-server-port: Managed server port number
    • standalone (optional): indicates standalone managed server which is not part of any cluster.
oracle@server> cd $ORACLE_HOME/forms/provision
oracle@server> ./frmconfighelper.sh create_managed_server MS_HR_APP AdminServerMachine 9010 standalone

running frmconfighelper.sh create_managed_server
using log file /home/oracle/frmconfighelper/logs/frmconfighelper_2017_05_15_21_33_56.log ..........

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

frmconfighelper.py output
-------------------------------b-e-g-i-n--------------------------------------------
Please enter your username :weblogic
Please enter your password :
Please enter your server URL [t3://localhost:7001] :
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server "AS_FRDEVEL" that belongs to domain "FRDEVEL".

Warning: An insecure protocol was used to connect to the server. 
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

processCreateManagedServer
processing createManagedServer MS_HR_APP
createServer MBean: [MBeanServerInvocationHandler]com.bea:Name=MS_HR_APP,Type=Server
configuring standalone managed server
Target JRF components to "MS_HR_APP"
Copying JRF configuration files from /u00/app/oracle/product/fmw-fr-12.2.1.2.0/oracle_common/modules to /u00/app/oracle/user_projects/domains/FRDEVEL/config/fmwconfig/servers/MS_HR_APP
Update JRF changes to domain /u00/app/oracle/user_projects/domains/FRDEVEL in online mode
frmconfighelper.py script returning ...
------------------------------------------------------------------------------------
command :createManagedServer succeeded... 

-------------------------------e-n-d------------------------------------------------

Now we have created a new standalone Managed Server for our next step to deploy the formsapp into it by using an own context root and an own servlet alias. To deploy the formsapp we will use the function deploy_app from the frmconfighelper:
oracle@server> cd $ORACLE_HOME/forms/provision
oracle@server> ./frmconfighelper.sh deploy_app hrapp hrappservlet MS_HR_APP

running frmconfighelper.sh deploy_app
using log file /home/oracle/frmconfighelper/logs/frmconfighelper_2017_05_15_21_39_59.log ..........

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

frmconfighelper.py output
-------------------------------b-e-g-i-n--------------------------------------------
Please enter your username :weblogic
Please enter your password :
Please enter your server URL [t3://localhost:7001] :
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server "AS_FRDEVEL" that belongs to domain "FRDEVEL".

Warning: An insecure protocol was used to connect to the server. 
To ensure on-the-wire security, the SSL port or Admin port should be used instead.

processDeployApp
deploying the formsapp.dependencies library to target MS_HR_APP
<May 15, 2017 9:40:19 PM CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, oracle.formsapp.dependencieslib#12.2.1@12.2.1 [archive: /u00/app/oracle/product/fmw-fr-12.2.1.2.0/forms/j2ee/formsapp_deps.jar], to MS_HR_APP .> 
deploying custom Forms JavaEE application hrappapp
<May 15, 2017 9:40:20 PM CEST> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, hrappapp [archive: /u00/app/oracle/product/fmw-fr-12.2.1.2.0/forms/j2ee/hrapp.ear], to MS_HR_APP .> 
frmconfighelper.py script returning ...
------------------------------------------------------------------------------------
command :deployApp succeeded... 

-------------------------------e-n-d------------------------------------------------
<May 15, 2017 9:40:23 PM CEST> <Warning> <JNDI> <BEA-050001> <WLContext.close() was called in a different thread than the one in which it was created.> 

When you login to your WebLogic Server Console, you will find under Domain Structure / Environment / Servers your newly created Managed Server MS_HR_APP, assigned to the Machine AdminServerMachine.



Under Domain Structure / Deployments you will find the newly deploy formsapp called hrappapp, which is targeted to the above created Managed Server MS_HR_APP:


Just start the above create Managed Server MS_HR_APP, the deployment will become active and you can open a browser and point to: http://servername:9010/hrapp/hrappservlet


Under the $DOMAIN_HOME/config/fmwconfig/servers/MS_HR_APP/applications/hrappapp_12.2.1/config directory you will find the standard configuration files for your Forms Applications, e.g. formsweb.cfg, default.env

Also you can configure your new formsapp via the Enterprise Manager Fusion Middleware Control http://servername:7001/em

Navigate via the Target Navigation to the Forms Tree and click on forms


And you will find the new formsapp called hrappapp:


The function create_managed_server in combination with deploy_app enables you to created quickly and stable and bullet-proofed multiple Oracle Forms Managed Servers including the required formsapp deployment including context root naming and alias servlet naming.



Tuesday, May 9, 2017

Fully unintended CPU Patch Download for Oracle WebLogic Server

In case you are owning different versions of Oracle WebLogic Server, e.g. 10.3.6, 12.1.3, 12.2.1.2 and so on and you are regularly applying the Oracle Critical Patch Updates, you will have to download various different Patches.

Mainly you will have to click through different Websites and My Oracle Support Notes until you can download the required patches.

For this purpose I have developed a handy script, with which you can perform a fully unintended download of the latest Oracle WebLogic Server CPU Patches.

All what you need is:

Instructions

At first generate the required folder structure on your Linux Server:

root@server> cd /
root@server> mkdir -p CPU_TOOL/em_catalog
root@server> mkdir -p CPU_TOOL/archive
root@server> mkdir CPU_PATCHES

Create in the directory CPU_TOOL the following 2 files:
patch_download.ksh (afterwards make it executable chmod +x patch_download.ksh

#!/bin/ksh
# Author: Dirk Nachbar, http://dirknachbar.blogspot.com
#
# Purpose:    Wrapper Script for automated Critical Patch Update
#             download from My Oracle Suppurt (MOS)
#             
# Requirements: getMOSPatch, Author: Maris Elsins
#               Source: https://github.com/MarisElsins/getMOSPatch
#
#
# Parameters: -i <PropertiesFile> 
#       e.g.: -i mos.properties
#
#
# Exit Codes:
#             - 1 = Exit Code of Usage Function
#             - 2 = Missing Property or Value in configfile
#
#---------------------------------------------------------------------


#---------------------------------------------------------------------
# CONSTANTS
#---------------------------------------------------------------------

MyName="$(basename $0)"
StartDate="$(date '+%Y-%m-%d_%H:%M:%S')"
LogDir=/work/logs
WorkDir=`pwd`

#---------------------------------------------------------------------
Usage()
#
# PURPOSE: Displays the Usage of the script
#---------------------------------------------------------------------
{
cat << EOF
Usage: patch_download.ksh -i <ConfigFile>
       Wrapper Script for automated Critical Patch Update
       download from My Oracle Support (MOS)
       for Oracle WebLogic Server Release 10.3.6, 12.1.x, 12.2.x

Parameters:
   -i: config file with required parameters

EOF
exit 1
}

#---------------------------------------------------------------------
DoMsg()
#
# PURPOSE: Displays the TimeStamp in front of each status line
#---------------------------------------------------------------------
{
    if [ "${DoAppend}" = "TRUE" ]; then
        echo "`date +%Y-%m-%d_%H:%M:%S` `printf "%05d" $$` ${1}" | tee -a ${LogFile}
    else
        echo "`date +%Y-%m-%d_%H:%M:%S` `printf "%05d" $$` ${1}"
    fi

    shift

    while [ "${1}" != "" ]; do

        if [ "${DoAppend}" = "TRUE" ]; then
            echo "                     ${1}" | tee -a ${LogFile}
        else
            echo "                     ${1}"
        fi

        shift
    done
}


#---------------------------------------------------------------------
CheckParams()
#
# PURPOSE: Checks the input Parmeter -i
#---------------------------------------------------------------------
{
    if [ "${ConfigFile}" = "" ] ; then
        DoMsg "  ERR: Missing parameter(s), the flags -i must be used."
        Usage
    fi
}


#---------------------------------------------------------------------
ReadParams()
#
# PURPOSE: Reads the Parmeters of the Configfile and validate them
#---------------------------------------------------------------------
{
DoMsg "Reading provided Configuration File"
DoMsg "..."

TheMOSUser="$(cat ${ConfigFile} | grep -i "^MOSUser=" | head -n 1 | cut -d= -f2-)"
TheMOSPassword="$(cat ${ConfigFile} | grep -i "^MOSPassword=" | head -n 1 | cut -d= -f2-)"
TheUploadDir="$(cat ${ConfigFile} | grep -i "^UploadDir=" | head -n 1 | cut -d= -f2-)"

    if [ "${TheMOSUser}" = "" ] ; then
        echo "  ERR: Missing value MOSUser in the provided Config File."
        exit 2
    fi

    if [ "${TheMOSPassword}" = "" ] ; then
        echo "  ERR: Missing value MOSPassword in the provided Config File."
        exit 2
    fi

    if [ "${TheUploadDir}" = "" ] ; then
        echo "  ERR: Missing value UploadDir in the provided Config File."
        exit 2
    fi
}


#---------------------------------------------------------------------
DownloadEMCatalog()
#
# PURPOSE: Download of actual Patch List from MOS
#---------------------------------------------------------------------
{

DoMsg "Starting to download latest Version of em_catalog.zip from My Oracle Support"

# Cleanup the em_catalog directory from previous executions
rm -f ${WorkDir}/em_catalog/*.*

TheCookieFile=/tmp/$$.cookies
TheEM_CatalogLogFile=${LogDir}/wget_em_catalog_download_${StartDate}.log

# Contact updates site so that we can get SSO Params for logging in
SSO_Response=`wget https://updates.oracle.com/Orion/Services/download 2>&1|grep Location`

# Extract request parameters for SSO
SSO_Token=`echo $SSO_Response| cut -d '=' -f 2|cut -d ' ' -f 1`
SSO_Server=`echo $SSO_Response| cut -d ' ' -f 2|cut -d 'p' -f 1,2`
SSO_Auth_URL=sso/auth
Auth_Data="ssousername=${TheMOSUser}&password=${TheMOSPassword}&site2pstoretoken=$SSO_Token"

wget --post-data $Auth_Data --save-cookies=${TheCookieFile} --keep-session-cookies $SSO_Server$SSO_Auth_URL >> ${TheEM_CatalogLogFile} 2>&1
wget  --load-cookies=${TheCookieFile} --save-cookies=${TheCookieFile} --keep-session-cookies "https://updates.oracle.com/download/em_catalog.zip" -O em_catalog.zip >> ${TheEM_CatalogLogFile} 2>&1

# Cleanup the Cookie File
rm -f ${TheCookieFile}
rm -f auth

# Extract the em_catalog.zip
unzip ${WorkDir}/em_catalog.zip -d ${WorkDir}/em_catalog/

mv ${WorkDir}/em_catalog.zip ${WorkDir}/archive/em_catalog_${StartDate}.zip

DoMsg "Done to download latest Version of em_catalog.zip from My Oracle Support"

}

#---------------------------------------------------------------------
#
DownloadPatches()
# PURPOSE: Download the actual Patches for Oracle WLS
#---------------------------------------------------------------------
{

# Calculate actual Quarter Year
TheQYear=`echo $(date +%Y)_Q$(( ($(date +%-m)-1)/3+1 ))`
TheDownloadLogFile=${LogDir}/download_patches_${StartDate}.log
DoMsg "Starting to download Oracle WLS CPU's" | tee -a ${TheDownloadLogFile}


# Patch Download for WLS 10.3.6
PatchNumber=`grep -B 2 "<psu_bundle>WLS 10.3" em_catalog/patch_recommendations.xml | grep "<name>" | sed -e 's,.*<name>\([^<]*\)</name>.*,\1,g'`

ThePatchDir=${TheUploadDir}/WLS10.3.6.0/${TheQYear}/${PatchNumber}
mkdir -p ${ThePatchDir}
cd ${ThePatchDir}

DoMsg "Downloading CPU Patch ${PatchNumber} for WLS 10.3.6" | tee ${TheDownloadLogFile}

java -jar ${WorkDir}/getMOSPatch/getMOSPatch.jar MOSUser=${TheMOSUser} MOSPass=${TheMOSPassword} patch=${PatchNumber} regexp=.*Generic.* download=all platform=1234P >> ${TheDownloadLogFile}

cd ${TheUploadDir}/WLS10.3.6.0
rm -f actual
ln -s ${ThePatchDir} actual
cd ${WorkDir}

# Patch Download for WLS 12.1.2
PatchNumber=`grep -B 2 "<psu_bundle>WLS 12.1.2" em_catalog/patch_recommendations.xml | grep "<name>" | sed -e 's,.*<name>\([^<]*\)</name>.*,\1,g'`

ThePatchDir=${TheUploadDir}/WLS12.1.2.0.0/${TheQYear}/${PatchNumber}
mkdir -p ${ThePatchDir}
cd ${ThePatchDir}

DoMsg "Downloading CPU Patch ${PatchNumber} for WLS 12.1.2" | tee -a ${TheDownloadLogFile}

java -jar ${WorkDir}/getMOSPatch/getMOSPatch.jar MOSUser=${TheMOSUser} MOSPass=${TheMOSPassword} patch=${PatchNumber} regexp=.*Generic.* download=all platform=1234P >> ${TheDownloadLogFile}

cd ${TheUploadDir}/WLS12.1.2.0.0
rm -f actual
ln -s ${ThePatchDir} actual
cd ${WorkDir}

# Patch Download for WLS 12.1.3
PatchNumber=`grep -B 2 "<psu_bundle>Oracle WebLogic Server 12.1.3" em_catalog/patch_recommendations.xml | grep "<name>" | sed -e 's,.*<name>\([^<]*\)</name>.*,\1,g'`

ThePatchDir=${TheUploadDir}/WLS12.1.3.0.0/${TheQYear}/${PatchNumber}
mkdir -p ${ThePatchDir}
cd ${ThePatchDir}

DoMsg "Downloading CPU Patch ${PatchNumber} for WLS 12.1.3" | tee -a ${TheDownloadLogFile}

java -jar ${WorkDir}/getMOSPatch/getMOSPatch.jar MOSUser=${TheMOSUser} MOSPass=${TheMOSPassword} patch=${PatchNumber} regexp=.*Generic.* download=all platform=1234P >> ${TheDownloadLogFile}

cd ${TheUploadDir}/WLS12.1.3.0.0
rm -f actual
ln -s ${ThePatchDir} actual
cd ${WorkDir}

# Patch Download for WLS 12.2.1.0
PatchNumber=`grep -B 2 "<psu_bundle>Oracle WebLogic Server 12.2.1.0" em_catalog/patch_recommendations.xml | grep "<name>" | sed -e 's,.*<name>\([^<]*\)</name>.*,\1,g'`

ThePatchDir=${TheUploadDir}/WLS12.2.1.0.0/${TheQYear}/${PatchNumber}
mkdir -p ${ThePatchDir}
cd ${ThePatchDir}

DoMsg "Downloading CPU Patch ${PatchNumber} for WLS 12.2.1.0" | tee -a ${TheDownloadLogFile}

java -jar ${WorkDir}/getMOSPatch/getMOSPatch.jar MOSUser=${TheMOSUser} MOSPass=${TheMOSPassword} patch=${PatchNumber} regexp=.*Generic.* download=all platform=1234P >> ${TheDownloadLogFile}

cd ${TheUploadDir}/WLS12.2.1.0.0
rm -f actual
ln -s ${ThePatchDir} actual
cd ${WorkDir}

# Patch Download for WLS 12.2.1.1
PatchNumber=`grep -B 2 "<psu_bundle>Oracle WebLogic Server 12.2.1.1" em_catalog/patch_recommendations.xml | grep "<name>" | sed -e 's,.*<name>\([^<]*\)</name>.*,\1,g'`

ThePatchDir=${TheUploadDir}/WLS12.2.1.1.0/${TheQYear}/${PatchNumber}
mkdir -p ${ThePatchDir}
cd ${ThePatchDir}

DoMsg "Downloading CPU Patch ${PatchNumber} for WLS 12.2.1.1" | tee -a ${TheDownloadLogFile}

java -jar ${WorkDir}/getMOSPatch/getMOSPatch.jar MOSUser=${TheMOSUser} MOSPass=${TheMOSPassword} patch=${PatchNumber} regexp=.*Generic.* download=all platform=1234P >> ${TheDownloadLogFile}

cd ${TheUploadDir}/WLS12.2.1.1.0
rm -f actual
ln -s ${ThePatchDir} actual
cd ${WorkDir}

# Patch Download for WLS 12.2.1.2
PatchNumber=`grep -B 2 "<psu_bundle>Oracle WebLogic Server 12.2.1.2" em_catalog/patch_recommendations.xml | grep "<name>" | sed -e 's,.*<name>\([^<]*\)</name>.*,\1,g'`

ThePatchDir=${TheUploadDir}/WLS12.2.1.2.0/${TheQYear}/${PatchNumber}
mkdir -p ${ThePatchDir}
cd ${ThePatchDir}

DoMsg "Downloading CPU Patch ${PatchNumber} for WLS 12.2.1.2" | tee -a ${TheDownloadLogFile}

java -jar ${WorkDir}/getMOSPatch/getMOSPatch.jar MOSUser=${TheMOSUser} MOSPass=${TheMOSPassword} patch=${PatchNumber} regexp=.*Generic.* download=all platform=1234P >> ${TheDownloadLogFile}

cd ${TheUploadDir}/WLS12.2.1.2.0
rm -f actual
ln -s ${ThePatchDir} actual
cd ${WorkDir}

DoMsg "Done to download Oracle WLS CPU's" | tee -a ${TheDownloadLogFile}

}

#---------------------------------------------------------------------
# MAIN
#---------------------------------------------------------------------

ConfigFile=""

# All required ConfigParameters are initially set to empty
TheMOSUser=
TheMOSPassword=

while getopts i: CurOpt; do
    case ${CurOpt} in
        i) ConfigFile="${OPTARG}" ;;
        ?) Usage
           exit 1 ;;
    esac
done

shift $((${OPTIND}-1))

if [ $# -ne 0 ]; then
    Usage
fi

# Check Input Params
CheckParams

# Read the Params from the Config File
ReadParams
# Downloading EM Catalog zip file
DownloadEMCatalog
# Downloading the latest available Patches
DownloadPatches


mos.properties
# Configuration File for Automated Critical Patch Download
#
# Author: Dirk Nachbar, http://dirknachbar.blogspot.com
#

# My Oracle Support Credentials

MOSUser=<your_email>
MOSPassword=<your_mos_password>

# Upload Directory for CPU Patches

UploadDir=/CPU_PATCHES

Download the getMOSPatch.jar from https://github.com/MarisElsins/getMOSPatch and place it under /CPU_TOOL/getMOSPatch

root@server> mkdir -p /CPU_TOOL/getMOSPatch
root@server> cp /tmp/getMOSPatch.jar /CPU_TOOL/getMOSPatch

Make sure that you have a java 1.6 or higher in your PATH
root@server> which java
/bin/java
root@server> java -version
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

How does it work?

The trick behind the unintended CPU download is really simple, I am using the em_catalog.zip provided by My Oracle Support, which is used by Oracle Cloud Control for the so called Offline Patching (see MOS Note https://support.oracle.com/epmos/faces/DocContentDisplay?id=1931891.1)
In the patch_download.ksh script within the function DownloadEMCatalog() I am downloading the latest version of the em_catalog.zip, place it in the subdirectory /CPU_TOOL/em_catalog, unzip the file.
In the function DownloadPatches() I am using grep to identify the latest available CPU Patches for various WebLogic Server Releases within the file /CPU_TOOL/em_catalog/patch_recommendations.xml and through Maris Elsins' getMOSPatch I am downloading unintended the identified Patches, place them in the directory /CPU_PATCHES/WLS/<VersionNumber>/YYYY_Q[1|2|3|4] and creating a symlink on the latest CPU Patch to actual.

Get your Patches

To download the latest available patches, simply execute following commands:

root@server> cd /CPU_TOOL
root@server> ./patch_download.ksh -i mos.properties

2017-05-09_11:46:19 08102 Reading provided Configuration File
2017-05-09_11:46:19 08102 ...
2017-05-09_11:46:19 08102 Starting to download latest Version of em_catalog.zip from My Oracle Support
Archive:  /CPU_TOOL/em_catalog.zip
  inflating: /CPU_TOOL/em_catalog/aru_products.xml  
  inflating: /CPU_TOOL/em_catalog/aru_releases.xml  
  inflating: /CPU_TOOL/em_catalog/aru_platforms.xml  
  inflating: /CPU_TOOL/em_catalog/aru_languages.xml  
  inflating: /CPU_TOOL/em_catalog/aru_product_groups.xml  
  inflating: /CPU_TOOL/em_catalog/aru_product_releases.xml  
  inflating: /CPU_TOOL/em_catalog/aru_component_releases.xml  
  inflating: /CPU_TOOL/em_catalog/aru_targets.xml  
  inflating: /CPU_TOOL/em_catalog/components.xml  
  inflating: /CPU_TOOL/em_catalog/certifications.xml  
  inflating: /CPU_TOOL/em_catalog/patch_recommendations.xml  
 extracting: /CPU_TOOL/em_catalog/README.txt  
2017-05-09_11:46:56 08102 Done to download latest Version of em_catalog.zip from My Oracle Support
2017-05-09_11:46:56 08102 Starting to download Oracle WLS CPU's
2017-05-09_11:46:57 08102 Downloading CPU Patch 25388747 for WLS 10.3.6
2017-05-09_11:47:39 08102 Downloading CPU Patch 22505331 for WLS 12.1.2
2017-05-09_11:48:07 08102 Downloading CPU Patch 25388793 for WLS 12.1.3
2017-05-09_11:48:34 08102 Downloading CPU Patch 25388847 for WLS 12.2.1.0
2017-05-09_11:48:54 08102 Downloading CPU Patch 25388843 for WLS 12.2.1.1
2017-05-09_11:49:18 08102 Downloading CPU Patch 25388866 for WLS 12.2.1.2
2017-05-09_11:49:41 08102 Done to download Oracle WLS CPU's


Now you will find under the directory /CPU_PATCHES/WLS<VersionNumber>/YYYY_Q[1|2|3|4] the latest available CPU Patch for your Oracle WebLogic Server.
You can easily change in the mos.properties configuration file the target location for the CPU Patches to e.g. a mounted NAS drive, which you can attach to your WebLogic hosts, so that the patches are immediately available on your hosts for WebLogic Server.

Monday, April 10, 2017

Silent Installation and Configuration of Standalone Oracle HTTP Server

Currently I am working in a project for which will be needed the Oracle HTTP Server (OHS) in a Standalone Mode as a frontend Web Server for a Oracle SOA 12.2.1.2.0 environment.

As I am not really a fan of clicking through several installers and configuration wizards, I have created some scripts for a complete silent installation of the Standalone Oracle HTTP Server 12.2.1.2.0 and on top a silent configuration of the standalone Domain for the Oracle HTTP Server.

Silent Installation of the Oracle HTTP Server Software

For the following example, we will use following naming convention:
  • MW_HOME=/u00/app/oracle/product/fmw-webtier-12.2.1.2.0
  • JAVA_HOME=/u00/app/oracle/product/jdk1.8.0_121
  • DOMAIN_HOME=/u00/app/oracle/user_projects/domains/ohs_domain
Download at first the required installation software from Oracle Technology Network http://www.oracle.com/technetwork/middleware/webtier/downloads/index.html and transfer the installation software to your target server, e.g. /u00/app/oracle/tmp.


Make sure you that you have a JDK 1.8 on your server, I prefer to install the JDK under the Oracle user, e.g. /u00/app/oracle/product/jdk1.8.0_121

Connect to your server as oracle user and create following files under the directory /u00/app/oracle/tmp

webtier.rsp
[ENGINE]
Response File Version=1.0.0.0.0
[GENERIC]
ORACLE_HOME=/u00/app/oracle/product/fmw-webtier-12.2.1.2.0
INSTALL_TYPE=Standalone HTTP Server (Managed independently of WebLogic server)
DECLINE_SECURITY_UPDATES=true
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

oraInst.loc
inst_group=oinstall
inventory_loc=/u00/app/oracle/oraInventory

Now we can extract the installation software and install the Oracle HTTP Server in silent mode
oracle@server> cd /u00/app/oracle/tmp
oracle@server> unzip fmw_12.2.1.2.0_ohs_linux64_Disk1_1of1.zip
oracle@server> ./fmw_12.2.1.2.0_ohs_linux64.bin -jreLoc /u00/app/oracle/product/jdk1.8.0_121 -silent -responseFile /u00/app/oracle/tmp/webtier.rsp -invPtrLoc /u00/app/oracle/tmp/oraInst.loc

0%...................................................................................................100%
Launcher log file is /tmp/OraInstall2017-04-10_12-39-12PM/launcher2017-04-10_12-39-12PM.log.
Checking if CPU speed is above 300 MHz.   Actual 2194.918 MHz    Passed
Checking swap space: must be greater than 512 MB.   Actual 3071 MB    Passed
Checking if this platform requires a 64-bit JVM.   Actual 64    Passed (64-bit not required)
Checking temp space: must be greater than 300 MB.   Actual 8528 MB    Passed
. . .
. . .
Percent Complete : 90
Visit http://www.oracle.com/support/policies.html for Oracle Technical Support policies.
Percent Complete : 100

The installation of Oracle HTTP Server 12.2.1.2.0 completed successfully.
Logs successfully copied to /u00/app/oracle/oraInventory/logs.

Now we have installed the Oracle HTTP Server Software.

Silent Configuration of the Standalone Domain for the Oracle HTTP Server

The next step is to configure in a silent way the required Standalone Domain for our Oracle HTTP Server.

For this I have 3 scripts:

  • setLocalEnv.sh = contains all necessary Environment Variables for the creation of the Standalone Domain
  • cr_ohs_domain.sh = Wrapper Script to source the setLocalEnv.sh and execute the cr_ohs_domain.py
  • cr_ohs_domain.py = Python Script to create the Standalone Domain for the Oracle HTTP Server

setLocalEnv.sh
#
# Author: Dirk Nachbar
#
# http://dirknachbar.blogspot.com
#
# Environment Script for silent Standalone OHS Domain Creation
# 
#
export SCRIPT_HOME=$PWD
export MW_HOME=/u00/app/oracle/product/fmw-webtier-12.2.1.2.0
export WLST_HOME=$MW_HOME/oracle_common/common/bin
export JAVA_HOME=/u00/app/oracle/product/jdk1.8.0_121
export DOMAIN_NAME=ohs_domain
export DOMAIN_HOME=/u00/app/oracle/user_projects/domains/$DOMAIN_NAME
export NM_LISTENADDRESS=`hostname -f`
export NM_TYPE=SSL
export NM_PORT=5557
export NM_USERNAME=nodemanager
export NM_PASSWORD=welcome1
export NM_HOME=$DOMAIN_HOME/nodemanager
export OHSINSTANCENAME=ohs1
export OHSADMINPORT=9999
export OHSHTTPPORT=7777
export OHSHTTPSPORT=4443

The above Environment Variables are all self-explained, you may align them to your specific needs.
cr_ohs_domain.sh
#!/bin/sh
#
# Author: Dirk Nachbar
#
# http://dirknachbar.blogspot.com
#
# Shell Script Wrapper for Silent Standalone OHS Domain Creation
#

start_time=$(date +%s)

. $PWD/setLocalEnv.sh

echo "============================================="
echo " Program: cr_ohs_domain.sh              ....."
echo "============================================="

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

if ! test -d "${DOMAIN_HOME}"; then
   echo "============================================="
   echo " Domain will be installed               ....."
   echo "============================================="
   if [ -z "${MW_HOME}" -o -z "${JAVA_HOME}" -o -z "${DOMAIN_NAME}" -o -z "${DOMAIN_HOME}" -o -z "${NM_LISTENADDRESS}" -o -z "${NM_TYPE}" -o -z "${NM_PORT}" -o -z "${NM_USERNAME}" -o -z "${NM_PASSWORD}" -o -z "${NM_HOME}" -o -z "${OHSADMINPORT}" -o -z "${OHSHTTPPORT}" -o -z "${OHSHTTPSPORT}" ]; 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}/cr_ohs_domain.py

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

cr_ohs_domain.py
#!/usr/bin/python
#
# Author: Dirk Nachbar
#
# http://dirknachbar.blogspot.com
#

import os, sys

v_mwHome=os.environ['MW_HOME']
v_jdkHome=os.environ['JAVA_HOME']
v_domainHome=os.environ['DOMAIN_HOME']
v_domainName=os.environ['DOMAIN_NAME']
v_NMUsername=os.environ['NM_USERNAME']
v_NMPassword=os.environ['NM_PASSWORD']
v_NMHome=os.environ['NM_HOME']
v_NMHost=os.environ['NM_LISTENADDRESS']
v_NMPort=os.environ['NM_PORT']
v_NMType=os.environ['NM_TYPE']
v_OHSInstanceName=os.environ['OHSINSTANCENAME']
v_OHSAdminPort=os.environ['OHSADMINPORT']
v_OHSHTTPPort=os.environ['OHSHTTPPORT']
v_OHSHTTPSPort=os.environ['OHSHTTPSPORT']

readTemplate(v_mwHome +'/wlserver/common/templates/wls/base_standalone.jar')
addTemplate(v_mwHome +'/ohs/common/templates/wls/ohs_standalone_template.jar')

cd('/')
create(v_domainName, 'SecurityConfiguration') 
cd('SecurityConfiguration/' + v_domainName)
set('NodeManagerUsername',v_NMUsername)
set('NodeManagerPasswordEncrypted',v_NMPassword)
setOption('NodeManagerType', 'CustomLocationNodeManager');
setOption('NodeManagerHome', v_NMHome);
setOption('JavaHome', v_jdkHome )

cd('/Machines/localmachine/NodeManager/localmachine')
cmo.setListenAddress(v_NMHost);
cmo.setListenPort(int(v_NMPort));
cmo.setNMType(v_NMType);

delete(v_OHSInstanceName,'SystemComponent')
create (v_OHSInstanceName,'SystemComponent')
cd('/OHS/'+v_OHSInstanceName)
cmo.setAdminPort(v_OHSAdminPort)
cmo.setListenPort(v_OHSHTTPPort)
cmo.setSSLListenPort(v_OHSHTTPSPort)

writeDomain(v_domainHome) 

Now we can execute the cr_ohs_domain.sh which will create silently the Standalone Domain for our Oracle HTTP Server:

oracle@server> cd /u00/app/oracle/tmp
./cr_ohs_domain.sh

=============================================
 Program: cr_ohs_domain.sh              .....
=============================================
=============================================
 Domain will be installed               .....
=============================================

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Finished
Domain Build Time: 1  minutes.

And thats it, now you can start your Oracle HTTP Server Instance named ohs1

oracle@server> cd /u00/app/oracle/user_projects/domains/ohs_domain/bin
oracle@server> ./startNodeManager > /dev/null 2>&1 &
oracle@server> ./startComponent.sh ohs1 storeUserConfig



Friday, April 7, 2017

Switching MPM Type for Oracle HTTP Server 12c

The Oracle HTTP Server (OHS) comes by default with the MPM (Multi-Processing Modules) Type event for Linux systems, but sometimes you need to change the MPM Type for example to prefork.

The Oracle HTTP Server comes by default with 4 MPM Types:
  • Worker: This is the default for non-Linux UNIX Platforms, e.g. Solaris, AIX ...
  • Event: This is the default for Linux Platforms
  • Prefork: This Type implements a non-threaded, pre-forking server, that handles request as an Apache HTTPD Server 1.3
  • WinNT: This is the default for Windows Platforms
For more details about the MPM Types see http://docs.oracle.com/middleware/12212/webtier/administer-ohs/man_server.htm#zzaszzohszzmpm

In case you need to switch the MPM Type, you need at first to check if you have a standalone OHS or a OHS in a WebLogic Server Domain, as the way to switch the MPM Type is depending on these 2 options.

Switching MPM for a standalone OHS:

Simply connect to your server as oracle user and perform following steps:
cd $DOMAIN_HOME/config/fmwconfig/components/OHS/<OHS_Componentname>/

# Open the Config File ohs.plugins.nodemanager.properties
# and add following line at the end
# depending on your desired MPM Type
# mpm = prefork
# mpm = worker
# mpm = event
mpm = prefork

After that restart your OHS with:
cd $DOMAIN_HOME/bin
./stopComponent.sh <OHS_Componentname>
./startComponent.sh <OHS_Componentname> 

Switching MPM for OHS in a WebLogic Domain

Simply connect to your server as oracle user and perform following steps:
$ORACLE_HOME/oracle_common/common/bin/wlst.sh
connect('weblogic', '<AdminPassword>', '<servername>:<Port>')
editCustom()
cd('oracle.ohs')
cd('oracle.ohs:type=OHSInstance.NMProp,OHSInstance=<OHS_Componentname>,component=OHS')
startEdit()
# Set here your desired MPM Type
# possible values are:
# - prefork
# - event
# - worker
# - winnt (only for Windows)
set('Mpm','prefork') 
save()
activate()

After that restart your OHS with:
cd $DOMAIN_HOME/bin
./stopComponent.sh <OHS_Componentname>
./startComponent.sh <OHS_Componentname> 


Wednesday, March 22, 2017

Consume WebLogic Server RESTFul Management Services with ELK

In several of my projects for Oracle WebLogic Server and Oracle Fusion Middleware Environments a main topic is the monitoring.
Oracle provides with the Oracle Enterprise Manager Cloud Control are really powerful solution to monitor Oracle WebLogic Server and Oracle Fusion Middleware Environments, but the disadvantage is the huge license cost for the necessary Management Packs for Oracle WebLogic / Fusion Middleware. Moreover in many small to midrange sized environments the Oracle Enterprise Manager Cloud Control can be an overkill and due to the license costs for the Management Packs a no-go.

There are several solutions on the market, some commercial and some open source, for Oracle WebLogic Server Monitoring.

I will show you a short test case, how to consume Oracle WebLogic Server RESTFul Management Services with the so called ELK Stack (Elasticsearch / Logstash / Kibana). How to setup the ELK stack, just check Google or the documentation on elastic.co https://www.elastic.co/guide/en/elastic-stack/current/index.html

My environment is as follows:

  • Ubuntu 16.04 server named "monitoring" which is hosting my ELK Stack
  • Oracle Enterprise Linux named "wls12212" which is hosting my Oracle WebLogic Server with a Domain called demo_domain
    • AdminServer running on Port 7001
On the ELK server monitoring add a Logstash configuration file wls-rest.conf under /etc/logstash/conf.d
For this I will use the Input Plugin http_poller (see https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http_poller.html)

input {
  http_poller {
    urls => {
      test1 => {
        method => get
        # define the RESTFul Management Service URL
        url => "http://wls12212:7001/management/wls/latest/servers"
        headers => {
          Accept => "application/json"
        }
        # Define the Basic Authentication against the WebLogic Server
        auth => {
          user => "weblogic"
          password => "welcome01"
        }
      }
    }
    request_timeout => 30
    # poll every 60 seconds the metrics
    interval => 60
    # Set the Codec to json
    codec => "json"
    metadata_target => "http_poller_metadata"
  }
}

output {
  # Output to elasticsearch
  elasticsearch { hosts => ["localhost:9200"] }
  # Output to stdout
  stdout { codec => rubydebug }
}


Now we can start our logstash process on the ELK server monitoring

/opt/logstash/bin/logstash -f /etc/logstash/conf.d/wls-rest.conf
Settings: Default pipeline workers: 1
Pipeline main started
{
                   "items" => [
        [0] {
                   "heapFreeCurrent" => 188998424,
                   "heapSizeCurrent" => 374341632,
                "usedPhysicalMemory" => 3520323584,
                  "jvmProcessorLoad" => 0,
                            "health" => {
                "state" => "ok"
            },
            "activeHttpSessionCount" => 0,
                 "activeThreadCount" => 11,
                              "name" => "DemoAdminServer",
                             "state" => "running"
        },
        [1] {
                   "heapFreeCurrent" => 275771456,
                   "heapSizeCurrent" => 401080320,
                "usedPhysicalMemory" => 3520323584,
                  "jvmProcessorLoad" => 0,
                            "health" => {
                "state" => "ok"
            },
            "activeHttpSessionCount" => 0,
                 "activeThreadCount" => 8,
                              "name" => "DemoMS1",
                             "state" => "running"
        },
. . .
. . .


Now we can check in Kibana the Indices under Settings:



and define our Visualization under Visualize:




With this really simple configuration you can consume all available Metrics within the WebLogic RESTFul Management Services via ELK Stack just by defining the url in the http_poller configuration, visualise them, create dashboard and with the Output Plugins in Logstash (https://www.elastic.co/guide/en/logstash/current/output-plugins.html) you can even define notifications through Email, Nagios, Zabbix and so on ...