Creating a Clustered Domain in WebLogic 11g

In this post I’m creating a simple WebLogic 10.3.6 cluster domain with two Managed Servers, across two Linux machines, named linux01.vbox and linux02.vbox.  Obviously you need to have already installed WebLogic 11g at this point.

There are a few different ways you can create a cluster domain in WebLogic, but I usually start with the GUI wizard and then use the pack/unpack utilities to copy over the configuration…

Open the WebLogic domain configuration wizard:

.  ./set_wls11.env
echo $WLS_HOME=/u01/app/oracle/middleware/wls_10.3.6
$WLS_HOME/common/bin/config.sh

Once the GUI starts, respond as follows:

  • Welcome
    • Create a new WebLogic domain
    • Next
  • Select Domain Source
    • Generate a domain configured automatically to support the following products:
    • Tick ‘Oracle Enterprise Manager’ (Oracle JRF components will be automatically added)
    • Next
  • Specify Domain Name and Location
    • Domain Name: ClusterDomain
    • Domain Location: /u01/app/oracle/middleware/user_projects/domains
    • Application location: /u01/app/oracle/middleware/user_projects/applications
    • Next
  • Configure Administrator User Name and Password
    • Name: weblogic
    • User password: password1
    • Confirm user password: password1
    • Next
  • Configure Server Start Mode and JDK
    • Development Mode (unless Production)
    • Available JDKs: JRockit SDK 1.6.0_37…
    • Next
  • Select Optional Configuration
    • Tick Administration Server
    • Tick Managed Servers, Clusters and Machines
    • Next
  • Configure the Administration Server
    • Name: AdminServer
    • Listen address: linux01.vbox
    • Listen port: 7004
    • SSL enabled: tick
    • SSL listen port: 7504
    • Next
  • Configure Managed Servers
    • Add
      • Name: ManagedServer_1
      • Listen address: linux01.vbox
      • Listen port: 7007
      • Tick SSL enabled
      • SSL listen port: 7507
    • Add
      • Name: ManagedServer_2
      • Listen address: linux02.vbox
      • Listen port: 7007
      • Tick SSL enabled
      • SSL listen port: 7507
    • Next
  • Configure Clusters
    • Add
      • Name: Cluster_1
      • Cluster messaging mode: unicast
      • Cluster address: linux01.vbox
    • Next
  • Assign Servers to Clusters
    • Assign Server ManagedServer_1 to Cluster Cluster_1
    • Assign Server ManagedServer_2 to Cluster Cluster_1
    • Next
  • Configure Machines
    • Select Unix Machine tab
    • Add
      • Name: linux01.vbox
      • Node manager listen address: linux01.vbox
      • Node manager listen port: 5556
    • Add
      • Name: linux02.vbox
      • Node manager listen address: linux02.vbox
      • Node manager listen port: 5556
    • Next
  • Assign Servers to Machines
    • Assign Server AdminServer to Machine linux01.vbox
    • Assign Server ManagedServer_1 to Machine linux01.vbox
    • Assign Server ManagedServer_2 to Machine linux02.vbox
    • Next
  • Configuration Summary
    • Check the configuration is correct
    • Create
  • Creating Domain
    • Once created, click Done

Create a boot.properties file for the new Admin Server

Rather than having to enter the credentials in each time, create a boot.properties file (an encrypted password file) for your Admin Server :

export DOMAIN_HOME=/u01/app/oracle/middleware/user_projects/domains/ClusterDomain
mkdir -p $DOMAIN_HOME/servers/AdminServer/security
vi $DOMAIN_HOME/servers/AdminServer/security/boot.properties

The contents of the file should be like below:

username=weblogic
password=password1

The password will be encrypted once the WebLogic server is restarted.

Start the Node Manager (unless it’s already running of course):

nohup $WLS_HOME/server/bin/startNodeManager.sh > /dev/null 2>&1 &

Start the Admin Server for your domain and tail the log file:

nohup $DOMAIN_HOME/startWebLogic.sh > /dev/null 2>&1 &
sleep 10
tail -f $DOMAIN_HOME/servers/AdminServer/logs/AdminServer.log

wait for a few minutes and look out for the following to ensure the Admin Server starts up correctly (CTRL+C to exit from the tail command above):

<BEA-000360> <Server started in RUNNING mode>

Pack and unpack your Domain configuration

WebLogic provides two command-line utilities, pack and unpack.  These two utilities provide a quick way to package up your existing domain configuration for distribution across other machines within your cluster.

On your primary machine (linux01), pack up the domain configuration (ensuring DOMAIN_HOME is still set):

cd $WL_HOME/common/bin 
./pack.sh -managed=true -domain=$DOMAIN_HOME -template=${DOMAIN_HOME}-template.jar -template_name=ClusterDomain

Copy the jar file across to the other machine in your domain (linux02):

scp ${DOMAIN_HOME}-template.jar linux02.vbox:/u01/app/oracle/middleware/user_projects/domains

Then use unpack on the second machine to write the necessary configuration files for your cluster domain:

export DOMAIN_HOME=/u01/app/oracle/middleware/user_projects/domains/ClusterDomain
cd $WL_HOME/common/bin
./unpack.sh -domain=$DOMAIN_HOME -template=${DOMAIN_HOME}-template.jar

Enroll your second machine

Now we need to enroll the second machine into the WebLogic Domain.  Using the WebLogic Scripting Tool (WLST), from the second machine (linux02), we connect to the Admin Server on the first machine (linux01), and register this second machine as follows:

$WLS_HOME/common/bin/wlst.sh
connect('weblogic','password1','t3://linux01.vbox:7004')
nmEnroll ('/u01/app/oracle/middleware/user_projects/domains/ClusterDomain','/u01/app/oracle/middleware/wls_10.3.6/common/nodemanager')
disconnect()
exit()

Add boot.properties files for Managed Servers

On the primary machine (linux01), copy the boot.properties file from earlier into your Managed Server security directory:

mkdir -p $DOMAIN_HOME/servers/ManagedServer_1/security
cp $DOMAIN_HOME/servers/AdminServer/security/boot.properties $DOMAIN_HOME/servers/ManagedServer_1/security

Then on your second machine (linux02) create a boot.properties file as before:

mkdir -p $DOMAIN_HOME/servers/ManagedServer_2/security
vi $DOMAIN_HOME/servers/ManagedServer_2/security/boot.properties

The contents of the file should be like below:

username=weblogic
password=password1

Check the Domain has been registered correctly

On both of the servers, check that the domain has been registered correctly with the Node Manager services by looking at the following files:

grep $DOMAIN_HOME $MW_HOME/domain-registry.xml
 u01/app/oracle/middleware/user_projects/domains/ClusterDomain"/>

grep $DOMAIN_HOME $WLS_HOME/common/nodemanager/nodemanager.domains
clusterDomain=/u01/app/oracle/middleware/user_projects/domains/ClusterDomain

Finally, make sure the Node Manager services are up and running on both machines, if not, start them:

ps -ef|grep NodeManager
nohup $WLS_HOME/server/bin/startNodeManager.sh > /dev/null 2>&1 &

Start the Managed Servers

You should be able to now log into the WebLogic console and start the Managed Servers 🙂

http://linux01.vbox:7004/console

…or you can start them from the command line on each of the machines:

nohup $DOMAIN_HOME/bin/startManagedWebLogic.sh ManagedServer_1 > /dev/null 2>&1 &
nohup $DOMAIN_HOME/bin/startManagedWebLogic.sh ManagedServer_2 > /dev/null 2>&1 &

Stop/Start scripts for your new Domain

Once you’re happy with everything, you’ll probably want to create some stop and start scripts to make life easier when managing your domain…here are a couple I made earlier 😉

mkdir ~/scripts

Shutdown your domain:

vi ~/scripts/stop_ClusterDomain.sh

# Set environment variables
export MW_HOME=/u01/app/oracle/middleware
export WLS_HOME=$MW_HOME/wls_10.3.6
export DOMAIN_NAME=ClusterDomain
export DOMAIN_HOME=$MW_HOME/user_projects/domains/$DOMAIN_NAME

echo Stopping WebLogic Managed Servers...
echo Stopping WebLogic Managed Server : ManagedServer_1
$DOMAIN_HOME/bin/stopManagedWebLogic.sh ManagedServer_1

echo Stopping WebLogic Admin Server...
$DOMAIN_HOME/bin/stopWebLogic.sh

echo Stopping Node Manager...
nm_pid=`ps -ef | grep [N]odeManager | awk '{print $2}'`
if [ "$nm_pid" = "" ];
then echo Node Manager not running
else echo Killing Node Manager processes: $nm_pid
kill -9 $nm_pid 2>&1 > /dev/null
fi

echo "Tidying up temp files..."
find $DOMAIN_HOME/servers -name "*.lok" -exec rm -f {} ;
find $DOMAIN_HOME/servers -name "*.DAT" -exec rm -f {} ;

echo Done!

Startup your domain:

vi ~/scripts/start_ClusterDomain.sh

# Set environment variables
export MW_HOME=/u01/app/oracle/middleware
export WLS_HOME=$MW_HOME/wls_10.3.6
export DOMAIN_NAME=ClusterDomain
export DOMAIN_HOME=$MW_HOME/user_projects/domains/$DOMAIN_NAME

echo Starting Node Manager...
nohup $WLS_HOME/server/bin/startNodeManager.sh > /dev/null 2>&1 &
sleep 10

echo Starting WebLogic Admin Server...
nohup $DOMAIN_HOME/bin/startWebLogic.sh > /dev/null 2>&1 &
sleep 120

echo Starting WebLogic Managed Servers...
echo Starting WebLogic Managed Server : ManagedServer_1
nohup $DOMAIN_HOME/bin/startManagedWebLogic.sh ManagedServer_1 > /dev/null 2>&1 &

echo Done!

These scripts would be executed against your primary machine.  The same scripts can be applied to your second machine, just without the Admin Server reference, and renaming your Managed Server appropriately  e.g. ManagedServer_2

6 thoughts on “Creating a Clustered Domain in WebLogic 11g

Leave a comment

Your e-mail address will not be published. Required fields are marked *