Wednesday, December 15, 2010

Postgresql Tomcat en OpenSuse parte 1

Explicare brevemente los pasos para instalar Postgresql + Apache Tomcat en OpenSuse.
En este caso se trataba de una aplicación un poco antigua que corre sobre Apache Tomcat 5.5.20 y se deseaba migrar a un nuevo servidor.
Instalar Postgresql

yast2 –install postgresql-server

Instala postgresql en
/usr/share/postgresql/
Los datos se almacenan en
/var/lib/pgsql/
Los archivos de configuracion estan en
/var/lib/pgsql/data
Aqui estan los archios pg_hba.conf y postgresql.conf

Iniciar postgresql
rcpostgresql start
detener
rcpostgresql stop
Restaurar postgresql
rcpostgresql restart
Entrar a postgresql
su postgres -c psql postgres
Cambiar el password
ALTER USER postgres WITH PASSWORD ‘postgres’;

Descargamos el JDK 
Descargamos Apache Tomcat
Creamos un Script para el arranque de Tomcat 
CONFIGURAR TOMCAT PARA ARRANCAR CON EL SISTEMA OPERATIVO
copiar el script tomcat a la carpeta /etc/init.d/
#!/bin/sh
# TOMCAT Init Script written by Martin Loitzl 2006
DIR_FILE=/opt/apache-tomcat-5.5.20
START_FILE=bin/startup.sh
STOP_FILE=bin/shutdown.sh
TOMCAT_START=${DIR_FILE}/${START_FILE}
TOMCAT_STOP=${DIR_FILE}/${STOP_FILE}
TOMCAT_PID_FILE=/var/run/tomcat.pid
test -x $TOMCAT_START || { echo "$TOMCAT_START not installed or execeutable";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
case "$1" in
start)
echo "Starting TOMCAT"
if [ -e $TOMCAT_PID_FILE ]; then
TOMCAT_PID=`head -n 1 $TOMCAT_PID_FILE`
if ps -p $TOMCAT_PID; then
echo "TOMCAT already running"
exit 1
else
$TOMCAT_START
exit 0
fi
else
$TOMCAT_START
exit 0
fi
;;
stop)
echo "Stopping TOMCAT"
if [ -e $TOMCAT_PID_FILE ]; then
TOMCAT_PID=`head -n 1 $TOMCAT_PID_FILE`
if ps -p $TOMCAT_PID; then
$TOMCAT_STOP
else
echo "Could not find process, trying $TOMCAT_STOP anyways"
$TOMCAT_STOP
fi
else
echo "Could not find PID file, trying $TOMCAT_STOP anyways"
$TOMCAT_STOP
fi
;;
status)
if [ -e $TOMCAT_PID_FILE ]; then
TOMCAT_PID=`head -n 1 $TOMCAT_PID_FILE`
ps -p $TOMCAT_PID
else
echo "$TOMCAT_PID_FILE not found"
fi
;;
restart)
$0 stop
echo "Shutting down TOMCAT takes some time. Waiting for 10 secs. to restart"
sleep 10
$0 start
;;
reload|force-reload)
$0 stop
echo "Shutting down TOMCAT takes some time. Waiting for 60 secs. to restart"
sleep 60
$0 start
;;
*)
echo "Usage: tomcat {start|stop|restart|status|reload|force-reload}"
exit 1
;;
esac

Le damos los permisos mediante
chmod 755 /etc/init.d/tomcat


En la parte dos explicare como agregarlo a los Run Level.

No comments: