Sei sulla pagina 1di 30

Tutorial sulla configurazione di un

cluster in modalit domain con


JBOSS EAP 6.2
In questo documento verr spiegata una modalit tipica per eseguire il setup di un cluster in
modalit Domain.

===========================
CHAPTER 1: Architettura Generale

===========================

1.1.

Setup di JBoss e scopo del documento

In questo capitolo lavoreremo con 4 servers distribuiti per creare due cluster orizzantali, per I
quali gli indirizzi IP e I nomi canonici sono i seguenti:

192.168.0.1

webserver

ws (Apache 2.2.x)

192.168.10.0

domain controller

dc (JBoss 7 / EAP6)

192.168.20.0
EAP6)

applicationserver

slave1 of dc (JBoss 7 /

192.168.30.0
EAP6)

applicationserver

slave2 of dc (JBoss 7 /

Naturalmente la stessa configurazione pu essere riutilizzata, invece che per un cluster verticale,
per un cluster orizzontale, ovvero dove tutte le varie istanza del dc, slaves e ws girano su
ununica macchina con risorse adeguate

1.2.

JBoss Clusters, Istanze e applicazioni:

Nel tutorial configureremo due virtual hosts apache


(www.application1.nl and www.application2.nl).
Ogni virtual host dovr connettersi via mod_cluster ad un cluster jboss designato. I Clusters
saranno:

cluster1 costituito da {node11@as1 and node12@as2)


cluster2 costituito da {node21@as1 and node22@as2}

lapplication1.war verr deployata sul cluster1 e raggiungibile allURL


http://www.application1.nl/application1
lapplication2.war verr deployata sul cluster2 e raggiungibile allURL
http://www.application2.nl/application2

Abbiamo quindi due Apache Virtual hosts che bilanciano le richieste verso due diversi clusters
JBoss, ognuno dei quali consiste da two instances. Ogni istanza che partecipa ad un cluster gira
su una machina fisica diversa dallaltra, ma condivide la stessa macchina con unaltra istanza che
partecipa al secondo cluster.

A livello DNS, entrambi gli URLs www.application1.nl e www.application2.nl sono risolti dal
webserver Apache (bilanciatore), usando mod_cluster in combinazione con ajp (Apache JServ
Protocol) per reindirizzare le chiamate al cluster e sticky session per il bilanciamento corretto in
modalit statefull.

Questo tutorial descrive la configurazione del domain controller e degli


application servers che partecipano ai clusters (slaves), e non si concentra
molto sullaspetto del mod_cluster. Quando si ha un clustername al quale
reindirizzare le chiamate applicative tutto molto pi trasparente (ulteriori
dettagli verranno approfonditi nel CHAPTER 8). Lobiettivo descrivere la
separazione dei clusters completamente dal punto d vista delle relazioni
Domain Controller/Slaves. Questo significa che, ad eccezione della creazione di
un nuovo profilo, che va fatta a mano, la maggior parte del lavoro verr
eseguita sul DC attraverso la console di JBoss client (jboss-cli).

1.3.

Contenuti

CHAPTER 2: il Domain Controller

CHAPTER 3: Installare gli Slaves

CHAPTER 4: Creare un nuovo Profilo

CHAPTER 5: Configurare l'Architettura di un cluster funzionante

CHAPTER 6: Deployare e testare le applicazioni

CHAPTER 7: Di cosa non abbiamo parlato

CHAPTER 8: Bilanciamento (mod-cluster e sticky-session)

CHAPTER 9: Configurazione attraverso ununico script da console jboss-cli

=================================
CHAPTER 2: il Domain Controller
=================================

2.1.

Breve parentesi sullinstallazione di JBOSS

Dopo aver scaricato JBoss EAP 6.2 e la Oracle JDK (jdk1.6.0_30.tar.gz) esegui quanto segue:

root@dc # cd /opt
root@dc # cp /tmp/jdk1.6.0_30.tar.gz /tmp/jboss-eap-6.2.zip .
root@dc # tar xfz jdk1.6.0_30.tar.gz ; unzip jboss-eap-6.2.zip
root@dc # ln -s jdk1.6.0_30.tar.gz jdk ; ln -s jboss-eap-6.2 jboss
root@dc # chown -R jboss:jboss jboss-eap-6.2

2.2.

Installare il domain-controller

Il modo pi semplice di avviare il domain controller semplicemente lanciare


/opt/jboss/bin/domain.sh -b <bind-address> dopo aver impostato la variabile
dambiente JAVA_HOME. Nota che questo anche il modo peggiore perch cos parte in
foreground. Ci sono una variet di modi per far partire il DC in background e visualizzarne il log
su una console ad-hoc nvece che sulla shell (prompt), ma non vogliamo entrare nel dettaglio.
Ora lancia:
root@dc # /opt/jboss/bin/domain.sh --domain-config domain.xml
--host-config=host-master.xml -P
file:///apps/jboss/nlptc27b09/configs/domain.properties

con:

root@192.168.10.0:/opt# cat
/apps/jboss/192.168.10.0/configs/domain.properties

jboss.bind.address=192.168.10.0
jboss.bind.address.management=192.168.10.0
jboss.socket.binding.port-offset=0

jboss.config.dir=/apps/jboss/nlptc27b09
jboss.domain.log.dir=/var/log/jboss/nlptc27b09
jboss.domain.base.dir=/apps/jboss/profiles/nlptc27b09
jboss.domain.base.url=file:///apps/jboss/profiles/nlptc27b09
jboss.domain.master.address=192.168.10.0
jboss.domain.name=192.168.10.0

Che solo un modo per amministrare le caratteristiche del nostro DC pi pulito. Comunqueil
seguente processo dovrebbe essere in esecuzione:

root@192.168.10.0:/opt# ps -ef | grep jboss | grep -v grep


jboss
8339
1 0 08:40 ?
00:00:00 /bin/sh
/opt/jboss/bin/domain.sh --domain-config domain.xml --hostconfig=host.xml -P
file:///apps/jboss/192.168.10.0/configs/domain.properties
jboss
8382 8339 0 08:40 ?
00:00:03 /opt/jdk/bin/java
-D[Process Controller] -server
-Dorg.jboss.boot.log.file=/var/log/jboss/192.168.10.0/processcontroller.log
-Dlogging.configuration=file:/apps/jboss/profiles/192.168.10.0/con
figuration/logging.properties -jar /opt/jboss/jboss-modules.jar
-mp /opt/jboss/modules org.jboss.as.process-controller -jboss-home
/opt/jboss -jvm /opt/jdk/bin/java -mp /opt/jboss/modules --Dorg.jboss.boot.log.file=/var/log/jboss/192.168.10.0/hostcontroller.log
-Dlogging.configuration=file:/apps/jboss/profiles/192.168.10.0/con
figuration/logging.properties -server -- -default-jvm
/opt/jdk/bin/java --domain-config domain.xml --hostconfig=host.xml -P
file:///apps/jboss/192.168.10.0/configs/domain.properties
jboss
8396 8382 0 08:40 ?
00:00:11 /opt/jdk/bin/java
-D[Host Controller]
-Dorg.jboss.boot.log.file=/var/log/jboss/192.168.10.0/hostcontroller.log
-Dlogging.configuration=file:/apps/jboss/profiles/192.168.10.0/con
figuration/logging.properties -server -jar /opt/jboss/jbossmodules.jar -mp /opt/jboss/modules -jaxpmodule javax.xml.jaxp-

provider org.jboss.as.host-controller -mp /opt/jboss/modules --pcaddress 127.0.0.1 --pc-port 46303 -default-jvm /opt/jdk/bin/java
--domain-config domain.xml --host-config=host.xml -P
file:///apps/jboss/192.168.10.0/configs/domain.properties
-Djboss.home.dir=/opt/jboss

2.3.

2.3.1

Aggiungere utenti JBoss

Aggiungere ladmin user

Lo user admin usto per accedere al sito di amministrazione:

root@dc : /opt/jboss/bin # ./add-user.sh

What type of user do you wish to add?


a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a):

Enter the details of the new user to add.


Realm (ManagementRealm) :
Username : admin
Password : <welkom>
Re-enter Password : <welkom>
Updated user 'admin' to file '/opt/jboss-eap6.0.0/standalone/configuration/mgmt-users.properties'

Updated user 'admin' to file '/opt/jboss-eap6.0.0/domain/configuration/mgmt-users.properties'


Is this new user going to be used for one AS process to connect to
another AS process e.g. slave domain controller?
yes/no? no

Hai bisogno di questo utente anche se vuoi accedere alla console di jboss-cli del DC da remoto

2.3.2

Aggiungere un utente slave

Lutente slaveuser viene usato dai nodi esterni (Slaves) per collegarsi al Domain Controller:

root@dc : /opt/jboss/bin # ./add-user.sh

What type of user do you wish to add?


a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a):

Enter the details of the new user to add.


Realm (ManagementRealm) :
Username : slaveuser
Password : <welkom>
Re-enter Password : <welkom>

About to add user 'slaveuser' for realm 'ManagementRealm'


Is this correct yes/no? yes
Added user 'slaveuser' to file
'/opt/jboss/standalone/configuration/mgmt-users.properties'
Added user 'slaveuser' to file
'/opt/jboss/domain/configuration/mgmt-users.properties'
Is this new user going to be used for one AS process to connect to
another AS process e.g. slave domain controller?
yes/no? yes

To represent the user add the following to the server-identities


definition <secret value="d2Vsa29t" />

=====================================
CHAPTER 3: Installare gli slaves
=====================================

Inizia con un nome univoco (qui slave1) per ogni slave e ripeti questa operazione per quanti
slaves vuoi avere nella tua architettura Nota che gli slaves possono risiedere fisicamente
ovunque (ad esempio, per i production servers, da qualche altra parte su internet, o persino sul
tuo laptop). Il nome assegnato deve essere univoco (in ambiente di produzione si usa
solitamente il Fully Qualified Domain Name FQDN, che permette di avere architetture molto
estese e flessibili).

3.1.

Come installare uno slave.

Semplice, segui il passo 2.1

3.2.

Configurare la relazione DC/Slaves

Darto che sar sempre la stessa cosa (con qualche variazione sul tema) per ogni slave, vediamo
come fare per lapplicationserver slave1 (192.168.20.0):

3.2.1.

Modificare host-slave.xml

<?xml version='1.0' encoding='UTF-8'?>

<host name="slave1" xmlns="urn:jboss:domain:1.3">

<management>
<security-realms>
<security-realm name="ManagementRealm">
<server-identities>
<secret value="$
{jboss.domain.login.password}"/>
</server-identities>
<authentication>
<local default-user="$local"/>
<properties path="mgmt-users.properties"
relative-to="jboss.domain.config.dir"/>
</authentication>
</security-realm>

...

Se usi questa configurazione, dovrai fornire una propriet jboss.domain.login.password durante


lavvio con la modalit -Djboss.domain.login.password=. Purtroppo, questa una propriet
non crittografata che apparir quando andrete ad elencare I processi attivi sul server. Se ci tieni
alla sicurezza, puoi fare cos:

...
<security-realm name="ManagementRealm">
<server-identities>
<secret value="d2Vsa29t"/>
</server-identities>
<authentication>
<local default-user="$local"/>
<properties path="mgmt-users.properties"
relative-to="jboss.domain.config.dir"/>
</authentication>
</security-realm>
...

La secret quella fornita durante il passo 2.3.2. Adesso per rendere lAS slave del DC, apporta la
seguente modifica:

...
<domain-controller>
<remote host="${jboss.domain.master.address}" port="$
{jboss.domain.master.port:9999}" security-realm="ManagementRealm"
username="${jboss.domain.login.user}"/>
</domain-controller>
...

Usiamo delle variabili, perch abbiamo deciso di mettere in campo un file di properties che le
gestisce. (Attenzione a ${jboss.domain.login.user})
In alternativa si possono scrivere I valori direttamente.
Ma noi ci teniamo alla sicurezza, giusto ?

3.2.2.

Avviare lo slave.

Il modo pi semplice di avviare lo slave semplicemente lanciare


/opt/jboss/bin/domain.sh -b <bind-address> dopo aver impostato la variabile
dambiente JAVA_HOME. Nota che questo anche il modo peggiore perch cos parte in
foreground. Ci sono una variet di modi per far partire il DC in background e visualizzarne il log
su una console ad-hoc nvece che sulla shell (prompt), ma non vogliamo entrare nel dettaglio.
Ora lancia:

root@slave1 # /opt/jboss/bin/domain.sh --domain-config domain.xml


--host-config=host-slave.xml -P
file:///apps/jboss/slave1/configs/domain.properties

con:

root@slave1:/opt# cat /apps/jboss/alave1/configs/domain.properties

jboss.bind.address=192.168.20.0
jboss.bind.address.management=192.168.20.0
jboss.socket.binding.port-offset=0
jboss.domain.log.dir=/var/log/jboss/slave1
jboss.domain.master.address=192.168.10.0

jboss.domain.name=slave1
jboss.domain.login.user=slaveuser
jboss.domain.login.password=welkom

E si ottiene

root@slave1:/opt# ps -ef | grep jboss | grep -v grep


jboss
6670
1 0 11:44 ?
00:00:00 /bin/sh
/opt/jboss/bin/domain.sh --domain-config domain.xml --hostconfig=host-slave.xml -P
file:///apps/jboss/fbewslave/configs/domain.properties
jboss
6713 6670 0 11:44 ?
00:00:00 /opt/jdk/bin/java
-D[Process Controller] -server
-Dorg.jboss.boot.log.file=/var/log/jboss/fbewslave/processcontroller.log
-Dlogging.configuration=file:/apps/jboss/profiles/fbewslave/config
uration/logging.properties -jar /opt/jboss/jboss-modules.jar
-mp /opt/jboss/modules org.jboss.as.process-controller -jboss-home
/opt/jboss -jvm /opt/jdk/bin/java -mp /opt/jboss/modules --Dorg.jboss.boot.log.file=/var/log/jboss/fbewslave/hostcontroller.log
-Dlogging.configuration=file:/apps/jboss/profiles/fbewslave/config
uration/logging.properties -server -- -default-jvm
/opt/jdk/bin/java --domain-config domain.xml --host-config=hostslave.xml -P
file:///apps/jboss/fbewslave/configs/domain.properties
jboss
6728 6713 3 11:44 ?
00:00:04 /opt/jdk/bin/java
-D[Host Controller]
-Dorg.jboss.boot.log.file=/var/log/jboss/fbewslave/hostcontroller.log
-Dlogging.configuration=file:/apps/jboss/profiles/fbewslave/config
uration/logging.properties -server -jar /opt/jboss/jbossmodules.jar -mp /opt/jboss/modules -jaxpmodule javax.xml.jaxpprovider org.jboss.as.host-controller -mp /opt/jboss/modules --pcaddress 127.0.0.1 --pc-port 37932 -default-jvm /opt/jdk/bin/java
--domain-config domain.xml --host-config=host-slave.xml -P
file:///apps/jboss/fbewslave/configs/domain.properties
-Djboss.home.dir=/opt/jboss

3.2.3.

Controllare se lo slave connesso al domain controller

Lo slave connesso al domain controller quando puoi visualizzare slave1 come host nella jbosscli cos:

root@dc:/opt/jboss/bin# ./jboss-cli.sh --controller=192.168.10.0


--connect
[domain@192.168.10.0:9999 /] ls -l /host
slave1
master

=================================
CHAPTER 4: Creare un nuovo profilo
=================================

4.1.

Add a profile definition to the domain.xml

Dato che non (ancora) possibile copiare un profile con il JBoss client, lo faremo a mano:

1. Aprire /opt/jboss/domain/configuration/domain.xml nel domain crontroller.


2. Se vogliamo un profile di tipo full-HA, copiare tutto quello che compreso tra:

<profile name="full-ha">
...

</profile>

Creando un nuovo spezzone di <profiles> ... </profiles> tags, ad esempio:

<profile="cluster1">
...
</profile>

attenzione:

Le seguenti propriet della nostra architettura dovranno essere impostate a livello del profilo:

* Il nome del bilanciatore, essenzialmente quello che dovremo inserire nell Apache Virtual Host
tra i tags <Proxy> ... </Proxy>.
* Il jdbc-driver.
* Il datasource.
* configurazione del logging per il web system.

4.2.

Controlliamo se il profile c

Dopo aver modificato il file domain.xml del domain controller, restarare il DCte controllare se il
profilo appare sulla jboss-cli:

[domain@145.78.121.33:9999 /] ls -l /profile

cluster1
cluster2
default
full
full-ha
ha

Vediamo che abbiamo ripetuto il passo 4.1 con il cluster-name cluster2, visto che dobbiamo
configurare due clusters separati.

=============================================================
CHAPTER 5: Configurare larchitettura per un cluster funzionante
=============================================================

5.1.

Uno script per configurare il profilo e il server-group

Ricorda sempre che non stiamo facendo una mappatura 1 a 1, ma una configurazione
ortogonale della combinazione profilo + server-group.

Salva quanto segue in un file (es: /tmp/cluster1.cli).

#
# Setting the balancer name in the profile
#

/profile=cluster1/subsystem=modcluster/mod-clusterconfig=configuration:write-attribute(name=balancer,
value="cluster1")

#
# Creating the server group
#

/server-group=cluster1-server-group:add(profile=cluster1, socketbinding-group=ha-sockets, socket-binding-port-offset=0)

#
# Creating JDBC Driver entries and datasource entry for cluster1
# Datasource definition shown for Oracle
#

/profile=cluster1/subsystem=datasources/jdbcdriver=mysql:add(driver-name="mysql",driver-modulename="com.mysql")
/profile=cluster1/subsystem=datasources/jdbcdriver=oracle:add(driver-name="oracle",driver-modulename="com.oracle.ojdbc6")

data-source --name=cluster1_DS \
--connectionurl="jdbc:oracle:thin:@databaseserver:port:database" \
--jndi-name="java:jboss/cluster1_DS" \
--driver-name="oracle" \
--user-name="cluster1_appl" --password="password" \

--use-java-context="true" \
--min-pool-size="0" \
--max-pool-size="64" \
--idle-timeout-minutes="30" \
--background-validation="false" \
--background-validation-millis="1" \
--validate-on-match="true" \
--allocation-retry="0" \
--share-prepared-statements="false" \
--set-tx-query-timeout="false" \
--query-timeout="0" \
--use-try-lock="0" \
--url-delimiter="|" \
--profile=cluster1 add

#
# Creating application properties entry (if needed of course)
#

/server-group=cluster1-server-group/systemproperty=PROPERTY_FILE:add(value="/home/jboss/data/cluster1.proper
ties")

#
# Creating proxy-list for modcluster
#

/profile=cluster1/subsystem=modcluster/mod-clusterconfig=configuration:write-attribute(name=proxy-list,
value=192.168.0.1:80)
#
# Creating access log entry
#

/profile=cluster1/subsystem=web/virtual-server=defaulthost/access-log=configuration:add(extended=false, pattern="%a %t
%H %p %U %s ", prefix=false, resolve-hosts=false, rotate=true

Certo ci potrebbero essere molte alter direttive (puoi mettere quello che credi), a questo punto:

root@dc # cd /opt/jboss/bin
root@dc # /jboss-cli.sh --controller=192.168.10.0 --connect
--file=/tmp/cluster1.cli

5.2.

Creare e configurare server-configs

Un server-group contiene molteplici server-configs, che sono un sinonimo dei nodi cluster nei
bei vecchi tempi andati. Questi server-configs possono essere lanciati ovunque ci sia un JBoss
slave installato. Se non lhai ancora fatto, segui il passo 3.2.3 e controlla se lo slave presente.
Quindi (sempre con jboss-cli):

[domain@192.168.10.0:9999 /] /host=slave1/serverconfig=node11:add(auto-start=true, group=cluster1-server-group,


socket-binding-group=ha-sockets, socket-binding-port-offset=0)

{
"outcome" => "success",
"result" => undefined
}

5.3.

Lanciare i nodes e controllare dove sono I files

Puoi avviare, stoppare o restartare i server-configs cos:

[domain@192.168.10.0:9999 /] /host=slave1/serverconfig=node11:start
{
"outcome" => "success",
"result" => "STARTING"
}

Su slave1 possiamo visualizzare:

root@slave1:/home/wnoordui# tree /opt/jboss/domain/servers/node11/


/opt/jboss/domain/servers/node11/
|-- data
|-- log
|

|-- accesslog

|-- boot.log

`-- access_log.2013-02-13

|-- server.log

`-- server.log.2013-02-11

`-- tmp

5.4.

Abilitare i datasources e testarli

[domain@192.168.10.0:9999 /]
/profile=cluster1/subsystem=datasources/datasource=cluster1_DS:enable
{
"outcome" => "success",
"result" => undefined,
"server-groups" => {"cluster1-server-group" => {"host" =>
{"slave1" => {"node11" => {"response" => {
"outcome" => "success",
"result" => undefined
}}}}}}
}

[domain@192.168.10.0:9999 /]
/host=slave1/server=node11/subsystem=datasources/datasource=cluster1_DS:test-connection-in-pool
{
"outcome" => "success",
"result" => [true]

=================================================
CHAPTER 6: Deployare e testare le applicazioni
=================================================

6.1.

Deployare unapplicazione

semplice, supponiamo di avere /tmp/testapp.war che contiene unapplicazione web. Quindi:

[domain@192.168.10.0:9999 /] deploy
groups=cluster1-server-group

/tmp/testapp.war --server-

Seguire i logfiles su uno dei nodi del cluster1-server-group (node11 sarebbe una buona scelta)/

6.2.

Testare lapplicazione

Per me: lynx http://slave1:8080/testapp funziona su SuSE, ma se sei un fun dei


browser puoi usare chrome, Firefox o Safari Persino IE.

=====================================
CHAPTER 7: di cosa non abbiamo parlato
=====================================

In questo tutorial abbiamo visto solo il modo facile di configurare cluster e/o
architetture clusterlike in esecuzione su un domain cluster (server-configs).
Non ci siamo addentrati nei meandri dell hibernazione, messaggistica, ecc.

Potete proseguire con il CHAPTER 8, per approfondire la configurazione di un


bilanciatore, il mod cluster e i cookies di sessione (sticky session), ma questa
parte lavevo scritta tempo fa in inglese, quindi lho tradotta al volo mentra
arrivavate.
Siate comprensivi.

===========================================
CHAPTER 8: Bilanciamento (mod-cluster e sticky-session)
===========================================
8.1. Downloading del pacchetto binary mod_cluster 1.1.1:

Andare sul link http://www.jboss.org/mod_cluster/downloads/1-1-1 e scaricare larchivio


adatto al Sistema di riferimento. Il pacchetto jboss.org contiene una versione httpd. Si pu
scegliere di scaricarlo e installarlo per intero o, nel caso il sistema abbia gi un server httpd
installato, di copiare le shared libraries necessarie nella directory appropriata dove stato
configurato il server Apache gi esistente. Scegliamo questultima opzione. Quindi:

ws # unzip /tmp/mod_cluster-1.1.1.Final-linux2-x64-ssl.tar.gz
ws # cd /tmp/opt/jboss/httpd/
ws # cp lib* /distr/jboss-ews/httpd/lib
ws # cd httpd/modules
ws # cp -p mod_advertise.so mod_jk.so mod_manager.so /distr/jbossews/httpd/modules
ws # cp -p mod_proxy_cluster.so mod_slotmem.so /distr/jbossews/httpd/modules
8.2. Creare un file cluster.conf
Il nostro file di configurazione httpd.conf legge le regole da altri files attraverso una direttiva
"Include conf.d/*.conf" allinterno del file http.conf stesso. E possibile che alcune versioni di
Apache non abbiano una cartella conf.d/, ma questo non deve essere un impedimento, baste
crearla e dotarla dei permessi necessary. Quindi baster aggiungere la direttiva
Include conf.d/*.conf
allinterno del file httpd.conf

Creare un file ${APACHE_HOME}/conf.d/cluster.conf

LoadModule
LoadModule
LoadModule
LoadModule
LoadModule
LoadModule
LoadModule

proxy_module modules/mod_proxy.so
proxy_ajp_module modules/mod_proxy_ajp.so
slotmem_module modules/mod_slotmem.so
manager_module modules/mod_manager.so
proxy_cluster_module modules/mod_proxy_cluster.so
advertise_module modules/mod_advertise.so
rewrite_module modules/mod_rewrite.so

e mettere il carattere # per commentare tutte le direttive gi presenti.


8.3. Caricare i virtual hosts:

Inseriamo per ogni virtual host una direttiva di inclusione per le configurazioni (che risiedono nel
nostro sistema in ${APACHE_HOME}/conf/virtual_hosts/.

La fine del file ${APACHE_HOME}/conf/httpd.conf dovrebbe assomiglare a:

NameVirtualHost *:80
#
# Include various virtual host configurations
#
Include "conf/virtual_hosts/jboss.conf"
Include "conf/virtual_hosts/application1.conf"
Include "conf/virtual_hosts/application2.conf
8.4. jboss.conf, un virtual host dummy

<VirtualHost *:80>
<Directory />
Order deny,allow
Allow from all
</Directory>
<Location /mcm>
SetHandler mod_cluster-manager

Order deny,allow
Allow from 192.168
</Location>
KeepAliveTimeout 60
MaxKeepAliveRequests 0
ManagerBalancerName testcluster
AdvertiseFrequency 5
ServerAdvertise On
EnableMCPMReceive
</VirtualHost>
Attenzione:

o testcluster un nome fittizio. Non h testato larchitettura senza di esso, ma immagino


funzioni ugualmente.
o Il mod cluster manager pu essere raggiunt attraverso lURL http://192.168.0.1/mcm .
8.5. I Virtual hosts per application1 e application2:

application1.conf:
=================

<VirtualHost *:80>
ServerAdmin unix@tntpost.nl
DocumentRoot /apps/www.application1.nl/data
ServerName www.application1.nl:80
ErrorLog logs/www.application1.nl-error_log
CustomLog logs/www.application1.nl-access_log combined
LogLevel debug
ProxyPass / balancer://cluster1/application1
stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://cluster1/application1
</VirtualHost>

application2.conf:
=================

<VirtualHost *:80>
ServerAdmin unix@tntpost.nl
DocumentRoot /apps/www.application2.nl/data
ServerName www.application2.nl:80
ErrorLog logs/www.application2.nl-error_log
CustomLog logs/www.application2.nl-access_log combined
LogLevel debug
ProxyPass / balancer://cluster2/application2
stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://cluster2/
</VirtualHost>

=============================================================
CHAPTER 9: Configurazione attraverso ununico script da console
jboss-cli
==============================================================

# stop the preconfigured server for the domain


batch
# first stop the default servers, block until the server is down
/host=master/server-config=server-one:stop(blocking=true)
/host=master/server-config=server-two:stop(blocking=true)
# remove the default server configuration and server-groups
/host=master/server-config=server-one:remove
/host=master/server-config=server-two:remove

/host=master/server-config=server-three:remove
/server-group=main-server-group:remove
/server-group=other-server-group:remove

# ---- configure the domain for the quickstart ejb-multi-server


# disable the local authentication for applications
/host=master/core-service=management/securityrealm=ApplicationRealm/authentication=local:remove
/profile=default/subsystem=ejb3:write-attribute(name=default-missing-method-permissions-denyaccess, value=false)
/profile=ha/subsystem=ejb3:write-attribute(name=default-missing-method-permissions-deny-access,
value=false)
# Configure the connection from main server to "one" and "two"
# this is to use the application "one" and "two" located at the remote server
#
# add the socket binding to the full-sockets, used by the app-main server
/socket-binding-group=full-sockets/remote-destination-outbound-socket-binding=remote-ejb1:add(host=localhost, port=4547)
/socket-binding-group=full-sockets/remote-destination-outbound-socket-binding=remote-ejb2:add(host=localhost, port=4647)
# add the outbound connections to the remoting subsystem of the full-profile used by app-main server
/profile=full/subsystem=remoting/remote-outbound-connection=remote-ejb-connection1:add(outbound-socket-binding-ref=remote-ejb-1, security-realm=ejb-security-realm-1,
username=quickuser1)
/profile=full/subsystem=remoting/remote-outbound-connection=remote-ejb-connection1/property=SASL_POLICY_NOANONYMOUS:add(value=false)
/profile=full/subsystem=remoting/remote-outbound-connection=remote-ejb-connection1/property=SSL_ENABLED:add(value=false)
/profile=full/subsystem=remoting/remote-outbound-connection=remote-ejb-connection2:add(outbound-socket-binding-ref=remote-ejb-2, security-realm=ejb-security-realm-2,
username=quickuser2)
/profile=full/subsystem=remoting/remote-outbound-connection=remote-ejb-connection2/property=SASL_POLICY_NOANONYMOUS:add(value=false)
/profile=full/subsystem=remoting/remote-outbound-connection=remote-ejb-connection2/property=SSL_ENABLED:add(value=false)
# add the security realms with the secret (password base64) values for the server communication
/host=master/core-service=management/security-realm=ejb-security-realm-1:add()
/host=master/core-service=management/security-realm=ejb-security-realm-1/serveridentity=secret:add(value=cXVpY2sxMjMr)
/host=master/core-service=management/security-realm=ejb-security-realm-2:add()
/host=master/core-service=management/security-realm=ejb-security-realm-2/serveridentity=secret:add(value=cXVpY2srMTIz)
# adjust the default JVM configuration to minimum
/host=master/jvm=default:write-attribute(name=permgen-size, value=64m)
/host=master/jvm=default:write-attribute(name=max-permgen-size, value=128m)

#add the main-server group and the server which handle the standalone client requests
/server-group=quickstart-ejb-multi-main-server:add(profile=full,socket-binding-group=full-sockets)
/server-group=quickstart-ejb-multi-main-server/jvm=default:add()
/host=master/server-config=app-main:add(auto-start=true, group=quickstart-ejb-multi-main-server)
#add the app-server group and the servers for the destination application
# app-one will be a clustered application, so use HA and add two servers
/server-group=quickstart-ejb-multi-appOne-server:add(profile=ha,socket-binding-group=ha-sockets)
/server-group=quickstart-ejb-multi-appOne-server/jvm=default:add()
/host=master/server-config=app-oneA:add(auto-start=true, group=quickstart-ejb-multi-appOneserver, socket-binding-port-offset=100)
/host=master/server-config=app-oneB:add(auto-start=true, group=quickstart-ejb-multi-appOneserver, socket-binding-port-offset=700)
# app two is not a clustered application, so use default profile
/server-group=quickstart-ejb-multi-appTwo-server:add(profile=default,socket-binding-group=standardsockets)
/server-group=quickstart-ejb-multi-appTwo-server/jvm=default:add()
/host=master/server-config=app-twoA:add(auto-start=true, group=quickstart-ejb-multi-appTwoserver, socket-binding-port-offset=200)
/host=master/server-config=app-twoB:add(auto-start=true, group=quickstart-ejb-multi-appTwoserver, socket-binding-port-offset=800)
# add an alias for app2 bean to demonstrate how to avoid direct dependency to destination app name
/profile=full/subsystem=naming/binding=java\:global\/AliasAppTwo:add(binding-type=lookup,
lookup="ejb:jboss-ejb-multi-server-app-two/ejb//AppTwoBean!
org.jboss.as.quickstarts.ejb.multi.server.app.AppTwo")

# --- add an additional server and group for web application only
# create a new profile
/profile=default-web:add()
/profile=default-web/subsystem=logging:add()
/profile=default-web/subsystem=logging/periodic-rotating-file-handler=FILE:add(file={"relativeto"=>"jboss.server.log.dir", "path"=>"server.log"},append=true,suffix=.yyyy-MMdd,formatter="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n")
/profile=default-web/subsystem=logging/logger=com.arjuna:add(level=WARN)
/profile=default-web/subsystem=logging/logger=org.apache.tomcat.util.modeler:add(level=WARN)
/profile=default-web/subsystem=logging/logger=sun.rmi:add(level=WARN)
/profile=default-web/subsystem=logging/logger=jacorb:add(level=WARN)
/profile=default-web/subsystem=logging/logger=jacorb.config:add(level=ERROR)
/profile=default-web/subsystem=logging/root-logger=ROOT:add(level=INFO,handlers=["FILE"])
/profile=default-web/subsystem=configadmin:add()
/profile=default-web/subsystem=ee:add(spec-descriptor-property-replacement=false,jboss-descriptorproperty-replacement=true)
/profile=default-web/subsystem=ejb3:add()
/profile=default-web/subsystem=ejb3:write-attribute(name=default-slsb-instance-pool,value=slsbstrict-max-pool)

/profile=default-web/subsystem=ejb3:write-attribute(name=default-sfsb-cache,value=simple)
/profile=default-web/subsystem=ejb3:write-attribute(name=default-stateful-bean-access-timeout,
value=5000)
/profile=default-web/subsystem=ejb3:write-attribute(name=default-singleton-bean-access-timeout,
value=5000)
/profile=default-web/subsystem=ejb3/strict-max-bean-instance-pool=slsb-strict-max-pool:add(maxpool-size=20,timeout=5,timeout-unit=MINUTES)
/profile=default-web/subsystem=ejb3/strict-max-bean-instance-pool=mdb-strict-max-pool:add(maxpool-size=20,timeout=5,timeout-unit=MINUTES)
/profile=default-web/subsystem=ejb3/cache=simple:add(aliases=["NoPassivationCache"])
/profile=default-web/subsystem=ejb3/cache=passivating:add(passivationstore=file,aliases=["SimpleStatefulCache"])
/profile=default-web/subsystem=ejb3/file-passivation-store=file:add
/profile=default-web/subsystem=ejb3/service=async:add(thread-pool-name=default)
/profile=default-web/subsystem=ejb3/service=timer-service:add(default-data-store="default-filestore",thread-pool-name="default")
/profile=default-web/subsystem=ejb3/service=timer-service/file-data-store="default-filestore":add(path="timer-service-data",relative-to="jboss.server.data.dir")
/profile=default-web/subsystem=ejb3/service=remote:add(connector-ref=remoting-connector,threadpool-name=default)
/profile=default-web/subsystem=ejb3/thread-pool=default:add(max-threads=10,keepalivetime={"time"=>"100","unit"=>"MILLISECONDS"})
/profile=default-web/subsystem=jca:add()
/profile=default-web/subsystem=jca/archive-validation=archive-validation:add(enabled=true, fail-onerror=true, fail-on-warn=false)
/profile=default-web/subsystem=jca/bean-validation=bean-validation:add(enabled=true)
/profile=default-web/subsystem=jca/cached-connection-manager=cached-connectionmanager:add(install=true)
/profile=default-web/subsystem=jca/workmanager=default:add(name=default)
/profile=default-web/subsystem=jca/workmanager=default/short-running-threads=default:add(corethreads=50,queue-length=50,max-threads=50,keepalive-time={"time"=>"10",
"unit"=>"SECONDS"})
/profile=default-web/subsystem=jca/workmanager=default/long-running-threads=default:add(corethreads=50,queue-length=50,max-threads=50,keepalive-time={"time"=>"10",
"unit"=>"SECONDS"})
/profile=default-web/subsystem=naming:add()
# remove this command if a 7.1.1 server is used
/profile=default-web/subsystem=naming/service=remote-naming:add
/profile=default-web/subsystem=remoting:add()
/profile=default-web/subsystem=remoting/connector=remoting-connector:add(socketbinding=remoting, security-realm=ApplicationRealm)
# add the outbound connections to the remoting subsystem of the profile used by to connect the app
servers
# it might not necesarry to use a different name for 'outbound-socket-binding-ref', it is just to show the
different configuration
/profile=default-web/subsystem=remoting/remote-outbound-connection=remote-connection-war-ejb1:add(outbound-socket-binding-ref=remote-war-1, security-realm=ejb-security-realm-1,

username=quickuser1)
/profile=default-web/subsystem=remoting/remote-outbound-connection=remote-connection-war-ejb1/property=SASL_POLICY_NOANONYMOUS:add(value=false)
/profile=default-web/subsystem=remoting/remote-outbound-connection=remote-connection-war-ejb1/property=SSL_ENABLED:add(value=false)
/profile=default-web/subsystem=remoting/remote-outbound-connection=remote-connection-war-ejb2:add(outbound-socket-binding-ref=remote-war-2, security-realm=ejb-security-realm-2,
username=quickuser2)
/profile=default-web/subsystem=remoting/remote-outbound-connection=remote-connection-war-ejb2/property=SASL_POLICY_NOANONYMOUS:add(value=false)
/profile=default-web/subsystem=remoting/remote-outbound-connection=remote-connection-war-ejb2/property=SSL_ENABLED:add(value=false)
/profile=default-web/subsystem=security:add
/profile=default-web/subsystem=security/security-domain=other:add(cache-type=default)
/profile=default-web/subsystem=security/security-domain=other/authentication=classic:add(loginmodules=[{"code"=>"Remoting","flag"=>"optional","module-options"=>[("passwordstacking"=>"useFirstPass")]},{"code"=>"RealmDirect","flag"=>"required","moduleoptions"=>[("password-stacking"=>"useFirstPass")]}])
/profile=default-web/subsystem=security/security-domain=jboss-web-policy:add(cache-type=default)
/profile=default-web/subsystem=security/security-domain=jboss-webpolicy/authorization=classic:add(policy-modules=[{"code"=>"Delegating","flag"=>"required"}])
/profile=default-web/subsystem=threads:add
/profile=default-web/subsystem=transactions:add(socket-binding=txn-recovery-environment, statussocket-binding=txn-status-manager, default-timeout=300, process-id-uuid=true)
/profile=default-web/subsystem=web:add(default-virtual-server=default-host,native=false)
/profile=default-web/subsystem=web/connector=http:add(protocol=HTTP/1.1, scheme=http, socketbinding=http)
/profile=default-web/subsystem=web/virtual-server=default-host:add(enable-welcome-root=true,
alias=["localhost","example.com"])

/socket-binding-group=standard-sockets-web:add(default-interface=public)
/socket-binding-group=standard-sockets-web/socket-binding=http:add(port=8080)
/socket-binding-group=standard-sockets-web/socket-binding=remoting:add(port=4447)
/socket-binding-group=standard-sockets-web/socket-binding=txn-recoveryenvironment:add(port=4712)
/socket-binding-group=standard-sockets-web/socket-binding=txn-status-manager:add(port=4713)
# add the socket binding for connection to app-one, app-two
/socket-binding-group=standard-sockets-web/remote-destination-outbound-socket-binding=remotewar-1:add(host=localhost, port=4547)
/socket-binding-group=standard-sockets-web/remote-destination-outbound-socket-binding=remotewar-2:add(host=localhost, port=4647)

/server-group=quickstart-ejb-multi-appWeb-server:add(profile=default-web,socket-bindinggroup=standard-sockets-web)

/server-group=quickstart-ejb-multi-appWeb-server/jvm=default:add()
/host=master/server-config=app-web:add(auto-start=true, group=quickstart-ejb-multi-appWeb-server,
socket-binding-port-offset=300)
run-batch
# without restart, outside the batch, there are different problems
:restart-servers
# finally start the configured servers
/host=master/server-config=app-oneA:start
/host=master/server-config=app-oneB:start
/host=master/server-config=app-twoA:start
/host=master/server-config=app-twoB:start
/host=master/server-config=app-main:start
/host=master/server-config=app-web:start