Instalación de Glassfish 3 sobre Debian Linux
El servidor de aplicaciones Java Glassfish 3 es la implementación de referencia Java EE actualmente. Este documento comenta brevemente algunos pasos y detalles de la instalación del servidor como un servicio sobre un servidor corriendo Debian Linux.
Instalación
La instalación no presenta particularidades fuera de la documentación oficial.
- Descargar y descomprimir.
- Crear usuario para ejecutar el glassfish:
adduser - home / opt/glassfishv3 - disabled-password - disabled-login glassfish
- Preparar un init.d por el servicio, ver más adelante.
- Cambiar permisos directorio:
chown-R glassfish.glassfish / opt/glassfishv3 /
init.d
#! /bin/sh
### BEGIN INIT INFO
# Provides: glassfish
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: glassfish initscript
# Description: Simple initscript for GlassFish App server
### END INIT INFO
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="GlassFish v3 JavaEE 6 App server"
NAME=glassfish
ASADMIN=/usr/local/glassfishv3/bin/asadmin
# Username to run application server
USER="glassfish"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
su - $USER -c "$ASADMIN start-domain" \
|| return 1
}
#
# Function that stops the daemon/service
#
do_stop()
{
su - $USER -c "$ASADMIN stop-domain" \
|| return 1
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
sleep 10
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
exit 3
;;
esac
Drivers de base de datos
Para cargar un driver de base de datos sólo hay que dejar el jar pertinente bajo ./glassfish/lib
Conexión AJP con Apache HTTPD
http://weblogs.java.net/blog/2009/06/24/running-glassfish-v3-apache-httpd
Actualizaciones
Glassfish es un servidor modular conformado por diferentes módulos que se pueden actualizar independientemente. También se pueden descargar paquetes de actualización de múltiples módulos simultáneamente.
En la consola de administración hay una sección “update tool” donde se pueden consultar versiones y estado de los módulos. No se puede actualizar desde esta opción ya que hay que detener el servidor para ello.
Para actualizar podemos utilizar dos herramientas: updatetool o pkg. Ambas están en el bin del servidor y son el equivalente a un apt-get o aptitude para el glassfish. El updatetool es un GUI y el pkg es de línea de comandos.
Ambas herramientas se descargarán en el primer uso.
Hay que ejecutar las llamadas como el usuario glassfish (o aquel que ejecuta el servicio).
Ejemplo:
glassfish@bsg:~/bin$ ./pkg list
The software needed for this command (pkg) is not installed.
When this tool interacts with package repositories, some system information
such as your system's IP address and operating system type and version
is sent to the repository server. For more information please see:
[http://wiki.updatecenter.java.net/Wiki.jsp?page=UsageMetricsUC2](http://wiki.updatecenter.java.net/Wiki.jsp?page=UsageMetricsUC2)
Once installation is complete you may re-run this command.
Would you like to install this software now (y/n): y
Proxy: Using system proxy settings.
Install image: /opt/glassfishv3
Installing pkg packages.
Initialization complete.
Software successfully installed. You may now re-run this command (pkg).
glassfish@bsg:~/bin$ ./pkg list -u
No installed packages have available updates
http://wikis.sun.com/display/IpsBestPractices/Screenshots http://docs.sun.com/app/docs/doc/820-4495/ghapp?a=view
Comandos pkg
- Refrescar repositorio:
pkg refresh
- Listar paquetes actualizables:
pkg list -u
- Actualizar todo:
pkg image-update
Servidores de 64 bits
Para los servidores de 64 hay que instalar la capa de compatibilidad con 32 bits. Paquete: ia32-libs
Además en el caso de ‘lenny’ encontramos que falta la librería libidn que no se encuentra en el repositorio central y hay que cogerla de debian-multimedia.
Diferentes repositorios
GlassFish viene configurado con varios repositorios accesibles y uno preferido (stable).
Más info:
http://serverfault.com/questions/130228/glassfish-v3-security-related-updates-repository-publisher
http://blogs.sun.com/alexismp/tags/IPS
Para consultar las autoridades actuales:
glassfish@ns23515:~/glassfishv3/bin$ ./pkg authority
PUBLISHER TYPE STATUS URI
stable.glassfish.org (preferred) origin online http://pkg.glassfish.org/v3/stable/
contrib.glassfish.org origin online http://pkg.glassfish.org/v3/contrib/
contrib.glassfish.sun.com origin online http://pkg.sun.com/glassfish/v3/contrib/
dev.glassfish.org origin online http://pkg.glassfish.org/v3/dev/
release.javaeesdk.sun.com origin online http://pkg.sun.com/javaeesdk/6/release/
Por ejemplo si se quiere actualizar la versión de desarrollo más actual (cuiddo, no recomendable para producción!):
C:\cc\glassfishv3\bin>pkg set-authority -P dev.glassfish.org
C:\cc\glassfishv3\bin>pkg publisher
PUBLISHER TYPE STATUS URI
dev.glassfish.org (preferred) origin online http://pkg.glassfish.org/v3/dev/
contrib.glassfish.org origin online http://pkg.glassfish.org/v3/contrib/
contrib.glassfish.sun.com origin online http://pkg.sun.com/glassfish/v3/contrib/
release.glassfish.sun.com origin online http://pkg.sun.com/glassfish/v3/release/
stable.glassfish.org origin online http://pkg.glassfish.org/v3/stable/
C:\cc\glassfishv3\bin>pkg image-update
DOWNLOAD PKGS FILES XFER (MB)
Completed 41/41 528/528 66.1/66.1
PHASE ACTIONS
Removal Phase 66/66
Install Phase 151/151
Update Phase 557/557