Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

This

...

article

...

applies

...

to

...

Geronimo

...

2.0

...

and

...

later.

...

This

...

article

...

describes

...

running

...

multiple

...

server

...

instances

...

from

...

one

...

installation

...

instance

...

of

...

Geronimo,

...

where

...

the

...

server

...

instances

...

share

...

as

...

much

...

of

...

the

...

base

...

Geronimo

...

artifacts

...

and

...

file

...

system

...

space

...

as

...

possible.

...

These

...

are

...

the

...

geronimo

...

directories,

...

all

...

sub-directories

...

of

...

<geronimo_home>

...

by

...

default:

...

  • bin
  • lib
  • schema
  • var
  • repository
  • deploy (hot deployment)

<geronimo_home> is the directory where you installed Geronimo. bin, lib and schema are read-only, and thus may be shared between instances. The disk space taken up by a typical vanilla freshly installed Geronimo instance is equally split between var and repository at almost 50 MB each, with the rest being noise. Most of var is 40 MB of ActiveMQ journal files.This motivates the idea of a second repository, in particular, one for each server instance.

In addition to a simple read/write partition of capabilities, security may well come into play as we access permissions on a set of directories. Each server instance should be able to read or write only its var directory, for instance.

Configuration Substitution Properties

A feature that helps with running multiple servers, whether or not they are sharing a repository, is the configuration substitution property facility. config.xml can have expressions of the form

...

etc. These expressions are evaluated with jexl using values set from:

  • a properties file, by default var/config/config-substitutions.properties.

...

  • The

...

  • name

...

  • of

...

  • this

...

  • file

...

  • may

...

  • be

...

  • changed

...

  • with

...

  • the

...

  • command

...

  • line

...

  • property:

...


  • -Dorg.apache.geronimo.config.substitutions.file=var/config/some-other-file.properties

...

  • system

...

  • environment

...

  • properties.

...

  • command

...

  • line

...

  • properties.

...


  • These

...

  • override

...

  • each

...

  • other

...

  • in

...

  • the

...

  • order

...

  • above:

...

  • command

...

  • line

...

  • properties

...

  • override

...

  • everything

...

  • else.

...

  • System

...

  • environment

...

  • properties

...

  • and

...

  • command

...

  • line

...

  • properties

...

  • must

...

  • be

...

  • preceded

...

  • by

...

  • a

...

  • prefix,

...

  • by

...

  • default

...

  • "org.apache.geronimo.config.substitution."

...

  • (note

...

  • the

...

  • final

...

  • ".")

...

  • You

...

  • may

...

  • change

...

  • the

...

  • prefix

...

  • with

...

  • the

...

  • command

...

  • line

...

  • property

...


  • -Dorg.apache.geronimo.config.substitution.prefix=myPrefix.

...

Multiple Server Instances

A server instance is easy to create in Geronimo:

  1. Set the org.apache.geronimo.server.name

...

  1. system

...

  1. property

...

  1. to

...

  1. the

...

  1. instance

...

  1. name

...

  1. before

...

  1. you

...

  1. start

...

  1. the

...

  1. server.

...

    • Use

...

    • the

...

    • syntax

...

    • -Dorg.apache.geronimo.server.name=foo

...

    • to

...

    • name

...

    • your

...

    • instance

...

    • foo

...

    • .
    • There are two ways to do this:
      1. Add this to your GERONIMO_OPTS environment variable, or
      2. Pass it on the java command-line invocation of the server.
    • This server's var and deploy directory will then be under <geronimo_home>/foo

...

    • .
    • org.apache.geronimo.server.name

...

    • may

...

    • be

...

    • any

...

    • pathname

...

    • relative

...

    • to

...

    • (descending

...

    • from)

...

    • <geronimo_home>.

...

    • For

...

    • example,

...

    • servers/bar

...

    • would

...

    • put

...

    • the

...

    • server's

...

    • var

...

    • directory

...

    • under

...

    • <geronimo_home>/servers/bar

...

    • .
    • The org.apache.geronimo.server.dir

...

    • system

...

    • property

...

    • may

...

    • also

...

    • be

...

    • used,

...

    • and

...

    • it

...

    • overrides

...

    • org.apache.geronimo.server.name

...

    • .
    • Use org.apache.geronimo.server.dir

...

    • to

...

    • specify

...

    • an

...

    • absolute

...

    • path,

...

    • which

...

    • need

...

    • not

...

    • be

...

    • relative

...

    • to

...

    • <geronimo_home>.

...

    • For

...

    • example,

...

    • /ag20/servers/bar

...

    • would

...

    • put

...

    • the

...

    • server's

...

    • var

...

    • directory

...

    • under

...

    • /ag20/servers/bar

...

    • .

...

    • Otherwise,

...

    • the

...

    • two

...

    • system

...

    • properties

...

    • behave

...

    • the

...

    • same.

...

  1. mkdir foo
  2. Copy var/* to foo/var/

...

  1. Edit foo/var/config/config-substitutions.properties

...

  1. ,

...

  1. uncomment

...

  1. PortOffset

...

  1. and

...

  1. change

...

  1. it

...

  1. to

...

  1. a

...

  1. value

...

  1. like

...

  1. 1,2,10,11,12,20,21,22,...

...

  1. so

...

  1. the

...

  1. ports

...

  1. in

...

  1. the

...

  1. new

...

  1. server

...

  1. instance

...

  1. will

...

  1. not

...

  1. conflict

...

  1. with

...

  1. existing

...

  1. server

...

  1. instances

...

  1. you

...

  1. already

...

  1. have

...

  1. defined

...

  1. and/or

...

  1. started.

...

  1. (Alternatively

...

  1. start

...

  1. the

...

  1. server

...

  1. with

...

  1. the

...

  1. property

...

  1. -Dorg.apache.geronimo.config.substitution.PortOffset=3

...

  1. in

...

  1. the

...

  1. command

...

  1. line)

...

  1. Start

...

  1. the

...

  1. server.

...

To

...

deploy

...

applications

...

to

...

the

...

new

...

server

...

instance,

...

you

...

need

...

to

...

specify

...

the

...

NamingPort+PortOffset

...

used,

...

such

...

as

...

for

...

PortOffset=1:

...

  • deploy

...

  • -port

...

  • 1100

...

  • list-modules

...

Multiple

...

Repositories

...

First,

...

we

...

consider

...

the

...

single

...

server

...

instance

...

case,

...

and

...

just

...

add

...

a

...

second

...

repository.

...

Say

...

we

...

want

...

to

...

leave

...

Geronimo

...

in

...

its

...

repository,

...

but

...

add

...

a

...

second

...

repository

...

to

...

deploy

...

our

...

applications.

...

Adding

...

a

...

second

...

repository

...

is

...

pretty

...

easy.

...

  1. Create

...

  1. a

...

  1. plan

...

  1. (say

...

  1. repo2.xml)

...

  1. for

...

  1. your

...

  1. repository

...

  1. module.

...

  1. xml

...

  1. solid

...

  1. repo2.xml

...

  1. <?xml

...

  1. version="1.0"

...

  1. encoding="UTF-8"?>

...

  1. <module

...

  1. xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">

...

  1. <environment>

...

  1. <moduleId>

...

  1. <groupId>org.example.configs</groupId>

...

  1. <artifactId>myrepo</artifactId>

...

  1. <version>2.0

...

  1. .1</version>

...

  1. <type>car</type>

...

  1. </moduleId>

...

  1. <dependencies>

...

  1. <dependency>

...

  1. <groupId>org.apache.geronimo.configs</groupId>

...

  1. <artifactId>j2ee-system</artifactId>

...

  1. <version>2.0

...

  1. .1</version>

...

  1. <type>car</type>

...

  1. </dependency>

...

  1. </dependencies>

...

  1. <hidden-classes/>

...

  1. <non-overridable-classes/>

...

  1. </environment>

...

  1. <!--Repository-->

...

  1. <gbean

...

  1. name="Repo2"

...

  1. class="org.apache.geronimo.system.repository.Maven2Repository">

...

  1. <attribute

...

  1. name="root">repo2s/</attribute>

...

  1. <attribute

...

  1. name="resolveToServer">true</attribute>

...

  1. <reference

...

  1. name="ServerInfo">

...

  1. <name>ServerInfo</name>

...

  1. </reference>

...

  1. </gbean>

...

  1. <!--Configuration

...

  1. Store

...

  1. service-->

...

  1. <gbean

...

  1. name="Local2"

...

  1. class="org.apache.geronimo.system.configuration.RepositoryConfigurationStore">

...

  1. <reference

...

  1. name="Repository">

...

  1. <name>Repo2</name>

...

  1. </reference>

...

  1. </gbean>

...

  1. </module>

...

  1. Create the repository's

...

  1. root

...

  1. directory

...

  1. via

...

  1. mkdir

...

  1. <geronimo_home>/repo2s

...

    • The directory is specified by the root attribute of the Maven2Repository GBean, repo2s/ in the above example. It is a path relative to the base directory <geronimo_home>.
    • The resolveToServer attribute specifies the repository's location.
      • true means this path is relative to baseServer, which is useful with multiple server instances.
      • false means this path is relative to the base directory <geronimo_home>.
  1. Deploy the repository module by deploying repo2.xml via deploy deploy repo2.xml.

    The deploy command is the script <geronimo_home>/bin/deploy.

...

  1. {bat,sh

...

  1. },

...

  1. depending

...

  1. on

...

  1. your

...

  1. operating

...

  1. system.

...

  1. It

...

  1. is

...

  1. invoked

...

  1. by

...

  1. typing

...

  1. simply

...

  1. deploy

...

  1. either

...

  1. from

...

  1. the

...

  1. <geronimo_home>/bin

...

  1. directory,

...

  1. or

...

  1. by

...

  1. having

...

  1. that

...

  1. directory

...

  1. in

...

  1. your

...

  1. path.

...

Using the new repository

Using the new repository is a little tricky, and is only supported from the command line currently. The essence is to use the --targets option of the deploy command to target your module to deploy in your new repository. First, use the deployer list-targets command to see the repositories. The target names are long and cumbersome:

deploy list-targets

Available Targets:
org.example.configs/myrepo/2.0-SNAPSHOT/car?ServiceModule=org.example.configs/myrepo/2.0-SNAPSHOT/car,j2eeType=ConfigurationStore,name=Local2

...


org.apache.geronimo.configs/j2ee-system/2.0-SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/j2ee-system/2.0-SNAPSHOT/car,j2eeType=ConfigurationStore,name=Local

...

...

The use of environment variables is recommended for command-line

...

use.

...

For

...

example,

...

set

...

REPO2=

...

org.example.configs/myrepo/2.0-SNAPSHOT/car?ServiceModule=org.example.configs/myrepo/2.0-SNAPSHOT/car,j2eeType=ConfigurationStore,name=Local2

...

.

To deploy to the new repository, use: deploy deploy --targets %REPO2% sample.war

deploy list-modules also gives those long target names for each repo, followed by the usual short names of each module deployed in the repo.
deploy list-modules %REPO2% gives the accustomed short output for the target repo.

The syntax to undeploy from a repo is: deploy undeploy "%REPO2%|geronimo/jsp-examples/1.1.1/war"

...

.

...

Note the | character separates the repository name from the module name. The " quotes are used around the entire parameter to escape this special character from command shell interpretation.

...

If no --targets are given on the deploy command, the module is deployed to all repositories. This certainly seems undesirable. If you only want to put the module in one repository, be sure to use the --targets option!

...

Multiple Server Instances, each with its own repository(ies)

In the case of multiple server instances, a separate path may be given for the Maven2Repository root attribute for each server. This might be done with config.xml overrides for each server instance. A better solution is to add a resolveToServer attribute to this GBean, so that the root attribute may be set to repository, and it will thus be unique for each server instance with no changes required for each instance. Each server instance would then have a repository located at <geronimo_home>/<instance_name>/repository

...

.

...

What's

...

lacking

...

is

...

console

...

support

...

for

...

multiple

...

repositories,

...

and

...

support

...

for

...

hot

...

deployment

...

and

...

plugins.

...

...

An interesting wrinkle here is in what repository is the new repository deployed? It's clear that the second repository (say repo2.xml above) will be deployed in the first repository. Thus, making this first repository read-only will not work for dynamically adding repositories. Perhaps a second repository is added to contain these server-unique repositories. The second repository must be shared and read-write, so it does not fit nicely in the use case. (sad)