Friday, February 15, 2008

Concepts of WPARs and configuring DB2

WPAR (Workload Partition) is a licensed program product shipped with IBM® AIX® 610. Tthis article teaches WPAR concepts and configurations. By following the examples in this article, you will be able to install and configure DB2® on a system and application WPAR.

Overview

WPAR is an isolated execution environment with its own init processes inside standard AIX machines. To the end user, WPAR appears as a standalone AIX machine with its own set of processes similar to standard AIX machines. This article concentrates on the following concepts, which are useful in setting up a DB2 environment inside a WPAR:

  • Types of WPARs (system and application WPARs)
  • Creating system WPARs
  • Installing and configuring DB2 on a WPAR

 

The instructions and tips provided in this article can help users of WPARs with installation and configuration of various products, such as DB2, Oracle, IDS, WebSphere® Application Server, and SAP.

Types of WPARs

WPARs can be categorized as system and application WPARs.

  • A system WPAR is a process inside standard AIX machines (which I will call "Global") with its own execution environment. It provides all standard (/ /usr /opt /var /etc /tmp and /home) file systems to the end user. System WPARs can share /usr or /opt from Global in read-only mode or can have its own /usr or /opt file systems. File systems in system WPARs could be configured in three different ways: with shared /usr and /opt (which is namefs type), with private /usr and /opt, and with so-called "remote" - root file systems are configured as NFS types (could be nfsv3 and nfsv4) and mounted from a NFS server.
  • An application WPAR is also a process inside the Global machine with its own execution environment and uses all file systems from the global environment. Application WPARs start with a startup script and end whenever the startup script completes its execution. For instance:
      
    wparexec -n "application wpar name" "absolute path of the script to be 
    executed with arguments if any"
    

     

     

       
    # wparexec -n appwpar /usr/bin/sleep 10
    Starting workload partition appwpar.
    Mounting all workload partition file systems.
    Loading workload partition.
    [ ----Script will start execution here---- ]
    Shutting down all workload partition processes.
    

      

    Appwpar will be started and execute the script given. In this case, it is sleep 10. Application WPAR will terminate itself after sleeping for 10 seconds.

How do you create system WPARs?

There are three ways to create system WPARs based on how you allocate file systems to system WPARs:

  • System WPAR with shared /usr
  • System WPAR with private /usr
  • System WPAR with remote OR NFS exported file systems

 

System WPAR with shared /usr

In this WPAR, /usr and /opt of Global are shared by the system WPAR. The following command creates the shared system WPAR:

mkwpar -n shared_wpar

  

The following figure shows the file system mapping of Global and the shared system WPAR.


Figure 1. Shared WPAR in Global environment
Shared WPAR in Global environment
 


File systems in shared WPARs
 

                    

# lsfs|grep shared_wpar
/dev/fslv00  --         /wpars/shared_wpar       jfs2   
/dev/fslv01  --         /wpars/shared_wpar/home   jfs2   
/opt   --         /wpars/shared_wpar/opt   namefs  
/proc   --         /wpars/shared_wpar/proc   namefs  
/dev/fslv02  --         /wpars/shared_wpar/tmp   jfs2   
/usr   --         /wpars/shared_wpar/usr   namefs  
/dev/fslv03  --         /wpars/shared_wpar/var   jfs2  

  

System WPARs with private /usr

In this WPAR, /usr and /opt are created separately for the system WPAR. Global gives Logical Volumes required to create /usr and /opt file systems (see Figure 2). The following command creates the private system WPAR:

mkwpar -l -N interface=en0 address="IP" netmask=255.255.255.192 
broadcast=9.2.60.255 -n "wpar name having DNS entry"

  

IP and DNS name are needed for system WPARs as DB2 probes for it while creating the DB2 instance. The following figure shows file system mapping of Global and the private system WPAR.


Figure 2. Private WPAR in the Global environment
Private WPAR in Global environment
 


File systems in a private WPAR
 

                    

# lsfs|grep private_wpar
/dev/fslv04 --         /wpars/private_wpar      jfs2   
/dev/fslv05 --         /wpars/private_wpar/home   jfs2   
/dev/fslv06      --         /wpars/private_wpar/opt   jfs2   
/proc            --         /wpars/private_wpar/proc   namefs  
/dev/fslv07      --         /wpars/private_wpar/tmp   jfs2   
/dev/fslv08      --         /wpars/private_wpar/usr   jfs2   
/dev/fslv09     --         /wpars/private_wpar/var   jfs2   

  

System WPAR with remote OR NFS exported File systems

In this WPAR, all the file systems come from a NFS server, which exports file systems using the mknfsexp command. The following figure shows file system mapping of Global and Remote System WPARs.


Figure 3. Remote WPAR in Global env ironment
Remote WPAR in Global env ironment
 


File systems in remote WPAR
 

                    
# lsfs|grep remote_wpar
/remote_wpar janet01    /wpars/remote_wpar      nfs    
/remote_wpar/opt  janet01    /wpars/remote_wpar/opt  nfs    
/proc  --   /wpars/remote_wpar/proc  namefs  
/remote_wpar/tmp  janet01    /wpars/remote_wpar/tmp  nfs    
/remote_wpar/usr  janet01    /wpars/remote_wpar/usr  nfs    
/remote_wpar/var  janet01    /wpars/remote_wpar/var  nfs    

  

The following command creates remote WPARs:

/usr/sbin/mkwpar -A -F -s -r -n remote_wpar -f remote_wpar.cf

 

remote_wpar.cf is the specification file used to create remote_wpar WPAR.

Entries in remote_wpar.cf are:

#cat remote_wpar.cf

network:
       interface = en0
       netmask = 255.255.255.192
       address = 9.2.65.91

general:
       privateusr=yes

mount:
        dev = /remote_wpar
        directory = /
        vfs = nfs
        host = janet01
  
mount:
        dev = /remote_wpar/usr
        directory = /usr
        vfs = nfs
        host = janet01

mount:
        dev = /remote_wpar/opt
        directory = /opt
        vfs = nfs
        host = janet01

mount:
        dev = /remote_wpar/var
        directory = /var
        vfs = nfs
        host = janet01

mount:
        dev = /remote_wpar/home
        directory = /home
        vfs = nfs
        host = janet01

mount:
        dev = /remote_wpar/tmp
        directory = /tmp
        vfs = nfs
        host = janet01

 

Here janet01 is the NFS server holding file systems required for remote system WPARs.

The following shows how to create and export /remote_wpar/* file systems on an NFS server:


Creation of file systems
 
                
crfs -v jfs2 -g ${VG} -m /remote_wpar -A yes -a size=${SZ}
crfs -v jfs2 -g ${VG} -m /remote_wpar/usr -A yes -a size=${SZ}
crfs -v jfs2 -g ${VG} -m /remote_wpar/opt -A yes -a size=${SZ}
crfs -v jfs2 -g ${VG} -m /remote_wpar/var -A yes -a size=${SZ}
crfs -v jfs2 -g ${VG} -m /remote_wpar/home -A yes -a size=${SZ}
crfs -v jfs2 -g ${VG} -m /remote_wpar/tmp -A yes -a size=${SZ}

 

where VG is Volume Group and SZ is size of file system.

This example shows how to export file systems:

mknfsexp -d /remote_wpar -B -a 0 -v 3 -t rw -r *.ibm.com
mknfsexp -d /remote_wpar/usr -B -a 0 -v 3 -t rw -r *.ibm.com
mknfsexp -d /remote_wpar/opt -B -a 0 -v 3 -t rw -r *.ibm.com
mknfsexp -d /remote_wpar/var -B -a 0 -v 3 -t rw -r *.ibm.com
mknfsexp -d /remote_wpar/home -B -a 0 -v 3 -t rw -r *.ibm.com
mknfsexp -d /remote_wpar/tmp -B -a 0 -v 3 -t rw -r *.ibm.com

 

The previous steps are required to set up various types of system WPARs. To create a DB2 environment, you can use any of the three types. Here are the possible configurations:

  • To install DB2 in the default directory (/opt is default directory), you need either a private or remote system WPAR.
  • To install DB2 in a non-default location, you can use any of the above-mentioned system WPAR types.

 

DB2 installation and setup on a system WPAR:

The following shows how to install and configure DB2 inside of a system WPAR:

  1. Create a system WPAR (private or remote). DB2 needs a bigger /usr, /opt and /home directories. You might need to increase them in case of failure.
  2. Start the system WPAR:
     startwpar remote_wpar

     
  3. Log in to remote_wpar using either clogin or telnet.
  4. Install DB2. This is similar to how you do installation on normal AIX machines (Global).
    1. Copy the DB2 images or mount a directory where DB2 images are available.
                  
                  mount "ImageServer":/DB2Images /mnt on your System WPAR

       
      cd /mnt/"DB2 path"

       
    2. Run db2_install (here we need to select the DB2 install path. You can change the path if you want to go for a non-default location.)
  5. List all DB2 filesets.
    lslpp -l |grep db2 lists 

     
  6. Create a DB2 instance just to reconfirm the installation.
    mkuser test
    mkuser testfc
    /DB2 Installation Dir/instance/db2icrt -a SERVER -s ESE -w 64 -u testfc test
    

     
  7. DB2 is now ready on system WPAR and can be used to run DB2 applications.

This section described set up DB2 on a system WPAR. The following section describes how set up DB2 setup on an application WPAR.

DB2 installation and setup on an application WPAR

As stated earlier, application WPARs use all the file systems from Global only.

  1. Install DB2 on Global. There is no need to create DB2 instance at this stage.
  2. Create the application WPAR using the wparexec command and pass the createdb2instance script as the startup script to wparexec command:
    wparexec -N interface=en0 address="IP" netmask=255.255.255.192 broadcast=9.2.60.255 
    -n "App WPAR name having DNS entry" /"absolutePath"/createdb2instance
    

     

    createdb2instance is a script, which creates the DB2 instance. We need to create the DB2 instance in this manner so that DB2 will take the IP and hostname from the current execution environment, which is nothing but the application WPAR environment.

    #cat  createdb2instance:
    mkuser test
    mkuser testfc
    /"DB2 Installation Dir"//instance/db2icrt -a SERVER -s ese -w 64 -u testfc test

     
  3. After completing the createdb2instance, we can infer:
    • Application WPAR exits.
    • DB2 instance (test in this case) exists on global file systems.
    • DB2 instance (test) internally contains application WPAR IP and DNS names.
  4. At this stage we have DB2 on Global and a DB2 instance with application WPAR references.
  5. Now we can start our application on the application WPAR and its DB2 instance.
    wparexec -N interface=en0 address="IP" netmask=255.255.255.192 broadcast=9.2.60.255 
    -n "App WPAR having DNS entry" /"absolutePath"/somedb2application
     

     

    Here somedb2application is a DB2 application uses the DB2 instance created inside the application WPAR.

Conclusion

This article discussed how to create various types of WPARs and install DB2 inside of a WPAR. The instructions and tips provided here can help users of WPARs with installation and configuration of various products, such as DB2, Oracle, IDS, WebSphere Application Server, and SAP.

Here are the importatnt points to be noted with respect to WPAR and DB2:

  • The WPAR name should have an IP and associated DNS entry.
  • /etc/hosts entry with WPAR IP and DNS name
  • Selection of type of system WPAR to be used for DB2 installation

No comments: