Tuesday, December 28, 2010

Pack & UnPack

BEA provides several tools for creating domains and templates: the Configuration Wizard, the Domain Template Builder, WLST Offline, and the pack and unpack commands. The pack and unpackcommands provide a simple, one-step method for creating domains and templates from the command line. They do not, however, allow you to customize the contents of your domain or template in the same way as the other tools.


The command is residding at wlserver/common/bin


Although the pack command does not allow you to customize the contents of your template in the same way as the Domain Template Builder, it is a useful tool for quickly creating the following:

  • A domain template that contains a snapshot of an entire working domain that has been customized through the Administration Console, Configuration Wizard, or WebLogic Scripting Tool (WLST). This template can then be used to create a domain using unpack, the Configuration Wizard, or WebLogic Scripting Tool (WLST) Offline.
  • A Managed Server template that contains a subset of the files in a domain that are required to create a Managed Server domain directory hierarchy on a remote machine. You can then useunpack to create the Managed Server domain directory on the remote machine.  
About Domain and Managed Server Templates: The term template refers to a Java Archive (JAR) file that contains the files and scripts required to create a domain

  • Domain template—defines the full set of resources within a domain, including infrastructure components, applications, services, security options, and general environment and operating system options. Using the pack command, you can create a domain template from an existing domain. A domain template is used to create a new domain.
  • Managed Server template—defines the subset of resources within a domain that are required to create a Managed Server domain directory on a remote machine. You create a Managed Server template using the pack command, with the -managed=true option. Subsequently, when you use the Managed Server template with the unpack command, the Managed Server domain directory that is created contains sufficient bootstrap information to start the Managed Server on the remote machine. You can start the Managed Server on the remote machine in either of two ways: using Node Manager, or using customized start scripts created when you unpacked the template on the remote machine.


pack

The pack command creates a template archive (.jar) file that contains a snapshot of either an entire domain or a subset of a domain. You can use a template that contains a subset of a domain to create a Managed Server domain directory hierarchy on a remote machine.
The following table describes the files and directories that are included in both domain and Managed Server templates.
When you create this type of template . . .
The following occurs . . .
Domain
All files and directories in the source domain are included, with the following exceptions:
  • Temporary files that are created when you start a server.
  • The servers directory.
  • Files in the security directory that are created automatically when you create the domain, such as DefaultAuthenticatorInit.ldift andXACMLRoleMapperInit.ldift.
Note:If you configured additional security data, such as for users, groups, or roles, through the WebLogic Server Administration Console or other online tools, the security data is stored in the LDAP server and is not included in the template. You must first export the data and then import it into the target domain.
Managed Server (using the -managed=trueoption)
The following files and directories are included by default:
  • All files in the root directory with the following extensions: .cmd.sh.xml.properties, and.ini.
  • Any files with the.pem extension defined in the SSL configuration for your domain
  • bin directory
  • lib directory
  • All files and subdirectories in the config directory
The following files and directories are not included in a Managed Server template by default:
  • Applications and certain application initialization files
  • Temporary files that are created when you start a server
  • The servers directory
  • Files in the security directory that are created automatically when you create the domain, such as DefaultAuthenticatorInit.ldift andXACMLRoleMapperInit.ldift.
Note:The config.xml file of the domain from which you are creating your template must contain Managed Server definitions that specify the IP address and port for the target remote machine. The Managed Server template that you create from that domain can only be used, with the unpack command, on the specified remote machines to create Managed Server domain directories for the Managed Servers defined in the config.xml file.

Example

Executing the following command using a domain named mydomain in the directory C:\bea\user_projects\domains creates a template file named mydomain.jar in the directoryC:\bea\user_templates. The name of the template is specified as My WebLogic Domain.

pack -domain=C:\bea\user_projects\domains\mydomain
-template=C:\bea\user_templates\mydomain.jar -template_name="My WebLogic Domain"

unpack

Creates a full domain or a subset of a domain used for a Managed Server domain directory on a remote machine. You may use unpack only with a template compatible with your current installation. The template can be any of the following:
  • A domain template provided by BEA and packaged with your current installation
  • A domain template created using the Domain Template Builder or WLST Offline
  • A domain template created using the pack command
  • A Managed Server template created using the pack command. A Managed Server template, by default, contains only the files necessary for creating a Managed Server domain directory.
When you use the unpack command with a domain template, it creates a domain containing all of the application and resource files defined in the template. It also creates necessary start scripts, and certain security and configuration files.
When you use the unpack command with a Managed Server template, it creates a Managed Server domain directory that includes the following:
  • A customized start script for each Managed Server in the domain
  • config_bootstrap.xml file (based on the config.xml in the template)
  • nm_password.properties file
  • SerializedSystemIni.dat file
An entry for the Managed Server domain directory is also created in the NM_HOME/nodemanager.domains file, where NM_HOME designates the Node Manager installation directory for the product installation on the remote machine. By default, this directory is located in WL_HOME/common/nodemanager, for example, C:\bea\weblogic92\common\nodemanager\nodemanager.domains.

Note:By default, application files are not included in a Managed Server template created using the pack command. If an application in the domain from which you created a Managed Server template was deployed using external_stage mode, the Managed Server domain directory that you create with the unpack command will not contain any of the external_staged applications. Before you start the Managed Server, you will need to make sure that it has access to the externally staged application files. For more information, see Controlling Deployment File Copying with Staging Modes in Deploying Applications to WebLogic Server.

Example

Executing the following command using a template named mydomain.jar in the directory C:\bea\user_templates creates a domain named my_new_domain in the directoryC:\bea\user_projects\domains.
unpack -template=C:\bea\user_templates\mydomain.jar -domain=C:\bea\user_projects\domains\my_new_domain
Use pack to Create a Managed Server Template
You create a Managed Server template by executing the pack command, with the -managed=true option, on an existing domain that already includes the definition of one or more Managed Servers. This domain must also contain Managed Server definitions in the config.xml file.
  1. From the command line on the local machine (that is, the machine that contains the Administration Server and the definition of Managed Servers), navigate to the WL_HOME\common\bindirectory. In this pathname, WL_HOME is the product directory in which you installed WebLogic Server.
  2. Execute the following command:
  3. pack -managed=true -domain=domain
    -template=template.jar -template_name="template_name"
    
    In this command line:
    • domain—The full or relative path to the domain from which the template is to be created.
    • template.jar—The full or relative 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 -managed=true -domain=C:\bea\user_projects\domains\mydomain
      -template=C:\bea\user_templates\mydomain_managed.jar
      -template_name="My Managed Server Domain"
Use unpack to Create a Managed Server on a Remote Machine
  1. Install WebLogic Server on each machine that you want to host a Managed Server for the domain.
  2. Note:All WebLogic Server instances within a domain must run the same version of the WebLogic Server software. For more information about installing WebLogic Server, see the Installation Guide.
  3. Establish a session with the remote machine that will host the Managed Server. You may use any valid method, such as telnet, to do so.
  4. Note:The IP address and port number of the remote machine must match the definition of the Managed Servers specified in the Managed Server template.
  5. Copy the Managed Server template to the remote machine. For details about how to create a Managed Server template, see How Do I: Use pack to Create a Managed Server Template.
  6. On the remote machine, navigate to the WL_HOME\common\bin directory. In this pathname, WL_HOME is the product directory in which you installed WebLogic Server.
  7. Execute the following command, using the Managed Server template that you copied to the machine in Step 3.
  8. unpack -domain=domain -template=template.jar
    
    In this command line:
    • domain—The full or relative path to the domain to be created.
    • template.jar—The full or relative 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=C:\bea\user_projects\domains\myManagedDomain
      -template=C:\bea\user_templates\mydomain_managed.jar

 Start Managed Servers on a Remote Machine

When you create a domain directory for Managed Servers using the unpack command, it contains a customized start script for each Managed Server targeted to the current remote machine. For example, if you create a domain that contains two Managed Servers, my_managed_server1 and my_managed_server2, and you target the servers to machine m1, when you create the Managed Server domain directory on machine m1, four custom start scripts are created: startmy_managed_server1.cmd/startmy_managed_server1.sh andstartmy_managed_server2.cmd/startmy_managed_server2.sh. You can use these scripts to start the corresponding Managed Servers. Alternatively, you can use the startManagedWebLogicscript with the required parameters.
  1. Start the Administration Server for the domain as described in Starting and Stopping Servers in Managing Server Startup and Shutdown.
  2. On the remote machine, navigate to the directory for the domain that you created in How Do I: Use unpack to Create a Managed Server on a Remote Machine.
  3. Start the Managed Server on the remote machine by doing one of the following:
    • On a Windows system, open an MS-DOS command prompt window and enter one of the following at the prompt:
    • startmy_managed_server
      startManagedWebLogic my_managed_server admin-url
    • On a UNIX system, enter one of the following at the prompt:
    • ./startmy_managed_server.sh
      ./startManagedWebLogic.sh my_managed_server admin-url
      In these command lines, my_managed_server is the name of the Managed Server to be started and admin-url specifies the listen address (host name or IP address) and port number of the machine hosting the Administration Server. For your convenience, the startManagedWebLogic_Readme.txt file provides a list of all the Managed Servers and the admin-url for the domain. http://download.oracle.com/docs/cd/E13179_01/common/docs92/pack/tasks.html