In this post, we will show how to create automation scripts in order to set-up middleware environments.

Preparation

As an example, we will use the Oracle Service Bus. In the example, we will use the following software

First, we have to decide how the directory structure will look, for example

/home/osb
	/jrockit-jdk1.6.0_37-R28.2.5-4.1.0 (created during the installation of JRockit)
	/oraInventory (created during the installation of Oracle Service Bus)
	/osb11.1.1.6
		/installation (directory which will contain all the software)
			/coherence_3.7 (created during the installation of WebLogic Server)
			/oracle_common (created during the installation of Oracle Service Bus)
			/oracle_service_bus (created during the installation of Oracle Service Bus)
			/wlserver_10.3 (created during the installation of WebLogic Server)
		/configuration
			/applications
				/osb_domain (created during the configuration of Oracle Service Bus)
			/domains
				/osb_domain (created during the configuration of Oracle Service Bus)
			/nodemanagers
				/osb_domain (created during the configuration of Oracle Service Bus)
		/scripts
			/configuration
			/installation
			/lifecycle (start and stop scripts)

Installation

To silent install JRockit, we need the following XML file

<domain-template-descriptor>
	<input-fields>
		<!-- Installation directory -->
		<data-value name="USER_INSTALL_DIR" value="/home/osb/jrockit-jdk1.6.0_37-R28.2.5-4.1.0"/>
		<!-- Optional installation of Demos and Samples -->
		<data-value name="INSTALL_DEMOS_AND_SAMPLES" value="false"/>
		<!-- Optional installation of Source Code -->
		<data-value name="INSTALL_SOURCE_CODE" value="false"/>
	</input-fields>
</domain-template-descriptor>

To silent install WebLogic, we need the following XML file

<bea-installer>
	<input-fields>
		<!-- BEAHOME: The full path for the middleware home directory. -->
		<data-value name="BEAHOME" value="/home/osb/osb11.1.1.6/installation"/>
		<!-- WLS_INSTALL_DIR: The full path for the directory where to install WebLogic Server. -->
		<data-value name="WLS_INSTALL_DIR" value="/home/osb/osb11.1.1.6/installation/wlserver_10.3"/>
		<!-- OCP_INSTALL_DIR: The full path for the directory where to install Coherence. -->
		<data-value name="OCP_INSTALL_DIR" value="/home/osb/osb11.1.1.6/installation/coherence_3.7"/>
		<!-- COMPONENT_PATHS: Specify the components and subcomponents to install. -->
		<data-value name="COMPONENT_PATHS" value="WebLogic Server/Core Application Server|WebLogic Server/Administration Console|WebLogic Server/Configuration Wizard and Upgrade Framework|WebLogic Server/Web 2.0 HTTP Pub-Sub Server|WebLogic Server/WebLogic JDBC Drivers|WebLogic Server/Third Party JDBC Drivers|WebLogic Server/WebLogic Server Clients|WebLogic Server/WebLogic Web Server Plugins|WebLogic Server/UDDI and Xquery Support|Oracle Coherence/Coherence Product Files"/>
		<!-- INSTALL_NODE_MANAGER_SERVICE: Install Node Manager as a Windows service. -->
		<data-value name="INSTALL_NODE_MANAGER_SERVICE" value="no"/>
		<!-- LOCAL_JVMS: Select JVMs which are already installed. -->
		<data-value name="LOCAL_JVMS" value="/home/osb/jrockit-jdk1.6.0_37-R28.2.5-4.1.0"/>
	</input-fields>
</bea-installer>

Note that the XML files, reflect our directory structure.

As we are testing this (installing and configuring the Oracle Service Bus) on Redhat-CentOS, we have to make sure that a right entry is added to the refhost.xml (located in the Disk1/stage/prereq/linux64 directory, which is created after the Oracle Service Bus software is unzipped), for example,

<OPERATING_SYSTEM>
	<VERSION VALUE="CentOS"/>
	<ARCHITECTURE VALUE="x86_64"/>
    <NAME VALUE="Linux"/>
	<VENDOR VALUE="redhat"/>
	<GLIBC ATLEAST="2.12-1.7.el6"></GLIBC>
	<PACKAGES>
		<PACKAGE NAME="binutils" VERSION="2.20.51.0.2-5.11.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="compat-libcap1" VERSION="1.10-1" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="compat-libstdc++-33" VERSION="3.2.3-69.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="compat-libstdc++-33" VERSION="3.2.3-69.el6"  ARCHITECTURE="i686" />
		<PACKAGE NAME="libgcc" VERSION="4.4.4-13.el6" ARCHITECTURE="i686" />
		<PACKAGE NAME="libgcc" VERSION="4.4.4-13.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="libstdc++" VERSION="4.4.4-13.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="libstdc++" VERSION="4.4.4-13.el6" ARCHITECTURE="i686"/>
		<PACKAGE NAME="libstdc++-devel" VERSION="4.4.4-13.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="sysstat" VERSION="9.0.4-11.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="gcc" VERSION="4.4.4-13.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="gcc-c++" VERSION="4.4.4-13.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="glibc" VERSION="2.12-1.7.el6" ARCHITECTURE="i686" />
		<PACKAGE NAME="glibc" VERSION="2.12-1.7.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="glibc-devel" VERSION="2.12-1.7.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="glibc-devel" VERSION="2.12-1.7.el6" />
		<PACKAGE NAME="libaio" VERSION="0.3.107-10.el6" ARCHITECTURE="x86_64" />
		<PACKAGE NAME="libaio-devel" VERSION="0.3.107-10.el6" ARCHITECTURE="x86_64" />
	</PACKAGES>
	<KERNEL>
		<PROPERTY NAME="VERSION" VALUE="2.6.32-279.19.1.el6"/>
		<PROPERTY NAME="hardnofiles" VALUE="4096"/>
		<PROPERTY NAME="softnofiles" VALUE="4096"/>
	</KERNEL>
</OPERATING_SYSTEM>

Note that this is based on the VENDOR VALUE="oracle" and VERSION VALUE="6" entry. When running on RedHat Enterprise Linux 6.3 an entry has to be added as well. The certification matrix states that RedHat Enterprise Linux 6.3 is supported, i.e., OSB 11.1.1.5+, x64 (only 64-bits), RedHatEL6(UL1+), JRockit Update 29 R28.2.0+. RedHat CentOS is not supported.

Make sure the packages mentioned above are installed on the system. By using yum, the packages can be installed, i.e., yum install ${NAME}-${VERSION}.${ARCHITECTURE}, for example, yum install compat-libstdc++-33-3.2.3-69.el6.i686.

To silent install the Oracle Service Bus, we first have to create a response file. To this end run the installer in graphical mode, i.e., execute ./runInstaller -jreLoc /home/osb/jrockit-jdk1.6.0_37-R28.2.5-4.1.0 in the Disk1 directory.

  • When this is the first time the installer is started, the specify inventory screen will pop-up. Enter an inventory directory and an operating system group name and click ok. Next execute ${INVENTORY_HOME}/createCentralInventory.sh as root and click ok in the pop-up.
  • The welcome screen is shown, click next.
  • Select skip software updates and click next.
  • Enter the following parameters:
    • Oracle Middleware Home: /home/osb/osb11.1.1.6/installation
    • Oracle Home Directory: oracle_service_bus
  • Click next.
  • Select custom in the installation type screen, and click next.
  • De-select, oracle service bus IDE and oracle service bus examples, and click next.
  • Prerequisite checks are run, click next when they finish successfully.
  • Enter the following parameters:
    • WebLogic Server Location: /home/osb/osb11.1.1.6/installation/wlserver_10.3
  • Click next.
  • Installation summary is shown, click save to save the response file.
  • Click install, click next when finished and click finish.

The resulting response file 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 specify a directory where latest updates are downloaded. This option would use the software updates from the specified directory
SPECIFY_DOWNLOAD_LOCATION=false

#
SKIP_SOFTWARE_UPDATES=true

#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
SOFTWARE_UPDATES_DOWNLOAD_LOCATION=

#Write the name of the Oracle Home directory. The Oracle Home directory name may only contain alphanumeric , hyphen (-) , dot (.) and underscore (_) characters, and it must begin with an alphanumeric character.
ORACLE_HOME=/home/osb/osb11.1.1.6/installation/oracle_service_bus

#Write the complete path to a valid Middleware Home.
MIDDLEWARE_HOME=/home/osb/osb11.1.1.6/installation

#Set this to true if typical installation must be done. If this is set to true then wariable "CUSTOM TYPE" must be set to false as the variables are mutually exclusive
TYPICAL TYPE=false

#Set this to true if custom installation must be done, all other required variables need to be provided. If this is set to true then variable "TYPICAL TYPE" must be set to false as the variables are mutually exclusive.
CUSTOM TYPE=true

#Set this to true if component Oracle Service Bus Examples must be installed. This input will be needed only in the case of custom installation
Oracle Service Bus Examples=false

#Set this to true if component Oracle Service Bus IDE must be installed. This input will be needed only in the case of custom installation
Oracle Service Bus IDE=false

#Give the complete path to a valid WebLogic Server Home for the corresponding Middleware Home entered.
WL_HOME=/home/osb/osb11.1.1.6/installation/wlserver_10.3

#Give the complete path to a valid OEPE Home for the corresponding Middleware Home entered. This input will be needed in both typical and custom installations. But in case of custom installation, Oracle Service Bus IDE must be set to true.
#OEPE_HOME=/tmp

[SYSTEM]

[APPLICATIONS]

[RELATIONSHIPS]

An example script that installs the necessary software, looks as follows

#!/bin/bash

SOFTWARE_DIRECTORY="/home/osb/temp"
export SOFTWARE_DIRECTORY

BASE_DIRECTORY="/home/osb"
export BASE_DIRECTORY

JAVA_HOME="${BASE_DIRECTORY}/jrockit-jdk1.6.0_37-R28.2.5-4.1.0"
export JAVA_HOME

MIDDLEWARE_HOME="${BASE_DIRECTORY}/osb11.1.1.6"
export MIDDLEWARE_HOME

create_repository() {
	${SOFTWARE_DIRECTORY}/rcuHome/bin/rcu -silent -createRepository -databaseType ORACLE -connectString 192.168.1.60:1521:orcl11 -dbUser sys -dbRole SYSDBA -schemaPrefix DEV -useSamePasswordForAllSchemaUsers true -component SOAINFRA -component MDS -component ORASDPM -f &lt; ${MIDDLEWARE_HOME}/scripts/installation/passwordfile.txt
}

drop_repository() {
	${SOFTWARE_DIRECTORY}/rcuHome/bin/rcu -silent -dropRepository -databaseType ORACLE -connectString 192.168.1.60:1521:orcl11 -dbUser sys -dbRole SYSDBA -schemaPrefix DEV -component SOAINFRA -component MDS -component ORASDPM -f &lt; ${MIDDLEWARE_HOME}/scripts/installation/passwordfile.txt
}

install_jrockit() {
	${SOFTWARE_DIRECTORY}/jrockit-jdk1.6.0_37-R28.2.5-4.1.0-linux-x64.bin -mode=silent -silent_xml=${MIDDLEWARE_HOME}/scripts/installation/silent-jrockit.xml
}

install_weblogic() {
	${JAVA_HOME}/bin/java -Xms512m -Xmx512m -jar ${SOFTWARE_DIRECTORY}/wls1036_generic.jar -mode=silent -silent_xml=${MIDDLEWARE_HOME}/scripts/installation/silent-weblogic.xml
}

install_service_bus() {
	${SOFTWARE_DIRECTORY}/Disk1/runInstaller -silent -responsefile ${MIDDLEWARE_HOME}/scripts/installation/silent-service-bus.txt -jreLoc ${JAVA_HOME}
}
# create_repository

# drop_repository

install_jrockit

install_weblogic

install_service_bus

When the script is run the following output is observed

[osb@middleware-magic installation]$ ./install-software.sh
Extracting 0%....................................................................................................100%
Extracting 0%....................................................................................................100%
Jan 21, 2013 11:02:41 AM java.util.prefs.FileSystemPreferences$2 run
INFO: Created user preferences directory.
Starting Oracle Universal Installer...

Checking if CPU speed is above 300 MHz.    Actual 2195 MHz    Passed
Checking Temp space: must be greater than 150 MB.   Actual 5155 MB    Passed
Checking swap space: must be greater than 512 MB.   Actual 3023 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2013-01-21_11-03-34AM. Please wait ...[osb@middleware-magic installation]$ Log: /home/osb/oraInventory/logs/install2013-01-21_11-03-34AM.log
Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
Reading response file..
Expected result: One of oracle-6,oracle-5.6,enterprise-5.4,enterprise-4,enterprise-5,redhat-CentOS,redhat-5.4,redhat-4,redhat-5,SuSE-10,SuSE-11
Actual Result: redhat-CentOS
Check complete. The overall result of this check is: Passed
CertifiedVersions Check: Success.
Checking for binutils-2.20.51.0.2-5.11.el6-x86_64; found binutils-2.20.51.0.2-5.34.el6-x86_64.	Passed
Checking for compat-libcap1-1.10-1-x86_64; found compat-libcap1-1.10-1-x86_64.	Passed
Checking for compat-libstdc++-33-3.2.3-69.el6-x86_64; found compat-libstdc++-33-3.2.3-69.el6-x86_64.	Passed
Checking for compat-libstdc++-33-3.2.3-69.el6-i686; found compat-libstdc++-33-3.2.3-69.el6-i686.	Passed
Checking for libgcc-4.4.4-13.el6-i686; found libgcc-4.4.6-4.el6-i686.	Passed
Checking for libgcc-4.4.4-13.el6-x86_64; found libgcc-4.4.6-4.el6-x86_64.	Passed
Checking for libstdc++-4.4.4-13.el6-x86_64; found libstdc++-4.4.6-4.el6-x86_64.	Passed
Checking for libstdc++-4.4.4-13.el6-i686; found libstdc++-4.4.6-4.el6-i686.	Passed
Checking for libstdc++-devel-4.4.4-13.el6-x86_64; found libstdc++-devel-4.4.6-4.el6-x86_64.	Passed
Checking for sysstat-9.0.4-11.el6-x86_64; found sysstat-9.0.4-20.el6-x86_64.	Passed
Checking for gcc-4.4.4-13.el6-x86_64; found gcc-4.4.6-4.el6-x86_64.	Passed
Checking for gcc-c++-4.4.4-13.el6-x86_64; found gcc-c++-4.4.6-4.el6-x86_64.	Passed
Checking for glibc-2.12-1.7.el6-i686; found glibc-2.12-1.80.el6_3.6-i686.	Passed
Checking for glibc-2.12-1.7.el6-x86_64; found glibc-2.12-1.80.el6_3.6-x86_64.	Passed
Checking for glibc-devel-2.12-1.7.el6-x86_64; found glibc-devel-2.12-1.80.el6_3.6-x86_64.	Passed
Checking for glibc-devel-2.12-1.7.el6; found glibc-devel-2.12-1.80.el6_3.6-x86_64.	Passed
Checking for libaio-0.3.107-10.el6-x86_64; found libaio-0.3.107-10.el6-x86_64.	Passed
Checking for libaio-devel-0.3.107-10.el6-x86_64; found libaio-devel-0.3.107-10.el6-x86_64.	Passed
Check complete. The overall result of this check is: Passed
Packages Check: Success.
Checking for VERSION=2.6.32-279.19.1.el6; found VERSION=2.6.32-279.19.1.el6.x86_64.	Passed
Checking for hardnofiles=4096; found hardnofiles=4096.	Passed
Checking for softnofiles=4096; found softnofiles=4096.	Passed
Check complete. The overall result of this check is: Passed
Kernel Check: Success.
Expected result: ATLEAST=2.12-1.7.el6
Actual Result: 2.12-1.80.el6_3.6
Check complete. The overall result of this check is: Passed
GLIBC Check: Success.
Expected result: 1024MB
Actual Result: 3832MB
Check complete. The overall result of this check is: Passed
TotalMemory Check: Success.
Verifying data......
Copying Files...
-----------20%----------40%----------60%----------80%--------100%

The installation of Oracle AS Common Toplevel Component, Oracle Service Bus completed successfully.

We could refine the functions in the script, such that the software is copied, unzipped (when necessary), and deleted, for example,

unzip -q ${SOFTWARE_LOCATION}/ofm_osb_generic_11.1.1.6.0_disk1_1of1.zip -d ${SOFTWARE_DIRECTORY}/OSB
cp ${SOFTWARE_LOCATION}/refhost.xml ${SOFTWARE_DIRECTORY}/OSB/Disk1/stage/prereq/linux64
${SOFTWARE_DIRECTORY}/OSB/Disk1/runInstaller -silent -responsefile ${MIDDLEWARE_HOME}/scripts/installation/silent-service-bus.txt -jreLoc ${JAVA_HOME}
rm -Rf ${SOFTWARE_DIRECTORY}/OSB

Configuration

To configure a domain, we can use the following WLST script

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

def createFile(directory_name, file_name, content):
	dedirectory = java.io.File(directory_name);
	defile = java.io.File(directory_name + '/' + file_name);

	writer = None;
	try:
		dedirectory.mkdirs();
		defile.createNewFile();
		writer = java.io.FileWriter(defile);
		writer.write(content);
	finally:
		try:
			print 'WRITING FILE ' + file_name;
			if writer != None:
				writer.flush();
				writer.close();
		except java.io.IOException, e:
			e.printStackTrace();

print 'CREATE DOMAIN';
readTemplate(weblogic_template);
setOption('DomainName', domain_name);
setOption('OverwriteDomain', 'true');
setOption('JavaHome', jvm_directory);
setOption('ServerStartMode', 'prod');
cd('/Security/base_domain/User/weblogic');
cmo.setName(admin_username);
cmo.setUserPassword(admin_password);
cd('/');

print "SAVE DOMAIN";
writeDomain(domain_home);
closeTemplate();

print 'READ DOMAIN';
readDomain(domain_home);

print 'ADD TEMPLATES';
addTemplate(service_bus_template);
# The next two templates are already selected by adding the service bus template
#addTemplate(webservice_template);
#addTemplate(jrf_template);
addTemplate(service_bus_owsm_template);
# The next template is already selected by adding the service bus owsm template
#addTemplate(owsm_policy_manager_template);
addTemplate(jrf_upgrade_template);
addTemplate(em_template);
setOption('AppDir', domain_application_home);

print 'CREATE MACHINE';
machine = create('osb_machine1','UnixMachine');
machine.setPostBindUIDEnabled(true);
machine.setPostBindUID('osb');
machine.setPostBindGIDEnabled(true);
machine.setPostBindGID('weblogic');
cd('/Machine/osb_machine1');
nodemanager = create('osb_machine1','NodeManager');
nodemanager.setListenAddress('middleware-magic.com');
nodemanager.setNMType('ssl');
cd('/');

print 'CREATE CLUSTER';
cluster = create('osb_cluster','Cluster');
cluster.setClusterMessagingMode('unicast');

print 'ADJUST MANAGED SERVER SETTINGS';
listen_port = 9001;
servers = cmo.getServers();
for server in servers:
	if server.getName() != 'AdminServer':
		server.setListenAddress('middleware-magic.com');
		server.setListenPort(listen_port);
		server.setMachine(machine);
		cd('Servers/' + server.getName());
		serverstart = create(server.getName(),'ServerStart');
		serverstart.setJavaHome(jvm_directory);
		serverstart.setJavaVendor('Oracle');
		serverstart.setArguments('-jrockit -Xms1024m -Xmx1024m -Xgc:throughput -XX:+UseCallProfiling -XX:+UseLargePagesForHeap');
		cd('/');
		listen_port = listen_port + 1;

print 'ADJUST DATA SOURCE SETTINGS';
jdbcsystemresources = cmo.getJDBCSystemResources();
for jdbcsystemresource in jdbcsystemresources:
	cd ('/JDBCSystemResource/' + jdbcsystemresource.getName() + '/JdbcResource/' + jdbcsystemresource.getName() + '/JDBCConnectionPoolParams/NO_NAME_0');
	cmo.setTestTableName('SQL SELECT 1 FROM DUAL');
	cmo.setConnectionCreationRetryFrequencySeconds(100);
	cd ('/JDBCSystemResource/' + jdbcsystemresource.getName() + '/JdbcResource/' + jdbcsystemresource.getName() + '/JDBCDataSourceParams/NO_NAME_0');
	cmo.setGlobalTransactionsProtocol('EmulateTwoPhaseCommit');
	cd ('/JDBCSystemResource/' + jdbcsystemresource.getName() + '/JdbcResource/' + jdbcsystemresource.getName() + '/JDBCDriverParams/NO_NAME_0');
	cmo.setUrl('jdbc:oracle:thin:@192.168.1.60:1521:orcl11');
	cmo.setDriverName('oracle.jdbc.OracleDriver');
	cmo.setPasswordEncrypted('magic11g');
	cd('/');

print 'ASSIGN SERVERS TO CLUSTER';
servers = cmo.getServers();
for server in servers:
	if server.getName() != 'AdminServer':
		assign('Server', server.getName(), 'Cluster', 'osb_cluster');

print 'ADJUST JMS DEPLOYMENT TO USE UNIFORM DISTRIBUTED QUEUES';
jmssystemresources = cmo.getJMSSystemResources();
for jmssystemresource in jmssystemresources:
	cd('/JMSSystemResource/' + jmssystemresource.getName());
	subdeployments = ls('SubDeployment', returnMap = 'true');
	for subdeployment in subdeployments:
		cd('SubDeployment/' + subdeployment);
		if 'jmsserver' in cmo.getName().lower():
			subdeploymentname = cmo.getName();
		cd('../..');
	cd('/JMSSystemResource/' + jmssystemresource.getName() + '/JmsResource/NO_NAME_0');
	distributedqueues = ls('DistributedQueue', returnMap = 'true');
	for distributedqueue in distributedqueues:
		cd('DistributedQueue/' + distributedqueue);
		name = cmo.getName();
		jndiname = cmo.getJNDIName();
		cd('../..');
		delete(name, 'DistributedQueue');
		uniformdistributedqueue = create(name, 'UniformDistributedQueue');
		uniformdistributedqueue.setJNDIName(jndiname);
		uniformdistributedqueue.setSubDeploymentName(subdeploymentname);

print "SET NODE MANAGER CREDENTIALS";
cd("/SecurityConfiguration/" + domain_name);
cmo.setNodeManagerUsername(node_manager_username);
cmo.setNodeManagerPasswordEncrypted(node_manager_password);
print "DISABLE HOSTNAME VERIFICATION";
cd('/Server/AdminServer');
create('AdminServer','SSL');
cd('SSL/AdminServer');
cmo.setHostnameVerificationIgnored(true);
cmo.setHostnameVerifier(None);
cmo.setTwoWaySSLEnabled(false);
cmo.setClientCertificateEnforced(false);

print 'SAVE CHANGES';
updateDomain();
closeDomain();

print 'CREATE FILES';
directory_name = domain_home + '/servers/AdminServer/security';
file_name = 'boot.properties';
content = 'username=' + admin_username + '\npassword=' + admin_password;
createFile(directory_name, file_name, content);

#directory_name = node_manager_home;
#file_name = 'nodemanager.domains';
#content=domain_name + '=' + domain_home;
#createFile(directory_name, file_name, content);

directory_name = node_manager_home;
file_name = 'nodemanager.properties';
content='DomainsFile=' + node_manager_home + '/nodemanager.domains\nLogLimit=0\nPropertiesVersion=10.3\nDomainsDirRemoteSharingEnabled=false\njavaHome=' + jvm_directory + '\nAuthenticationEnabled=true\nNodeManagerHome=' + node_manager_home + '\nJavaHome=' + jvm_directory + '/jre\nLogLevel=INFO\nDomainsFileEnabled=true\nStartScriptName=startWebLogic.sh \nListenAddress=\nNativeVersionEnabled=true\nListenPort=5556\nLogToStderr=true\nSecureListener=true\nLogCount=1\nDomainRegistrationEnabled=false\nStopScriptEnabled=false\nQuitEnabled=false\nLogAppend=true\nStateCheckInterval=500\nCrashRecoveryEnabled=false\nStartScriptEnabled=true\nLogFile=' + node_manager_home + '/nodemanager.log\nLogFormatter=weblogic.nodemanager.server.LogFormatter\nListenBacklog=50';
createFile(directory_name, file_name, content);

which can be run by using

#!/bin/sh

SCRIPT=$(readlink -f $0)
SCRIPT_PATH=$(dirname $SCRIPT)

. ${SCRIPT_PATH}/SetEnvironmentVariables.sh

${MIDDLEWARE_HOME}/common/bin/wlst.sh -loadProperties ${SCRIPT_PATH}/environment.properties ${SCRIPT_PATH}/create_environment.py

where ${MIDDLEWARE_HOME} points to the oracle_service_bus directory. The environment.properties file has the following contents

domain_name=osb_domain
domain_home=/home/osb/osb11.1.1.6/configuration/domains/osb_domain
domain_application_home=/home/osb/osb11.1.1.6/configuration/applications/osb_domain
weblogic_template=/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/templates/domains/wls.jar
service_bus_template=/home/osb/osb11.1.1.6/installation/oracle_service_bus/common/templates/applications/wlsb.jar
webservice_template=/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/templates/applications/wls_webservice.jar
jrf_template=/home/osb/osb11.1.1.6/installation/oracle_common/common/templates/applications/jrf_template_11.1.1.jar
service_bus_owsm_template=/home/osb/osb11.1.1.6/installation/oracle_service_bus/common/templates/applications/wlsb_owsm.jar
owsm_policy_manager_template=/home/osb/osb11.1.1.6/installation/oracle_common/common/templates/applications/oracle.wsmpm_template_11.1.1.jar
jrf_upgrade_template=/home/osb/osb11.1.1.6/installation/oracle_common/common/templates/applications/jrf_uprade_template_11.1.1.4.0.jar
em_template=/home/osb/osb11.1.1.6/installation/oracle_common/common/templates/applications/oracle.em_11_1_1_0_0_template.jar
jvm_directory=/home/osb/jrockit-jdk1.6.0_37-R28.2.5-4.1.0
node_manager_username=nodemanager
node_manager_password=magic11g
node_manager_home=/home/osb/osb11.1.1.6/configuration/nodemanagers/osb_domain
node_manager_listen_port=5556
admin_server_name=AdminServer
admin_username=weblogic
admin_password=magic11g
admin_server_listen_port=7001

When the configuration script is run the following output is observed

[osb@middleware-magic configuration]$ ./CreateEnvironmentService.sh 

CLASSPATH=/home/osb/osb11.1.1.6/installation/patch_wls1036/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/osb/osb11.1.1.6/installation/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/osb/jrockit-jdk1.6.0_37-R28.2.5-4.1.0/lib/tools.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/server/lib/weblogic_sp.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/server/lib/weblogic.jar:/home/osb/osb11.1.1.6/installation/modules/features/weblogic.server.modules_10.3.6.0.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/server/lib/webservices.jar:/home/osb/osb11.1.1.6/installation/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/home/osb/osb11.1.1.6/installation/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar::/home/osb/osb11.1.1.6/installation/oracle_common/modules/oracle.jrf_11.1.1/jrf-wlstman.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/lib/adfscripting.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/lib/adf-share-mbeans-wlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/lib/mdswlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/auditwlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/igfwlsthelp.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/jps-wlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/jrf-wlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/oamap_help.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/oamAuthnProvider.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/ossoiap_help.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/ossoiap.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/ovdwlsthelp.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/sslconfigwlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/wsm-wlst.jar:/home/osb/osb11.1.1.6/installation/utils/config/10.3/config-launch.jar::/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/derby/lib/derbynet.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/derby/lib/derbyclient.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/derby/lib/derbytools.jar::

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

CREATE DOMAIN
SAVE DOMAIN
READ DOMAIN
ADD TEMPLATES
CREATE MACHINE
CREATE CLUSTER
ADJUST MANAGED SERVER SETTINGS
ADJUST DATA SOURCE SETTINGS
ASSIGN SERVERS TO CLUSTER
ADJUST JMS DEPLOYMENT TO USE UNIFORM DISTRIBUTED QUEUES
drw-   WseeJmsServer507945982
drw-   dist_WseeMessageQueue_auto
drw-   dist_WseeCallbackQueue_auto
drw-   weblogic.wlsb.jms.transporttask.QueueConnectionFactory
drw-   wlsbJMSServer503893383
drw-   dist_wlsb.internal.transport.task.queue.ftp_auto
drw-   dist_wlsb.internal.transport.task.queue.sftp_auto
drw-   dist_wlsb.internal.transport.task.queue.email_auto
drw-   dist_wlsb.internal.transport.task.queue.file_auto
drw-   dist_QueueIn_auto
drw-   dist_wli.reporting.jmsprovider.queue_auto
drw-   dist_wli.reporting.jmsprovider_error.queue_auto
drw-   dist_wli.reporting.purge.queue_auto
SET NODE MANAGER CREDENTIALS
DISABLE HOSTNAME VERIFICATION
SAVE CHANGES
CREATE FILES
WRITING FILE boot.properties
WRITING FILE nodemanager.properties

Next, the node manager must be enrolled. This can be accomplished by using the following WLST script

import socket;
admin_server_listen_address = socket.gethostname();
admin_server_url = 't3://' + admin_server_listen_address + ':' + admin_server_listen_port;

print 'START ADMIN SERVER, AND DO NOT WORRY ABOUT THE EXECEPTIONS';
startServer(admin_server_name, domain_name, admin_server_url, admin_username, admin_password, domain_home);

print 'CONNECT TO ADMIN SERVER';
connect(admin_username, admin_password, admin_server_url);

print 'ENROLL NODE MANAGER AND CREATE NODEMANAGER.DOMAINS';
nmEnroll(domain_home,node_manager_home);

print 'SHUTDOWN ADMIN SERVER';
shutdown('AdminServer','Server','true',1000,'true');

which can be run by using

#!/bin/sh

SCRIPT=$(readlink -f $0)
SCRIPT_PATH=$(dirname $SCRIPT)

. ${SCRIPT_PATH}/SetEnvironmentVariables.sh

${MIDDLEWARE_HOME}/common/bin/wlst.sh -loadProperties ${SCRIPT_PATH}/environment.properties ${SCRIPT_PATH}/enroll_node_manager.py

When this script is run the following output is observed

CLASSPATH=/home/osb/osb11.1.1.6/installation/patch_wls1036/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/osb/osb11.1.1.6/installation/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/home/osb/jrockit-jdk1.6.0_37-R28.2.5-4.1.0/lib/tools.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/server/lib/weblogic_sp.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/server/lib/weblogic.jar:/home/osb/osb11.1.1.6/installation/modules/features/weblogic.server.modules_10.3.6.0.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/server/lib/webservices.jar:/home/osb/osb11.1.1.6/installation/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/home/osb/osb11.1.1.6/installation/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar::/home/osb/osb11.1.1.6/installation/oracle_common/modules/oracle.jrf_11.1.1/jrf-wlstman.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/lib/adfscripting.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/lib/adf-share-mbeans-wlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/lib/mdswlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/auditwlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/igfwlsthelp.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/jps-wlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/jrf-wlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/oamap_help.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/oamAuthnProvider.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/ossoiap_help.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/ossoiap.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/ovdwlsthelp.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/sslconfigwlst.jar:/home/osb/osb11.1.1.6/installation/oracle_common/common/wlst/resources/wsm-wlst.jar:/home/osb/osb11.1.1.6/installation/utils/config/10.3/config-launch.jar::/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/derby/lib/derbynet.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/derby/lib/derbyclient.jar:/home/osb/osb11.1.1.6/installation/wlserver_10.3/common/derby/lib/derbytools.jar::

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

START ADMIN SERVER, AND DO NOT WORRY ABOUT THE EXECEPTIONS
...
WLST-WLS-1358848073802: <Jan 22, 2013 10:49:05 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING>
WLST-WLS-1358848073802: <Jan 22, 2013 10:49:05 AM CET> <Notice> <WebLogicServer> <BEA-000360> <Server started in RUNNING mode>
Server started successfully.
CONNECT TO ADMIN SERVER
Connecting to t3://middleware-magic.com:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain 'osb_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.

ENROLL NODE MANAGER AND CREATE NODEMANAGER.DOMAINS
Enrolling this machine with the domain directory at /home/osb/osb11.1.1.6/configuration/domains/osb_domain ...
Successfully enrolled this machine with the domain directory at /home/osb/osb11.1.1.6/configuration/domains/osb_domain.
SHUTDOWN ADMIN SERVER
Shutting down the server AdminServer with force=true while connected to AdminServer ...
...
WLST-WLS-1358848073802: <Jan 22, 2013 10:49:11 AM CET> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN>
...
WLST-WLS-1358848073802: <Jan 22, 2013 10:49:11 AM CET> <Notice> <Server> <BEA-002607> <Channel "Default" listening on 192.168.1.150:7001 was shutdown.>
...
WLST lost connection to the WebLogic Server that you were
connected to, this may happen if the server was shutdown or
partitioned. You will have to re-connect to the server once the
server is available.
Disconnected from weblogic server: AdminServer
Disconnected from weblogic server:

Enrolling the node manager is to prevent the java.io.IOException: Read did not get bytes, but bytes are available. Another vague exception weblogic.ldap.EmbeddedLDAPException: Unable to open initial replica url can be prevented by making sure the hostnames between machines, managed servers and confgured host files and DNS correspond.

Lifecycle

Start and stop scripts are presented in the WLST Starting and Stopping a WebLogic Environment post.

References

[1] Installation Guide for Oracle Service Bus.
[2] Repository Creation Utility User’s Guide.