Farming

By creating a new server instance by using the multiple instances feature provided by Geronimo, the new instance will have available all of the applications and configurations deployed on the default instance available and with the same runtime state. Any new application or configuration or plugin deployed in one instance will not automatically be added to the other instances. If the newly-deployed configuration adds any content to config.xml, config-substitutions.properties, and so on, then the content will not be added to the corresponding files in the other instances. If you are using multiple installations of Geronimo without the Farming feature, then you will need to deploy your clustered application on each server installation. Starting and stopping the application also needs to be done for each server installation. The Farming feature provided by Geronimo enables you to deploy an application to a cluster of Geronimo servers with a single deployment step. Once deployed to a cluster, this application can then be transparently started, stopped, or undeployed across all of the cluster members. In this section, we will look at the configuration needed on the cluster members in order to enable farming and deployment of applications in the cluster.

Cluster member configuration

Each cluster member should be given a unique name. Also, the remote deployer URL for each cluster member needs to be configured correctly. In order to do so, update the clusterNodeName and RemoteDeployHostname properties in the var/config/config-substitutions.properties file under each server instance.

In the default server instance, for each additional cluster member, local or remote, add a BasicNodeInfo GBean to the farming configuration org.apache.geronimo.configs/farming/2.1.4/car in config.xml, in order to configure the connection to the cluster member using JMX. The GBean XML definition is given below:

<gbean name="org.apache.geronimo.configs/farming/2.1.4/car?ServiceModule=org.apache.geronimo.configs/farming/2.1.4/car,j2eeType=NodeInfo,name=NodeInfo2"
gbeanInfo="org.apache.geronimo.farm.config.BasicNodeInfo">
<attribute name="name">NODE2</attribute>
<attribute propertyEditor="org.apache.geronimo.farm.config.BasicExtendedJMXConnectorInfoEditor" name="extendedJMXConnectorInfo">
<ns:javabean class="org.apache.geronimo.farm.config. BasicExtendedJMXConnectorInfo"
xmlns:ns="http://geronimo.apache.org/xml/ns/deployment/ javabean-1.0">
<ns:property name="username">system</ns:property>
<ns:property name="password">manager</ns:property>
<ns:property name="protocol">rmi</ns:property>
<ns:property name="host">node2hostName</ns:property>
<ns:property name="port">1109</ns:property>
<ns:property name="urlPath">JMXConnector</ns:property>
<ns:property name="local">false</ns:property>
</ns:javabean>
</attribute>
</gbean>

Make sure that the properties under extendedJMXConnectorInfo reflect the correct values required to connect to the Geronimo server instances.

Farm deployment

To use farm deployment, the farming configuration org.apache.geronimo.configs/farming/2.1.4/car must be running on all of the cluster members. This configuration contains MasterConfigurationStore and ClusterStore GBeans. If the configuration is not started already, then you can start it by using the System Modules portlet. To deploy your application to the cluster, use the following command:

<GERONIMO_HOME>indeploy.bat distribute --targets "org.apache.geronimo.configs/farming/2.1.4/car?ServiceModule=org.apache.geronimo.configs/farming/2.1.4/car,j2eeType=ConfigurationStore,name=MasterConfigurationStore" <module file> <plan file>

This will deploy the following:

  • A configuration with the configuration ID as it would be derived from regular deployment of the module and/or plan to the MasterConfigurationStore on the default server. This configuration contains GBeans to start, stop, and undeploy the application or configuration across the cluster members.

  • A configuration with a configuration ID that is derived by adding _G_SLAVE to the artifactId of the configuration ID from above to the MasterConfigurationStore in the default server and to the ClusterStore in each of the cluster members.

To start the application across all cluster members, use the following command:

<GERONIMO_HOME>indeploy.bat start <configuration id>

To stop the application across all cluster members, use the following command:

<GERONIMO_HOME>indeploy.bat stop <configuration id>

To undeploy the application across all cluster members, use the following command:

<GERONIMO_HOME>indeploy.bat undeploy <configuration id>

Here, the configuration ID is the ID derived in the first step above.

Running a sample application with Farm deployment

For this sample, we will use the helloworld-cluster sample with the farming-geronimo-web.xml deployment plan. We will use two separate installations of Geronimo server. Follow the steps below to run the sample application:

  1. Extract the Geronimo Tomcat 2.1.4 distribution to a directory of your choice. We will refer to this directory as <GERONIMO1_HOME>.

  2. To create a second installation of Geronimo, extract the Geronimo Tomcat 2.1.4 distribution to a different directory of your choice. We will refer to this directory as <GERONIMO2_HOME>.

  3. Update the <GERONIMO2_HOME>/var/config/config-substitutions.properties to change the PortOffset to 10, and the clusterNodeName to NODE2.

  4. Add the BasicNodeInfo GBean definition given above to <GERONIMO1_HOME>/var/config/config.xml under apache.geronimo.configs/farming/2.1.4/car. Make sure that the host property value is localhost.

  5. Start the servers for both of installations.

  6. Start apache.geronimo.configs/farming/2.1.4/car configuration in both of the instances through the System Modules portlet in the respective Administration Consoles at http://localhost:8080/console and http://localhost:8090/console.

  7. Deploy the helloworld-cluster application with the farming-geronimo-web.xml plan, by file using the command below:

    <GERONIMO1_HOME>indeploy distribute -targets "org.apache.geronimo.configs/farming/2.1.4/car?ServiceModule=org.apache.geronimo.configs/farming/2.1.4/car,j2eeType=ConfigurationStore,name=MasterConfigurationStore" helloworld-cluster-1.0.war farming-geronimo-web.xml
    

    Note that this command will deploy a virtual configuration packt-samples/helloworld-farming/1.0/war to the MasterConfigurationStore in the server at <GERONIMO1_HOME>. This configuration contains GBeans to stop, start, and undeploy together the actual application deployed to the ClusterStore with configuration ID packt-samples/helloworld-farming_G_SLAVE/1.0/war in the servers at <GERONIMO1_HOME> and <GERONIMO2_HOME>.

  8. Start the application deployed in all of the instances at once by using the following command:

    <GERONIMO1_HOME>indeploy start "packt-samples/helloworld-farming/1.0/war"
    

    Now the application is available at URLs http://localhost:8080/helloworld-farming/ on the first server and http://localhost:8090/helloworld-farming/ on the second server.

  9. Add the following line to httpd.conf, and restart the Apache web server:

JkMount /helloworld-farming/* loadbalancer

The sample application is now available through the Apache web server at the URL http://localhost/helloworld-farming/. Access the application, enter a name, and click on getGreeting. The next page will display a greeting message along with the details of the request received in the Geronimo server. The org.apache.geronimo.server.home value indicates the server instance serving the request. Refresh or reload the page a few times, and notice that the application is load balanced along with session replication between the two server instances.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset