Monday, February 6, 2012

Configuring a network listener for Oracle on CentOS 6.2

You require to configure and run a network listener before creating a database with the Oracle's Database Configuration Assistant (dbca) tool. This is a how to configure such a listener.

I assume you already install a Oracle 11g Database Server on CentOS 6.2 with SSH X11 Forwarding and you are using a Linux client with a Desktop Environment like Gnome or KDE.
  1. Login on the server using oracle user with SSH X11 Forwarding:
  2. $ ssh -Y oracle@SERVER
    
  3. You already had the $ORACLE_HOME/bin on the PATH environment variable (see ~/.bash_profile here) so you can issue:
  4. $ netca
  5. Choose Listener Configuration on the Welcome panel:

  6. Select Add as the action:

  7. Type a listener name, I recommend the default  "LISTENER":

  8. Select protocols among the available, I choose TCP only:

  9. Choose a listening port, I recommend the default "1521" but you can change it if you want. NOTE: Remember to open this port on iptables if you want remote database access, otherwise you won't be able to use it:

  10. On More Listeners panels, choose No.
  11. If you finish gracefully the wizard, you should be able to see this on the standard output. Observe that the listener is running.
  12. $ netca 
    
    Oracle Net Services Configuration:
    Configuring Listener:LISTENER
    Listener configuration complete.
    Oracle Net Listener Startup:
        Running Listener Control: 
          /opt/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
        Listener Control complete.
        Listener started successfully.
    Oracle Net Services configuration successful. The exit code is 0
    
    you can manually stop the listener by issuing:
    $ lsnrctl stop LISTENER
    
      then start the listener by:
    $ lsnrctl start LISTENER
    
    and check the listener status:
    $ lsnrctl status LISTENER
    LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-FEB-2012 16:53:04
    
    Copyright (c) 1991, 2009, Oracle.  All rights reserved.
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myserver)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
    Start Date                06-FEB-2012 16:49:47
    Uptime                    0 days 0 hr. 3 min. 17 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /opt/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
    Listener Log File         /opt/app/oracle/diag/tnslsnr/soabpm/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=soabpm)(PORT=1521)))
    The listener supports no services
    The command completed successfully
    
    
    or verify if the listener is alive and locally reachable via TNS ping:
    $ tnsping localhost 1521
    
    TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 06-FEB-2012 16:55:34
    
    Copyright (c) 1997, 2009, Oracle.  All rights reserved.
    
    Used parameter files:
    
    Used HOSTNAME adapter to resolve the alias
    Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
    OK (0 msec)
    
    ...
    OK (0 msec)
    
    to ensure the same thing remotely you must issue. NOTE: Remember to configure iptables to allow remote access.  
    $ tnsping myserver 1521
    
    
    NOTE: Remember you must a have a running listener before creating a database.
  13. One final step is to add the ORACLE_HOME_LISTNER environment variable to oracle's ~/.bash_profile. Login to the server as oracle user and edit:
  14. $ nano ~/.bash_profile
    
    then append:
    export ORACLE_HOME_LISTNER=LISTENER
    
    at the end the ~/.bash_profile archive should look like:
    # .bash_profile
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
     . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    PATH=$PATH:$HOME/bin
    
    umask 022
    
    export TMPDIR=$TMP
    export ORACLE_BASE=/opt/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
    export PATH=$ORACLE_HOME/bin:$PATH
    
    # The SID for a database, See http://eduardo-lago.blogspot.com/2012/02/creating-new-oracle-11g-r2-database-on.html 
    export ORACLE_SID=demo 
    export ORACLE_HOME_LISTNER=LISTENER
    

What to do next?

1 comment: