Friday, October 23, 2009

How to Create Script for Weblogic Server Configuration

One way to create the WLST script is to use the Weblogic configuration wizard to configure the domain and server. After it is done, use a WLST command to generate the script from the configured server.

The following describes the steps.
  1. Use weblogic configuration wizard to create the domain. You will give the domain a name. Here suppose we use "myDomain".
  2. Execute C:\bea10\wlserver_10.3\common\bin\wlst.cmd. This will set the environment and give the prompt wls:/offline>
  3. Run WLST command configToScript to generate scripts. Example:
    configToScript('c:/bea10/user_projects/domains/myDomain','c:/myscripts')
    This will generate four files under the directory c:/myscripts: config.py, config.py.properties, c2sConfigmyDomain, and c2sSecretmyDomain.
  4. We won't use c2sConfigmyDomain or c2sSecretmyDomain. We need to modify config.py and config.py.properties files.
    In the config.py file, a critical change is to change setEncrypted("Password", .....) to set("Password","..."), i.e, to use the plain text password. Remove any string values that use those c2s values. Also delete the call in the script that set credentials.
    In the config.py.properties file, a critical change is to modify the domain directory to your desired domain name, say 'myNewDomain':
    domainDir=C:/bea10/user_projects/domains/myNewDomain
Now you can run the script to create the domain. First run the file at %WL10_HOME%\wlserver_10.3\common\bin\wlst.cmd. Then at the WLST command promt, execute the following
execfile('C:/myscripts/config.py')
After execution, your new domain will be created at C:/bea10/user_projects/domains/myNewDomain.
There are still some little things you need to modify. The following are the steps.
  1. The file %WL10_HOME%\wlserver_10.3\common\bin\commonEnv.cmd sets the patch.jar in the classpath. But the default download of webogic 10gR3 does not seem to include the patch.jar. And this may cause error when the weblogic server is started. So modify commonEnv.cmd to exclude patch jar files.
  2. The generated script will use jrocket even though the domain was created by wizard to use jdk.

    To use jdk, in the file myNewDomain\bin\setDomainEnv.cmd, change the following

    if "%JAVA_VENDOR%"=="BEA" (
    set JAVA_HOME=%BEA_JAVA_HOME%
    ) else (
    if "%JAVA_VENDOR%"=="Sun" (
    set JAVA_HOME=%SUN_JAVA_HOME%
    ) else (
    set JAVA_VENDOR=BEA
    set JAVA_HOME=C:\bea10\jrockit_160_05
    )
    )

    To

    if "%JAVA_VENDOR%"=="BEA" (
    set JAVA_HOME=%BEA_JAVA_HOME%
    ) else (
    if "%JAVA_VENDOR%"=="Sun" (
    set JAVA_HOME=%SUN_JAVA_HOME%
    ) else (
    set JAVA_VENDOR=Sun
    set JAVA_HOME=C:\bea10\jdk160_05
    )
    )

Notes on creating server cluster with the WLST script.

Assume the following scenario. You have one admin server myAdminServer and one cluster myCluster. The cluster has two servers: myAppServer1 and myAppServer2. The two servers will be located on the two linux machines machine1 and machine2 respectively. We'll also assume that the admin server will be on machine1. The admin server and the cluster will use different port numbers. Assume that myAdminServer will use port number 7001 and the cluster will use 7002. These port numbers can be specified in the property file for the WLST script.
First on machine1, make sure no server is running at the port 7001. Now run the WLST script on machine1 to create the domain. Then simply copy the whole domain to the same location in the directory structure on machine2. No other configuration is needed on machine2.

5 comments:

  1. Hi You; thanks for the tutorial. Do you know if the configToScript() command is supposed to replicate clusters that exist in the domain as well? In my domain I have an Admin server, one cluster and two servers in the cluster but the configToScript only recreates the AdminServer.

    I can't find any information on the possibly adding more args to the config.py.properties file, only the default one.

    Thanks again.

    Sean

    ReplyDelete
  2. If you have created the cluster using the console, the ConfigToScript command will also generate the code for cluster creation. In the config.py.properties file, you can specify the port number and the listenAddress of the servers in the cluster. You can also specify the multicast port, multicastAddress, and the clusterAddress for the cluster.
    If the default generated config.py.properties file does not have the properties you want to customize, you can simply add them and use them in the config.py file.

    ReplyDelete
  3. Hi This is a great blog!!

    Would like to know:-
    What if we want to upgrade the domain?
    I mean moving from 10 to 10.3?
    how can i change the version? there is a method in py script but changing that will it really create a new one?

    ReplyDelete
  4. I am not sure on that. But you can do some tests to see what will happen when you change the version number. I would guess that there will be no big change from 10 to 10.3 so the py script will still work. Also it may not be needed to use the version numbers in the py script if your purpose is just to configure those stuff such as datasource, jms, etc for the domain.

    ReplyDelete
  5. Thank you for this excellent post !..

    ReplyDelete