Wednesday, 8 March 2017

WebLogic Server 11g and 12cR1 (12.1.1) : Create, Extend and Remove Domains

This article provides a quick overview of managing domains in WebLogic Server 11g and 12cR1 (12.1.1). The examples all relate to WebLogic 11g installations, but the process is exactly the same on WebLogic 12cR1 (12.1.1).

◉ Create a Domain


Start the Configuration Wizard.

$ $WLS_HOME/common/bin/config.sh
Accept the "Create a new WebLogic domain" option by click the the "Next" button.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

Select the products the domain requires and click the "Next" button.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

Enter the domain name and the locations of the domain and application directories, the click the "Next" button.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

Enter an administrator username and password, then click the "Next" button.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

Select the server start mode and JDK, then click the "Next" button. For production mode you should use the JRockit JDK.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

Select any optional configuration (like resetting ports) if required, or click the "Next" button to ignore this step.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

If you are happy with the information in the configuration summary, click the "Create" button.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

Wait while the domain is created, then click the "Done" button to exit the Configuration Wizard.

WebLogic Server, Oracle Database Tutorials and Materials, Oracle Database Certifications

The following scripts are created for the "testDomain" domain.

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


$ # Start WebLogic
$ nohup $MW_HOME/user_projects/domains/testDomain/startWebLogic.sh > /dev/null 2>&1 &
$ # or
$ nohup $MW_HOME/user_projects/domains/testDomain/bin/startWebLogic.sh > /dev/null 2>&1 &

$ # Stop WebLogic
$ $MW_HOME/user_projects/domains/testDomain/bin/stopWebLogic.sh


$ # Start Managed Server
$ nohup $MW_HOME/user_projects/domains/testDomain/bin/startManagedWebLogic.sh AdminServer > /dev/null 2>&1 &

$ # Stop Managed Server
$ $MW_HOME/user_projects/domains/testDomain/bin/stopManagedWebLogic.sh AdminServer

◉ Extend a Domain


Extending a domain involves similar screens to those seen during the installation.

◈ Start the Configuration Wizard.
◈ Select the "Extend an existing WebLogic domain" option and click the "Next" button.
◈ Select the required domain from the tree and click the "Next" button.
◈ Select the additional products the domain should support and click the "Next" button.
◈ Select any optional configuration if required, then click the "Next" button.
◈ If you are happy with the information in the configuration summary, click the "Extend" button.
◈ Wait while the domain is extended, then click the "Done" button to exist the Configuration Wizard.

◉ Delete a Domain


To remove the "testDomain" domain we just created, do the following steps:

◈ Stop the processes associated with the domain.

◈ Remove the relevant domain entry from the "$MW_HOME/domain-registry.xml" file.

<?xml version="1.0" encoding="UTF-8"?>
<domain-registry xmlns="http://xmlns.oracle.com/weblogic/domain-registry">
  <domain location="/u01/app/oracle/middleware/user_projects/domains/testDomain"/>
</domain-registry>

◈ Remove the relevant domain entry from the "$WLS_HOME/common/nodemanager/nodemanager.domains" file.

#Domains and directories created by Configuration Wizard
#Thu Aug 23 22:53:14 BST 2012
testDomain=/u01/app/oracle/middleware/user_projects/domains/testDomain

◈ Delete the "testDomain" application and domain directories.

$ rm -Rf $MW_HOME/user_projects/applications/testDomain
$ rm -Rf $MW_HOME/user_projects/domains/testDomain

◉ Creating a Boot Identity File


When running in production mode, starting a server requires the credentials you provided while creating the domain. Using a boot identity file prevents you from having to type in the username/password each time the server is started.

Create a file called "boot.properties" with the following contents.

username=weblogic
password=mypassword

Save the file under the "$MW_HOME/user_projects/domains/<domain-name>/servers/<server-name>/security" directory. The managed server will now start and stop without needing credentials.

Alternatively, modify the JAVA_OPTIONS in the "setDomainEnv.sh" file to point to the location of the file. For example, if the "boot.properties" file is in the domain's home directory, you could place the following lines after the DOMAIN_HOME defintion. This method works fine for startup, but shutdown will still require credentials, so it is not as convenient.

JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.system.BootIdentityFile=${DOMAIN_HOME}/boot.properties"
export JAVA_OPTIONS

The first time the server starts using a boot identity file, it will encrypt the credentials in the file and use them when starting in future.

◉ Altering Server Port Settings


When you create a domain you will automatically create an AdminServer that listens on port 7001 by default. To change this, edit the "$MW_HOME/user_projects/domains/<domain-name>/config/config.xml" file, adding or amending the "listen-port" entry, shown in bold.

  <server>
    <name>AdminServer</name>
    <listen-port>7004</listen-port>
    <listen-address/>
    <server-diagnostic-config>
      <name>AdminServer</name>
      <diagnostic-context-enabled>true</diagnostic-context-enabled>
    </server-diagnostic-config>
  </server>

◉ Switching Development/Production Startup Mode


There are two locations where the startup mode can be set. If you are using the Java based controls the mode is picked up from the "$MW_HOME/user_projects/domains/domain-name/config/config.xml" file. Set the "production-mode-enabled" tag to the appropriate value.

<production-mode-enabled>true</production-mode-enabled>

If you are starting the domain using the generated startup scripts, you should edit the "$MW_HOME/user_projects/domains/domain-name/bin/setDomainEnv.sh" file. Set the "PRODUCTION_MODE" parameter to the appropriate value.

PRODUCTION_MODE="true"
export PRODUCTION_MODE

To prevent confusion, it makes sense to keep both files set to the same value.