The IBM PureApplication System supports two types of virtual patterns: Virtual application patterns and virtual system patterns.
- The virtual application pattern (VAP) is a workload-level virtualization pattern which includes everything up to application platform expertise.
- The virtual system pattern (VSP) is the topology-level virtualization pattern which includes only up to middleware expertise.
This article describes some best practices for each of the pattern development types, practices that we came across when implementing these patterns for real-world purposes.
The virtual application pattern practices described in this article include:
- Changing the Class Loader mode and policy. This enables pattern developers to easily build VAPs for applications that need their Class Loader mode and policy changed. (Class Loader policies control the isolation of an application.)
- Performing put/get operations with an FTP server. This enables pattern developers to build VAPs for applications that need to access to external FTP servers. This tip can be applied to other servers such as external HTTP servers, RSS servers, and so on.
- Troubleshooting why you cannot deploy a DB/DBaaS VAP when you get an OLTP error. This lets pattern developers understand (and avoid) the missing OLTP error.
Change Class Loader mode and policy
In IBM WebSphere® Application Server (WAS), you can change the order to load the classes by changing the Class Loader.
Figure 1. Class Loader in WAS console
For example, if you want to load your class first, set the Class Loader mode as PARENT_LAST. Normally in WebSphere Application Server, the Class Loader mode is set via the WebSphere Application Server admin console after installing the EAR.
In a VAP, however, you are not allowed to change any configurations in the deployed VM. Instead, JVM policy in the Virtual Application Builder supports the Class-Loader-related configurations.
To configure JVM policy:
- In Virtual Application Builder, add JVM policy on Enterprise Application.
- Select PARENT_FIRST or PARENT_LAST for Class Loader Order and select MULTIPLE or SINGLE for WAR Class Loader Policy.
Figure 2. Changing Class Loader by changing JVM policy
Perform put/get operations with an FTP server
If you want your virtual application pattern application to connect to an FTP server and put/get files, you need to define general targets in the Virtual Application Builder:
- In Virtual Application Builder, define Generic Targets for port 20 and 21 and link them from the Enterprise Application component.
- Enter FTP server name, IP address, and port number for each Generic Target.
Figure 3. To perform put/get on an FTP server
Note: To fix the ports to connect to FTP server, you should use active mode instead of passive mode in your application.
Can't deploy a DB VAP due to OLTP error?
You might encounter a problem in which you cannot deploy a VAP of a web app that might include a database or DBaaS pattern. Instead, you get an OLTP system plug-in error that can look like this:
! Contact an administrator to configure the "oltp" system plug-in. ! Contact an administrator to configure the "oltp" system plug-in for "IBM Transactional Database Pattern" environment based on your choice for the "Purpose". |
This can occur because the system plug-in is not configured properly. To correct the error:
- In the Workload Console, select Cloud > System Plug-ins > IBM Transactional Database Pattern > oltp and click Configure.
- Select Both for Environment and click OK.
Figure 4. Configuring the OLTP plug-in properly
Now we'll look at some VSP practices.
The virtual system pattern practices described in this article include:
- Creating wsadmin scripts for efficient VSP deployment: Make a datasource creation script and create an EAR installation script. A wsadmin script is difficult to create from scratch without any assistance or instruction. With this tip, pattern developers can easily create the wsadmin scripts to be used for a VSP.
- Importing and exporting a VSP. This will show pattern developers how to use the command line interface, a very good way to restore the script packages and add-ons manually and copy the migrating pattern. It also introduces the concept of the DBCS (double-byte character set) environment which could trip up a pattern developer.
- Changing the VM time zone setting for a VSP. In case you don't want the default UTC.
- Expanding the size of DB2 file system for a VSP. For when you need a larger file system.
- Transferring tables or data from an existing DB to a VSP. In case the DB is set by manual input or a dedicated tool and you need the data in another DB.
- Using DB2 drivers that have been tested with your application. Obviously a driver that already works with your application would be the best one to include in the VSP package.
Deploy VSPs with wsadmin scripts
When deploying a virtual system pattern, use a Jython script file (*.jy) with wsadmin. You can easily create a Jython script by using a command assistance function from the WebSphere Application Server admin console.
Creating a datasource creation script
To build a datasource script:
- When a virtual machine creates an instance, the following links are auto-generated: VNC and WebSphere. (Open the section Virtual machines in the virtual system instance.)
- Click the WebSphere link. Login with UID: virtuser and a password you set.
- This example is used when configuring a datasource. After invoking the Integrated Solutions Console, select Resources > JDBC > Data sources from the left menu.
- Click the New button in the Preferences section and follow Step 1 to Step 5.
- After clicking Finish, in the right pane click Command Assistance > View administrative scripting command for last action.
Figure 5. Command Assistance
- Copy the script in screen: Administrative Scripting Commands (such as
AdminTask,AdminConfig).
Figure 6. Copy the script in the screen
- Update the description in a file like the createDatasource.jy Jython file of the createDatasource.zip by referencing to the scripts copied in Step 6.
Creating an EAR installation script
You just learned how to build a script creating a datasource. Now let's create a script to install an Enterprise Archive file.
- When a virtual machine creates an instance, the following links are auto-generated: VNC and WebSphere. (Open the section Virtual machines in the virtual system instance.)
- Click the WebSphere link. Login with UID: virtuser and the password you set.
- After invoking the Integrated Solutions Console, select Applications > New Application > New Enterprise Application from the left menu.
- Enter the path to the new application (where you put the EAR file).
- Select Fast Path or Detailed. If you select Fast Path, follow Step 1 to Step 3.
- After clicking Finish, in the right pane click Command Assistance > View administrative scripting command for last action.
- Copy the script in screen: Administrative Scripting Commands (such as
AdminTask,AdminConfig). - Update the description in a file like installApp.jy that can be found in the installApp.zip by referencing to the scripts copied in Step 6.
In a VAP, you can export and import the modules with just one click. In a VSP, however, you need to restore the script packages and add-ons manually and copy the migrating pattern by a deployer command to a new environment.
To prepare:
-
Download a command line tool from IBM PureApplication System welcome screen and unzip it to <WORKING_DIRECTORY> (approx. 8MB).
Figure 7. Download the command line tool
- If you use a
deployercommand tool in a DBCS environment, then move to <WORKING_DIRECTORY>\deployer.cli\lib\3.1.0.0-20111118232331. The directory name is different depending on the version. Edit the registry file; uncomment the two rows (Figure 8) and edit the codeset.
Figure 8. In a DBCS environment
A DBCS (double-byte character set) environment is one in which the character set is comprised of all characters (including control characters) encoded in two bytes OR merely every graphic character not representable by an accompanying S(ingle)BCS is encoded in two bytes. A DBCS supports national languages that contain a large number of unique characters or symbols, for example Japanese, Korean, and Chinese.
To export:
- Download and save the script packages (if any, add-ons as well) for the subject pattern.
- Move to <WORKING_DIRECTORY>\deployer.cli\bin and run a
deployercommand. A sample command can be something like this:deployer -h host_IP_address -u user_name -p password -f ..\samples\patternToPython.py -f xxx_vsp.py
.
Figure 9. Save script packages and add-ons
Select the subject source pattern you want to copy from the previous screen and export the Python script (xxx_vsp.py) (any file name you like that ends with .py) to use later for a target virtual system pattern.
To import:
- Now that you downloaded the source script packages (as well as add-ons), create a script package (and add-ons) with the exact same name as the original one and upload the downloaded ZIP files. Make sure the parameters are set correctly by clicking the Refresh button.
- Import the VSP file (xxx_vsp.py) you exported in the previous steps to a new
environment using the
deployercommand. Use a command similar to this:deployer -h host_IP_address -u user_name -p password -f xxx_vsp.py
Be aware: If the same pattern name exists, remove it before executing thedeployercommand. - Deploy the VSP you just imported in to the cloud. After the deployment, confirm that it runs okay as an instance.
Change the VM time zone setting for the VSP
The time zone of a deployed VM is set as UTC by default. If you want to change it, you need to describe it in the script. (In a VAP, you are not allowed to change from UTC).
On the DB2 side, if you want to change the time zone to JST (Japan Standard Time), describe the following in the DB creation script.
Figure 10. Changing the time zone on the DB2 side
To change the time zone on the WebSphere Application Server side, then put in the first script executed in the WebSphere Application Server VM the following:
Figure 11. Changing the time zone on the WebSphere Application Server side
Expand the size of DB2 file system for VSPs
If a large-volume data migration is necessary in a VSP DB2 environment (nominally more than 20GB), you'll discover that a default size file system is not sufficient. You can add a disk by using an add-on function and increase the file system size.
- In the Workload Console, choose Catalog > Add-Ons.
- Select Default add disk in the left pane and confirm the Environment: parameters in the right pane.
- In the VSP DB2 topology, place the Default add disk from the add-on menu and change the default value of Environment: DISK_SIZE_GB = 10 to a disk size you need. Also, enter the file system type and mount point (voluntary).
- Create an additional script package
by referring to the sample descriptions in Figure 12 ("test_adddisk" in Figure 13). Then place it before executing the database script package ("Create DB2
database test" in Figure 13).
Figure 12. Unmounting the file system
Figure 13. Create DB2 database
After you deploy, you can use /db2fs file system with its disk size increased in the DB2 VSP.
Transfer tables/data from existing DB in a VSP
If it is difficult to create a script for DB creation and data loading because the DB is set by manual input or a dedicated tool. You might need to create a script to transfer the data from the existing DB.
To use db2 backup:
- Backup from the existing DB with:
db2 backup db DB_name to backup_file_name compress
- Create a script to restore data from the backup file and package it with the backup file:
db2 restore db DB_name from backup_file_name
Note: In this method, the script package tends to become large since the backup file is packaged in it. In addition, this method depends on the platform involved, so for example, there is no compatibility between different endians such as IA Linux (little endian) and AIX (big endian). To avoid these issues, use the db2move method.
With the db2move method:
- Acquire the DDL file from the existing DB:
db2look -d DB_name -a -e -l -x -f -td % -o DDL_file_name
- Acquire the data from the existing DB:
db2move DB_name export -sn schema_name
- If tables, including generated columns exist, export them:
db2 export to table_name.ixf of ixf messages table_name.msg select * from table_name
- Create a script like in Figure 14.
Figure 14. Using db2move
- Create a script package by packaging the files acquired from Steps 1 through 3 and the script.
Use DB2 drivers that have been tested with your application
You might want to use the DB2 drivers that have been tested with your application rather than the DB2 drivers provided by PureApplication System. In VSPs, you can replace them by packaging the DB2 drivers that you want to use.
- Include the tested DB2 drivers (db2jars.zip) to the script package for DB2 driver installation.
- Describe the following process in the script for DB2 driver installation:
# Copy db2jar.zip and extract the driver files at /opt/db2 directory chmod 777 /tmp/script_package_name/db2jars.zip mkdir /opt/db2 chown virtuser:users /opt/db2 cp /tmp/xxxx_installDB2Drivers/db2jars.zip /opt/db2 sudo -u virtuser unzip -d /opt/db2 /tmp/xxxx_installDB2Drivers/db2jars.zip # Add the DB2 driver path to the environment variable echo "export DB2UNIVERSAL_JDBC_DRIVER_PATH=/opt/db2" >> /etc/virtualimage.properties source /etc/virtualimage.properties
- Create a JDBC provider by setting the extracted DB2 driver JARs as the classpath in the wsadmin script for data source creation.
- Sample code for non-XA datasource creation:
AdminTask.createJDBCProvider('[-scope Cell=' + cellName + ' -databaseType DB2 -providerType "DB2 Universal JDBC Driver Provider" -implementationType "Connection pool data source" -name "DB2 Universal JDBC Driver Provider" -description "One-phase commit DB2 JCC provider" -classpath [/opt/db2/db2jcc.jar /opt/db2/db2jcc_license_cu.jar]]') - Sample code for XA datasource creation:
AdminTask.createJDBCProvider('[-scope Cell=' + cellName + ' -databaseType DB2 -providerType "DB2 Universal JDBC Driver Provider" -implementationType "XA data source" -name "DB2 Universal JDBC Driver Provider (XA)" -description "DB2 Universal JDBC Driver Provider (XA)" -classpath [/opt/db2/db2jcc.jar /opt/db2/db2jcc_license_cu.jar]]')
- Sample code for non-XA datasource creation:
We hope that these best practices that we came across when implementing virtual cloud-oriented patterns for real-world purposes will be a good start to help you configure and deploy patterns into cloud environments.
Learn
-
For more on using virtual patterns, visit PureSystems on developerWorks.
-
In the developerWorks cloud developer resources, discover and share knowledge and experience of application and services developers building their projects for cloud deployment.
- Find out how to access IBM SmartCloud Enterprise; developing on SmartCloud is a great way to practice developing for IBM PureSystems.
Get products and technologies
-
See the product images available for IBM SmartCloud Enterprise.
Discuss
-
Join a cloud computing group on developerWorks.
-
Read all the great cloud blogs on developerWorks.
-
Join the developerWorks community, a professional network and unified set of community tools for connecting, sharing, and collaborating.
Yuki Miyata is a technology executive with ISV and Developer Relations Japan, specializing in solutions and platforms with WebSphere products and PureApplication System. He has more than 12 years experience in WebSphere technical support, including WebSphere beta projects and cloud-related projects. Since last year, he has been working on enabling ISV solutions on IBM PureApplication System.
Kohsuke Sakamoto is an information technology specialist with ISV and Developer Relations in IBM Japan. His work includes technical support for ISVs in healthcare industry, which covers many platforms and products from databases, application servers to virtualization. His latest focus is on enabling ISVs application on IBM PureApplication System.




