Scott Van Vliet

Less Talk, More Rock

How-to: Change Windows Hostname and Keep Oracle 10g Running

So I realize it seems like I'm posting a bunch of stuff on Oracle and little on .NET, but it's all related to a large Smart Client application we're developing for our client, using Oracle 10g; thus, it's relative J

In a geographically-diverse team structure, it can be quite difficult to manage the development environment used by each team member (especially when you have little control over the workstation configuration of your offshore team.) Thus, for many of our engagements we heavily leverage virtualization – specifically Virtual PC 2007 – to help minimize the cost of environment setup and configuration.

One of the challenges we've faced with leveraging Virtual PC, specifically a shared image, is the unique naming of virtual machines. Now, in many cases it is acceptable to keep the virtual machine name the same across developer environments; however, for our purposes, unique machine names are required based on the following:

  • TFS Workspace names rely on machine name for unique naming (in combination with username)
  • Using our host VPN connection and Internet Connection Sharing (ICS), we provide our guest VPN access; although through NAT, the machine name (NetBIOS) still passes through when accessing corporate network resources, thus causing issues with the same
  • When using local network access directly on the guest, name conflicts occur; furthermore, two guest machines have issues accessing each other due to similar NetBIOS naming issues as outlined above (we often communicate guest-to-guest from different developer environments)

For all intents and purposes, this is a trivial matter. However, when dealing with Oracle, reliance on the installation-time hostname – at least from my experience and research – is critical. Thus, changing the hostname can cause problems.

Consequently, we've learned to deal with this process by following the steps outlined below.

Step 1 – Create Hosts Entry for Old Hostname

Locate your hosts file, typically located at %WINDIR%\system32\drivers\etc\hosts and add an entry for the old (current) hostname.

#
# HOSTS file
#

win2k3r2    172.16.10.10


Note the IP address – this is the address of a Loopback Adapter installed on the guest machine. As outlined by the Oracle Installer, a Loopback Adapter is required on systems that do not have a static IP address (as do virtual machines using NAT, etc.)

Step 2 – Uninstall Enterprise Manager Console

Because there are configuration settings stored with Enterprise Manager Console that reference the hostname, the same must be uninstalled.

emca -deconfig dbcontrol db -repos drop


Note, before executing this command, ensure that the Oracle instance is running – it has to be in order for Enterprise Manager Configuration Assistance to drop the repository and de-configure the Console.

Step 3 – Stop All Oracle Services

Once the uninstall of Enterprise Manage Console has completed, stop all Oracle Services on the guest machine.

  • iSQL*Plus Service – typically named Oracle<OracleHomeName>iSQL*Plus
  • Oracle Listener Service – typically named Oracle<OracleHomeName>TNSListener
  • Oracle Database Instance Service – typically named OracleServer<SID>

Step 4 – Update listener.ora and tnsnames.ora

Once all the Oracle services have stopped, update the listener.ora and tnsnames.ora files, located in %ORACLE_HOME%\network\admin to reflect the desired (new) hostname.

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = win2k3r2)(PORT = 1521))
)
)

DEVBOX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = win2k3r2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = devbox)
)
)

Step 5 – Rename Host and Restart

Now, rename the computer and restart the guest machine.

Step 6 – Ensure Oracle Instance is Running

Once the guest machine has started up, log in and ensure the Oracle instance is running using the following command line (typically required, unless the instance, not the Windows Service, is configured to auto-start.)

oradim -startup –sid devbox

Step 7 – Reinstall Enterprise Manager Console

After ensuring the Oracle instance is running, reinstall Enterprise Manager Console using the following command line:

emca -config dbcontrol db -repos create

Step 8 – Validate Enterprise Manager Console Installation

Lastly, after the successful installation of Enterprise Manager Console, validate the installation by navigating to the logon page – typically http://<hostname>:1158/em/.

At this point, you should be crankin' away with your Oracle instance running as it should! We spent a lot of time working on this issue, so hopefully this post helps you out in some way – I wished there was an article like this when I was scouring OTN with no results!

Thanks to Mike Huffine for the initial pointers.

Comments

Syn said:

Exactly what i was looking for!

Great short and direct Howto!

Easy and works!

Great work!

Thanks a lot!

# July 7, 2007 6:29 PM

Humberto Rodriguez said:

It is good, the only missing part on Windows is to rermove the service manually, the "emca -deconfig dbcontrol db -repos drop" doesn't remove it.

# July 13, 2007 9:03 PM

Anders Jax said:

Had already changed the hosts ip-address and thr em would not work. The host name was the ol ip. But hallrluja This solved the problem.

Thanks a lot

/ajax

# July 19, 2007 6:23 PM

Deepak Singh Rawat said:

Really helped a lot.

Thankx :)

# July 23, 2007 11:13 AM

Dennis said:

Wow, exactly what i was looking for. Thank you very much :-)

# August 16, 2007 10:15 AM

Gustavo Córdova Avila said:

Wow, actually I was looking for a way to script

the start and stop of an instance, and found it

here; thanks!!

-gca

# August 23, 2007 12:38 PM

Maximiliano Farias said:

To remove the service, reboot windows before STEP 7.

(windows load services only when it boot). If you don´t  do this, step 7 fails when try to create the service with the same name.

Thanks a lot for this info!

# August 28, 2007 8:53 PM

Kade said:

thanks very much.

that was a great help

# September 18, 2007 7:29 PM

DRASTANT said:

This is a very good article will guide many beginers on there jobs and projects

Thanks to the posters

# September 25, 2007 4:32 AM

BOFH said:

You can remove the windows service by using the sc command in a command prompt (just replace the SID name):

sc delete OracleDBConsole<SID>

# November 16, 2007 7:24 AM

dinesh singh said:

thanks for give me solution you Release my tention

thanks......................................

# November 24, 2007 4:40 AM

Kevin said:

Thanks this was very helpful.

Simple way to stop services if you want to everything by the command line.  I have a baseline VMWare machine and I need to reconfige each one.  This makes it easy.

net stop Oracle<OracleHomeName>iSQL*Plus

# December 1, 2007 6:51 PM

max said:

very useful, but uninstall didn't remove the EM repository... i did it by myself!!

thanks

max

# December 19, 2007 9:27 AM

CHaosMatrix said:

the version of emca that you are using, is that the one from 9i? Cause my emca tool requires different parameters....

# January 15, 2008 9:46 AM

Georide Hunter said:

Nice one Worked a treat....

# February 5, 2008 5:45 AM

Ziya said:

Supreb !!

# February 28, 2008 2:58 AM

Ming Man said:

Thank man, this works for 11g too. I am going to write a short article to link this from my blog ;-)

# April 16, 2008 10:20 AM

Chris Seeha said:

Coool - that is what I was looking for for so long. I´ve always been afraid of chaning names or addresses, but that solved my worries!

Thank you!

# April 28, 2008 12:21 PM

Ganesh said:

its good . but i want list of running oracle server on local network how to get that things please tell as simple as this.

thank you

# July 3, 2008 1:44 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)