domingo, 30 de septiembre de 2012

Tareas post-instalacion Oracle 11g release 2 en Debian 6.0 (Squeeze) de 64 bits

Por convencion durante la instalacion hemos llamado "deb664ora11gr2" al servidor, "odx" a la Instancia de base de datos y hemos instalado oracle en "/u01/app/oracle/product/11.2.0/dbhome_1".

Como "root", modificacion del fichero "oratab":

vi /etc/oratab

Cambiar:

odx:/u01/app/oracle/product/11.2.0/dbhome_1:N

por:

odx:/u01/app/oracle/product/11.2.0/dbhome_1:Y

Modificar el fichero "listener.ora":

vi /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Añadir la entrada "SID_LIST_LISTENER":

SID_LIST_LISTENER =
 (SID_LIST =
   (SID_DESC =
     (SID_NAME = odx)
     (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
     (PROGRAM = extproc)
   )
 (SID_DESC=
       (GLOBAL_DBNAME= odx.deb664ora11gr2)
       (ORACLE_HOME= /u01/app/oracle/product/11.2.0/dbhome_1)
       (SID_NAME=odx)
  )
 )

Si queremos que oracle escuche conexiones unicamente en las direcciones IPV4 modificamos la entrada "LISTENER":

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = deb664ora11gr2)(PORT = 1521)(IP=V4_ONLY))
    )
  )

Creamos el script de arranque de oracle:

vi /etc/init.d/oracle

Introducimos el siguiente contenido:

#!/bin/sh
# Oracle auto start-stop script.
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# from which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id of the owner of the 
# Oracle database in ORA_HOME.

### BEGIN INIT INFO
# Provides:          oracle
# Required-Start:    $remote_fs $syslog $named $network $time
# Required-Stop:     $remote_fs $syslog $named $network
# Should-Start:      tnslsnr
# Should-Stop:       tnslsnr
# Default-Start:     2
# Default-Stop:      0 1 6
# Short-Description: Oracle
# Description:       Oracle
### END INIT INFO

ORA_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi

case "$1" in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login 
        # will not prompt the user for any values
        su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
        touch /var/lock/oracle
        ;;
    'stop')
        # Stop the Oracle databases:
        # The following command assumes that the oracle login 
        # will not prompt the user for any values
        su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
        rm -f /var/lock/oracle
        ;;
esac

Hacemos que el fichero sea ejecutable y que sea arrancable/parable en el inicio/parada automaticamente:

chmod +x /etc/init.d/oracle

update-rc.d oracle defaults

Como "oracle", actualizar las variables de entorno del usuario:

echo "# Oracle Settings" >> /home/oracle/.profile
echo "TMP=/tmp; export TMP" >> /home/oracle/.profile
echo "TMPDIR=$TMP; export TMPDIR" >> /home/oracle/.profile
echo "ORACLE_HOSTNAME=deb664ora11gr2; export ORACLE_HOSTNAME" >> /home/oracle/.profile
echo "ORACLE_UNQNAME=odx; export ORACLE_UNQNAME" >> /home/oracle/.profile
echo "ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE" >> /home/oracle/.profile
echo "ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME" >> /home/oracle/.profile
echo "ORACLE_SID=odx; export ORACLE_SID" >> /home/oracle/.profile
echo "PATH=$ORACLE_HOME/bin:$PATH; export PATH" >> /home/oracle/.profile
echo "LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH" >> /home/oracle/.profile
echo "CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH" >> /home/oracle/.profile

Para comprobar que todo esta bien podemos probar "sqlplus":

oracle@deb664ora11gr2:~$ sqlplus -v

SQL*Plus: Release 11.2.0.1.0 Production

Y tras reiniciar desde "root":

root@deb664ora11gr2:/etc# netstat -lp | grep tnslsnr | grep -v STREAM
tcp        0      0 *:1521                  *:*                     LISTEN      982/tnslsnr

root@deb664ora11gr2:/etc# netstat -lp | grep ora_
tcp6       0      0 [::]:33079              [::]:*                  LISTEN      1227/ora_d000_odx
udp6       0      0 ip6-localhost:62128     [::]:*                              1229/ora_s000_odx
udp6       0      0 [::]:38848              [::]:*                              1223/ora_mmon_odx
udp6       0      0 ip6-localhost:37339     [::]:*                              1195/ora_pmon_odx
udp6       0      0 ip6-localhost:23137     [::]:*                              1227/ora_d000_odx





No hay comentarios:

Publicar un comentario