Running multiple server instances from a single installation

Geronimo provides an easy way of creating and running multiple server instances from a single Geronimo installation. All you need to do is copy a few directories and set a few system properties, and you will have a new server instance with all of the configurations in the default instance. We will now create another instance of the Geronimo server in which we have deployed the helloworld-cluster sample application. This new instance will run in a different JVM on a different set of server ports. The two server instances replicate sessions between them such that the instance that is serving the request during a session is transparent to the user. To create a new server instance, follow the steps below:

  1. Choose a name for your new server instance (for example, inst2) and create a directory with that name under the <GERONIMO_HOME> directory. We will refer to the instance name as <INSTANCE_NAME>.

  2. Make sure that the server is not running, and copy the contents of the <GERONIMO_HOME>/var directory, along with all of its subdirectories, to the <GERONIMO_HOME>/<INSTANCE_NAME>/var directory. We will refer to the <GERONIMO_HOME>/<INSTANCE_NAME> directory as <INSTANCE_HOME>. In our example, copy to the <GERONIMO_HOME>/inst2/var directory, and the <INSTANCE_HOME> will be <GERONIMO_HOME>/inst2.

  3. Open the <INSTANCE_HOME>/var/config/config-substitutions.properties file, and change the following properties:

    • PortOffset: Change PortOffset from 0 to any integer, such that none of the server ports are in conflict. In our example, we use 10 for the PortOffset.

    • clusterNodeName: Use this property to set a name for the cluster node.

You can now start the new server instance by setting the system property org.apache.geronimo.server.name to the name of the server instance. You can use the JAVA_OPTS environment variable to set the system property. To start the server instance inst2, use the following commands, in a Windows environment:

set JAVA_OPTS=-Dorg.apache.geronimo.server.name=inst2
<GERONIMO_HOME>/bin/geronimo run

This will start the server instance inst2. The following image shows the output in the command window at server startup:

Notice that all of the server ports are offset by the PortOffset value of 10. The Administration Console for this server instance is available at the URL http://localhost:8090/console. With the exception of the var directory, this server instance will share the lib, repository, and other directories with the default server instance. The configurations and clustered web applications deployed in the default server will all be available on this new server instance too. At this stage, the helloworld-cluster application is available in the server instance inst2 at the URL http://localhost:8090/helloworld-cluster/. Access the application at http://localhost:8090/helloworld-cluster/ in the same browser window from which you accessed http://localhost/helloworld-cluster/. Enter a name in the form displayed, and then click on getGreeting. Notice that the counter value displayed on the next page is one more than the previous value, and the new session value is false. Even though the request is served by the application running on the new server instance inst2, as indicated by the server.name value, a new session is not created because the session state has been replicated from the default instance to inst2. However, the Apache web server is configured to forward requests only to default instances.

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

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