I'm writing a series of blog posts on How to Create and Configure WebSphere Liberty Cluster End-to-End. This particular post focuses on application deployment. Below listed are all the posts in this series:
- How to Create and Configure WebSphere Liberty Cluster End-to-End
- How to Deploy Application in WebSphere Liberty Cluster
- How to Setup Front-End Web Server for WebSphere Liberty Cluster
Diagram 1.0 Example Topology: WLP Collective with Front-End & Deployment Server |
Note: in order to complete all the steps in this blog post, first you need to complete required steps outlined in How to Create and Configure WebSphere Liberty Cluster End-to-End
Deploying an application in WLP server or cluster
There are few ways to deploy an application into WLP server or cluster. Application can be simply dropped into a pre-defined dropins (${server.config.dir}/dropins
) directory, or by adding an application definition entry to the server configuration.In this blog post, we will explore script driven, remote application deployment for distributed platforms (multiple WLP servers or cluster managed by WLP Collective Controller) by utilizing secure JMX REST connection. Refer to Configuring secure JMX connection to Liberty for more details.
We'll be using
manageAppOnCluster.py
script and libraries available in IBM developerWorks to manage application(s) on WLP cluster.Download manageAppOnCluster.zip
You can download it from https://developer.ibm.com/wasdev/downloads/#asset/scripts-jython-Install_or_uninstall_an_application_to_cluster. Here I have downloaded and extracted manageAppOnCluster.zip in Deployment/Tool server (machine: 01 in example topology) under/opt/workspace/wlpDeployment
directory.Download and Install Jython.
You can download Jython from http://www.jython.org/downloads.htmlGeneral installation instruction can be found at https://wiki.python.org/jython/InstallationInstructions
Console based installation is very straight forward. See below, I'm installing standalone Jython under
/opt/jython
directory on Machine: 01
# Create /opt/jython directory
|
You'll also need
restConnector.jar
and restConnector.py
in order to be able to make remote JMX REST connection. If you have WLP installed on the machine, you should be good as these files are installed as part of WLP installation. If you don't have WLP installed on the machine, or you don't want to install WLP, you can just copy these files from another machine where it is installed. Easiest way is to tar the content of entire ${wlp.install.dir}/clients
directory and copy it to Deployment/Tool server where you can untar it.
Here, I'm going to create a
wlpclient.tar
file on Machine: 02, as WLP is installed there and copy to Machine: 01.$> cd /opt/ibm/wlp
$> tar -cvf /tmp/wlpclient.tar clients/
|
Copy the
wlpclient.tar
to Deployment/Tool server and extract it.# Create directory /opt/ibm/wlp in Machine 02 (if it doesn't exist)
|
In order to create secure connection, you'll also need signer certificate from the Collective Controller. Just copy
trust.jks
file (located under ${server.config.dir}/resources/security/
directory) from Collective Controller server and put into Deployment/tool server.Now, for convenient, create a script file (name it wlpMgmt.sh), which look something like this:
wlpMgmt.sh
#! /bin/bash # wlpMgmt.sh
export JYTHONPATH=/opt/ibm/wlp/clients/jython/restConnector.py
|
Prepare your application
For this exercise, I'm using a sampleJavaHelloWorldApp.war
application downloaded from https://github.com/IBM-Bluemix/java-helloworld/tree/master/targetI've put the application under
/opt/workspace/wlpDeployment/apps
directory in Machine:1.Deploy the Application
Here, we are going to usewlpMgmt.sh
(created above) to setup environment and call Jython and execute manageAppOnCluster.py
to create secure connection to Liberty Controller and deploy application remotely.
|
Verify application deployed successfully
- Verify application binary is copied to each member server (in this case Machine: 03 -
wlpSrv01
, and Machine: 04 -wlpSrv02
). By default, it is copied to${server.config.dir}/apps
directory of each cluster member server. Check and make sure it is copied. - Verify that
server.xml
of each member server is updated. In my case, it has added the following line in the member server'sserver.xml
:
<application name="JavaHelloWorldApp" location="${server.config.dir}/apps/JavaHelloWorldApp.war"/>
-
Access application and make sure it is available. In our case, it is accessible as:
- Machine: 03 URL: http://waslibmem01:9081/JavaHelloWorldApp/
- Machine: 04 URL: http://waslibmem02:9081/JavaHelloWorldApp/
Note: If for any reason you need to undeploy/uninstall the application, here is how to do it:
$> ./appMgmt.sh manageAppOnCluster.py \ |
uninstall removes the application binary as well as <application> definition from server.xml.
Next: proceed to Setup Front-End Web Server for WebSphere Liberty Cluster -->
Looks like you're really interested in WebSphere Liberty Profile, see my other related blog posts below:
- How to Create and Configure WebSphere Liberty Cluster End-to-End
- How to Deploy Application in WebSphere Liberty Cluster (this post)
- How to Setup Front-End Web Server for WebSphere Liberty Cluster
- Using Docker Secrets with IBM WebSphere Liberty Profile Application Server
- How to use WLP passwordUtilities feature for encryption/decryption