Tuesday, May 29, 2012

Change HOST name


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.

CHANGE HOST NAME FOR 11G


4 people like this. Be the first of your friends.

One mistake can lead to a lot of work. When you’ve installed Oracle Database 11g, you can’t change the Windows Hostname without reinstalling Oracle Enterprise Manager.
These are the steps:
1. Change the %ORACLE_HOME%\network\admin\listener.ora file from an IP number to machine name.
2. Change the %ORACLE_HOME%\network\admin\tnsnames.ora file from an IP number to a machine name.
3. Change the C:\WINDOWS\System32\drivers\etc\hosts file by adding this line beneath the default localhost line (for the new Hostname value):
127.0.0.1       localhost
172.16.113.128  mclaughlin11g mclaughlin11g.techtinker.com
4. Change the Windows hostname by navigating: Start > Control Panel > System (classic view) from the random assignment of VMWare Fusion.
5. Reboot the machine, and then drop the em configuration with the following commands:
C:\Data> set ORACLE_SID=orcl
C:\Data> emca -deconfig dbcontrol db -repos drop
6. You’ll receive the following prompts, enter the Oracle SID and Port number without double quotes but you must enter all passwords with double quotes (at least in Oracle Database 11g):
STARTED EMCA at Jul 13, 2008 8:26:42 AM
EM Configuration Assistant, Version 11.1.0.5.0 Production
Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Enter the following information:
Database SID: orcl
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user:
Password for SYSMAN user:
Do you wish to continue? [yes(Y)/no(N)]: y
7. You should then drop the SYSMAN user manually because it doesn’t happen without your assistance (or, it didn’t happen when I did it). If you don’t drop the SYSMAN schema, you’ll raise an error when you try to recreate it:
CONFIG: ORA-20001: SYSMAN already EXISTS..
ORA-06512: at line 17

oracle.sysman.assistants.util.sqlEngine.SQLFatalErrorException: ORA-20001: SYSMAN already EXISTS..
ORA-06512: at line 17
The Java stack trace will look like this, more or less based on version and release:
at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeImpl(SQLEngine.java:1530)
at oracle.sysman.assistants.util.sqlEngine.SQLEngine.executeScript(SQLEngine.java:880)
at oracle.sysman.assistants.util.sqlEngine.SQLPlusEngine.executeScript(SQLPlusEngine.java
at oracle.sysman.assistants.util.sqlEngine.SQLPlusEngine.executeScript(SQLPlusEngine.java
at oracle.sysman.emcp.EMReposConfig.createRepository(EMReposConfig.java:492)
at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:218)
at oracle.sysman.emcp.EMReposConfig.invoke(EMReposConfig.java:147)
at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:222)
at oracle.sysman.emcp.EMConfigAssistant.invokeEMCA(EMConfigAssistant.java:535)
at oracle.sysman.emcp.EMConfigAssistant.performConfiguration(EMConfigAssistant.java:1215)
at oracle.sysman.emcp.EMConfigAssistant.statusMain(EMConfigAssistant.java:519)
at oracle.sysman.emcp.EMConfigAssistant.main(EMConfigAssistant.java:468)
Drop the user and dependent on version a few other objects, like:
DROP USER sysman CASCADE;
DROP PUBLIC SYNONYM setemviewusercontext;
DROP ROLE mgmt_user;
DROP PUBLIC SYNONYM mgmt_target_blackouts;
DROP USER mgmt_view;
8. You can then create the em environment with the following syntax:
C:\Data> emca -config dbcontrol db -repos create
9. Again, you’ll receive the following prompts, enter the Oracle SID and Port number without double quotes but you must enter all passwords with double quotes (at least in Oracle Database 11g):
STARTED EMCA at Jul 13, 2008 8:28:48 AM
EM Configuration Assistant, Version 11.1.0.5.0 Production
Copyright (c) 2003, 2005, Oracle.  ALL rights reserved.

Enter the following information:
DATABASE SID: orcl
Listener port NUMBER: 1521
Password FOR SYS USER:
Password FOR DBSNMP USER:
Password FOR SYSMAN USER:
Password FOR SYSMAN USER: Email address FOR notifications (optional):
Outgoing Mail (SMTP) server FOR notifications (optional):
-----------------------------------------------------------------

You have specified the following settings

DATABASE ORACLE_HOME ................ C:\app\Administrator\product\11.1.0\db_1

LOCAL hostname ................ mclaughlin11g
Listener port NUMBER ................ 1521
DATABASE SID ................ orcl
Email address FOR notifications ...............
Outgoing Mail (SMTP) server FOR notifications ...............

-----------------------------------------------------------------

Do you wish TO continue? [yes(Y)/no(N)]: y
A note to me, remember haste makes waste. I’m just glad that rebuilding the MarkLogic server was easy.

2 comments:

  1. Does db console have to be up and running when you execute
    emca -deconfig dbcontrol db -repos drop
    I do this and it executes but hangs (or seems like it takes over 2 hours before I kill it and manually delete files? Thanks.

    ReplyDelete
  2. emca -deconfig dbcontrol db -repos drop

    ReplyDelete