Sunday, August 24, 2014

Centos hostname with dash causes configuration and tns issues with Oracle Express

Bottom Line:
When setting up a VirtualBox Centos VM that will eventually run Oracle Express, do NOT name the hostname with a dash in the name!

What Happened:
  • I set up a Centos 6.5 Virtual Box VM with the hostname of jhsu-cherryshoe; note the dash in the hostname.
  • I later installed Oracle Express 11g Release 2 for Linux x64 on it, and when configuring Oracle with /etc/init.d/oracle-xe configure, oracle did not complete its configuration properly.  Googling found some forums that said dashes in a Centos hostname may or may not cause issues with Oracle installs.
  • I went ahead and changed the hostname to jhsucherryshoe(no dash!) with the following instructions:
    • Run the hostname command
      • hostname jhsucherryshoe
    • Open /etc/sysconfig/network, update the HOSTNAME line and save:
      • # vim /etc/sysconfig/network
      • HOSTNAME=jhsucherryshoe
    • Open /etc/hosts file, and update the hostname entry and save: 
      • # vim /etc/hosts
      • 127.0.0.1 jhsucherryshoe
  • Running oracle configuration with /etc/init.d/oracle-xe configure again worked this time. Confirmed oracle started, sqlplus / as sysdba worked, and created a new db and user.
  • I thought this was the end of it and that all was well.  WRONG.
  • A couple days later I needed to access the db on the VM from my host machine with sqlDeveloper and could not access it.
  • The VirtualBox VM had the Network Adapter set to "Bridged Adapter", and the firewall configuration for the oracle port 1521 was configured so it wasn't an issue with network configs.
  • Errors seen on the VM:
    • "tnsping" gave tnslistener error
    • "lsnrctl stat" gave the following snippet.  
      • Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC_FOR_XE))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jhsu-cherryshoe)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jhsu-cherryshoe)(PORT=8081))(Presentation=HTTP)(Session=RAW))
    • Doing a grep in the /u01/app/oracle folder for jhsu-cherryshoe returned lots of results!  DARN missed that when renaming the hostname!  The initial install of the oracle rpm already created the configuration files with the original bad hostname in it. 
Final Solution for the issue of centos hostname with dash causing issues with Oracle:

  • Hostname for Centos was already changed previously
  • Uninstalled oracle xe, this article helped a lot:
    • Find out what oracle rpm's are installed
      • rpm -qa | grep oracle returned "oracle-xe-11.2.0-1.0.x86_64"
    • Uninstall the rpm via rpm -e <package name>
      • rpm -e oracle-xe-11.2.0-1.0.x86_64
    • Check the following files to makes ure oracle-xe was really uninstalled:
      • rm -Rf /usr/lib/oracle/xe
      • rm -Rf /etc/oratab
      • rm -Rf /etc/init.d/oracle-xe
      • rm -Rf /etc/sysconfig/oracle-xe
    • Installed oracle rpm again, configured, and now was able to access the DB from my host with sqlDeveloper
For more examples and ideas, I encourage you explore the links provided throughout this blog. What questions do you have about this post? Let me know in the comments section below, and I will answer each one.

1 comment:

I appreciate your time in leaving a comment!