Qu'est ce qu'on se fait ch ... !

Aller au contenu | Aller au menu | Aller à la recherche

Installer et configurer Glassfish en mode cluster - 1ère partie

Après avoir fait l'équivalent sous JBOSS, j'essaye de rentrer dans le mouve et réitérer la même chose sous Glassfish

Création d'une application démo

J'ai réalisé pour l'occasion une petite application de démonstration. Elle gère un panier. Dans un premier temps, je lui fait gérer ce dernier en session HTTP. Après, je le ferai via un EJB STATEFUL

Voici l'architecture en vrac:

  • JSF 1.2
  • Facelets
  • Richfaces
  • EJB3
  • JPA
  • JDK 6

Bref, que du lourd techniquement :-D D'un point de vue fonctionnel, ce n'est , certes pas très transcendant. J'ai utilisé la base de données Travel fournie en standard sur netbeans.

Un screenshot de l'appli : glassfish-1.jpg

Configuration GLASSFISH

Création du domaine

Il faut initialiser un domaine glassfish. Si comme moi, vous avez installé Glassfish à partir du bundle netbeans, nous aurez à modifier légèrement le fichier $GLASSFISH_HOME/setup-cluster.xml

Pour info, la propriété domain.name est spécifié comme suit:

<property name="domain.name" value="domain1"/>

Il faut la modifier pour que le domaine puisse être crée.

warning.png ATTENTION : vous devez faire attention aux ports spécifiés dans ce fichier. Il ne faut pas qu'ils soient en conflit avec des applications existantes ( un domaine glassfish existant, un serveur jboss perdu dans un coin ...)

Après lancer la commande suivante :

$GLASSFISH_HOME/lib/ant/bin/ant -f setup-cluster.xml
Buildfile: setup-cluster.xml
[...]
validate-java:
     [echo] Current Java Version 1.5.0_16
[...]

create.domain:
     [exec] Using port 4848 for Admin.
     [exec] Using port 8080 for HTTP Instance.
     [exec] Using port 7676 for JMS.
     [exec] Using port 3700 for IIOP.
     [exec] Using port 8181 for HTTP_SSL.
     [exec] Using default port 3820 for IIOP_SSL.
     [exec] Using default port 3920 for IIOP_MUTUALAUTH.
     [exec] Using default port 8686 for JMX_ADMIN.
     [exec] Domain being created with profile:developer, as specified by variabe AS_ADMIN_PROFILE in configuration file.
     [exec] The file in given locale [fr_FR] at: [C:\java\servers\glassfish-v2u2\lib\install\templates\locales\fr_FR\index.html] could not be found. Using defult (en_US) index.html instead.
     [exec] Security Store uses: JKS
     [exec] Domain domain-cluster-1 created.
     [exec] Admin login information for host [localhost] and port [4848] is beig overwritten with credentials provided. This is because the --savelogin option
was used during create-domain command.
     [exec] Login information relevant to admin user name [admin] for this doman [domain-cluster-1] stored at [C:\Documents and Settings\touret-a\.asadminpass
 successfully.
     [exec] Make sure that this file remains protected. Information stored in this file will be used by asadmin commands to manage this domain.
   [delete] Deleting: c:\java\servers\glassfish-v2ur2\passfile

BUILD SUCCESSFUL
Total time: 29 seconds

Peut être que l'installation multi JDK me fera défaut....Wait & see ....

Lancement du serveur

Avec asadmin:

$ bin/asadmin.bat start-domain --user admin domain-cluster-1
Starting Domain domain-cluster-1, please wait.
Log redirected to C:\java\servers\glassfish-v2ur2\domains\domain-cluster-1\logs\server.log.
29 oct. 2008 08:56:34 com.sun.jbi.installer.JBIComponentsConfigurator configure
INFO: Configuring jbi components...
29 oct. 2008 08:56:42 com.sun.jbi.installer.JBIComponentsConfigurator configure 
INFO: OpenESB JBI Components Configuration Successful
The operation CONFIGURE on the addon jbi_components_configurator is complete.
Redirecting output to C:/java/servers/glassfish-v2ur2/domains/domain-cluster-1/l
ogs/server.log
Domain domain-cluster-1 is ready to receive client requests. Additional services are being started in background.
Domain [domain-cluster-1] is running [Sun Java System Application Server 9.1_02
(build b04-fcs)] with its configuration and logs at: [C:\java\servers\glassfish-v2ur2\domains].
Admin Console is available at [http://localhost:4848].
Use the same port [4848] for "asadmin" commands.
User web applications are available at these URLs:
[http://localhost:8080 https://localhost:8181 ].
Following web-contexts are available:
[/web1  /__wstx-services ].
Standard JMX Clients (like JConsole) can connect to JMXServiceURL:
[service:jmx:rmi:///jndi/rmi://127.0.0.1:8686/jmxrmi] for domain management purposes.
Domain listens on at least following ports for connections:
[8080 8181 4848 3700 3820 3920 8686 ].
Domain does not support application server clusters and other standalone instances.

Pour les utilisateurs du couple netbeans/ glassfish

Vous devez vous connecter sur la console d'administration et effectuer les actions suivantes

Dans le menu "Serveur d'Applications" glassfish001.jpg

Activer le support du mode cluster glassfish002.jpg

puis redémarrer le serveur d'applications

Création du cluster

$ bin/asadmin.bat create-cluster --user admin --host 127.0.0.1 --port 4848 cluster-1
Please enter the admin password>
Command create-cluster executed successfully.

Création de l'agent

$ bin/asadmin.bat create-node-agent --user admin --host 127.0.0.1 --port 4848 cluster-1-node-agent-1
Please enter the admin password>
Command create-node-agent executed successfully.

Après la création on les démarre:

$ bin/asadmin.bat start-node-agent cluster-1-node-agent-1
Please enter the admin user name>admin
Please enter the admin password>
Please enter the master password [Enter to accept the default]:>
Redirecting output to C:/java/servers/glassfish-v2ur2/nodeagents/cluster-1-node-agent-1/agent/logs/server.log
Redirecting application output to C:/java/servers/glassfish-v2ur2/nodeagents/cluster-1-node-agent-1/agent/logs/server.log
Command start-node-agent executed successfully.

Création des instances contenues dans le noeud (node)

Première instance

$ bin/asadmin.bat create-instance --user admin --nodeagent cluster-1-node-agent -1 --cluster cluster-1 cluster-1-nodeagent-1-instance-1
Using 38á081 for HTTP_LISTENER_PORT.
Using 38á182 for HTTP_SSL_LISTENER_PORT.
Using 33á821 for IIOP_SSL_LISTENER_PORT.
Using 37á677 for JMS_PROVIDER_PORT.
Using 33á701 for IIOP_LISTENER_PORT.
Using 38á687 for JMX_SYSTEM_CONNECTOR_PORT.
Using 33á921 for IIOP_SSL_MUTUALAUTH_PORT.
Command create-instance executed successfully.

Deuxième instance

$ bin/asadmin.bat create-instance --user admin --nodeagent cluster-1-node-agent-1 --cluster cluster-1 cluster-1-nodeagent-1-instance-2
Using 38á082 for HTTP_LISTENER_PORT.
Using 38á183 for HTTP_SSL_LISTENER_PORT.
Using 33á822 for IIOP_SSL_LISTENER_PORT.
Using 37á678 for JMS_PROVIDER_PORT.
Using 33á702 for IIOP_LISTENER_PORT.
Using 38á688 for JMX_SYSTEM_CONNECTOR_PORT.
Using 33á922 for IIOP_SSL_MUTUALAUTH_PORT.
Command create-instance executed successfully.

Démarrage des instances

$ bin/asadmin.bat start-instance cluster-1-nodeagent-1-instance-1
Command start-instance executed successfully.
$ bin/asadmin.bat start-instance cluster-1-nodeagent-1-instance-2
Command start-instance executed successfully.

Conclusion

J'en ai fini de la première partie, qui était la création de mon premier cluster. Mon ressentiment est très positif. On peut faire la totalité avec asadmin, la configuration des ports est automatique, ce qui est un GROS voire ENORME avantage par rapport à JBOSS :-). Je trouve même que ca rend beaucoup plus professionnel et me conforte dans l'idée que les serveurs d'application JAVA EE propriétaires sont désormais obsolètes. Un gros inconvénient, c'est qu'il existe qu'un seul domaine. Je pense faire prochainement un DAS et un domaine applicatif. La suite dans un prochain épisode

Après deux ans d'utilisation d'un FRAMEWORK Struts Spring Hibernate

il était temps de faire un bilan du déploiement d'applications JAVA EE basées sur les célèbres FRAMEWORKS STRUTS SPRING et HIBERNATE..

Lire la suite...