Monday, August 17, 2009

WebLogic Pack and Unpack Commands

One small WebLogic utility which I think doesn't get the recognition it deserves is the pack and unpack command.

Sure you could just Copy + Paste your domain from node to node, but why not achieve the same thing in a more elegant and tidy way? And good luck pasting to your remote EC2 or cloud servers by the way!

What does the pack and unpack command do?

The pack and unpack commands provide a quick alternative way to package up your existing WLS domain for transportation and distribution across members of your WLS cluster.

It can be used to do more as well, like creating domains and templates, but we are just going to focus on the features associated with copying existing domains, and specifically WLS Managed Servers.

This is the best way to go to move domain information with Managed Server configs etc, to other EC2 machines or to servers in your cloud infrastructure.

The pack command creates a template archive (.jar) file that contains a snapshot of a domain, while the unpack command is used to create a Managed Server domain directory hierarchy on a remote machine.

Pack syntax

pack -domain=domain -template=template -template_name="template_name"

[-template_author="author"][-template_desc="description"]
[-managed={true|false}][-log=log_file] [-log_priority=log_priority]

You create a Managed Server template by executing the pack command, on an existing domain that already includes the definition of one or more Managed Servers. This domain must contain Managed Server definitions in the config.xml file, which are the ones you have specified when you completed the Domain Config Wizard.

You can create the template
with the -managed=true option, which should copy additional files to the template including .cmd, .sh, .xml, .ini and .properties files, but I have found that the default parameter -managed=false does copy all these files faithfully anyway. Include or exclude this parameter as you wish, your experiences may be different to mine, but -managed=false is not a required parameter.

From the machine that contains the Administration Server and the definition of Managed Servers, navigate to the /bea/wlserver_10.3/common/bin and run:

pack -domain=domain -template=template.jar -template_name="template_name"

Where,
  • domain: The path to the domain from which the template is to be created.
  • template.jar: The path to the template, and the filename of the template to be created.
  • template_name: Descriptive name for the template enclosed in quotes.
For example, executing the following command creates a Managed Server template named mydomain_managed.jar from a domain named mydomain.

pack -domain=/bea/user_projects/domains/mydomain

-template=/bea/user_templates/mydomain_managed.jar
-template_name="My Managed Server Domain"

Unpack syntax

unpack -template=template -domain=domain [-user_name=username]

[-password=password] [-app_dir=application_directory]
[-java_home=java_home_directory] [-server_start_mode={dev|prod}]
[-log=log_file] [-log_priority=log_priority]

Now this looks a little trickier, but it is not.

Remember you must have installed WebLogic Server onto each machine you want to host a Managed Server, and all WebLogic Server instances within your domain must run the same version of the WebLogic Server software.

You need to establish a session with your destination machine, eg SSH whatever, create a directory /bea/user_templates and copy the .jar file over to that server directory. Remember your file permissions and most importantly the destination servers IP and port information must match what you entered in the Domain Config Wizard when you initially created the domain template.

On the destination machine, navigate to the /bea/wlserver_10.3/common/bin and run:

unpack -domain=domain -template=template.jar

Where,
  • domain: The path to the domain to be created.
  • template.jar: The path to the template from which the domain is to be created
For example, executing the following command using a template named mydomain_managed.jar creates a domain named myManagedDomain.

unpack -domain=/bea/user_projects/domains/myManagedDomain
-template=/bea/user_templates/mydomain_managed.jar

Conclusion

That's it. You will then be rewarded with a nice new directory structure created for you with all the important domain pieces in place. Start it up via Node Manager, or with your startManagedWebLogic command.

A nice simple and quick way to distribute all your managed servers across your domain cluster members, and easier than Copy + Paste.

Well I think so anyway :-)