Skip to Main Content
  • Questions
  • Changing Hostname, IP address, DNA Name for the database

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Sangjukta.

Asked: April 10, 2017 - 6:40 am UTC

Last updated: April 22, 2017 - 1:58 am UTC

Version: 11.2.0.4

Viewed 50K+ times! This question is

You Asked

We have an Oracle 11.2.0.4 database with ASM storage. The linux version is OEL 7.0.
Recently, the clients are having changes to Host Name, IP Address, DNS Name. We have to update the same for the database.

Below is the list we have made, where we have to make the changes.
[ Kindly advise if I am missing something. If there is something else we need to update?? Also, please let me know if we should shutdown the database before we start making the below changes??? Or we can make the changes when the database is running?? ]

1. Change the IP address and hostname in "/etc/hosts" file.
2. Change the hostname in "/etc/sysconfig/network " file.
3. Change the hostname in "/etc/hostname" file.
4. For configuring network in the VM, we have to update the IP Address and DNS Names in the network configuration window.
5. For database global name :
SQL> ALTER DATABASE RENAME GLOBAL_NAME TO <New_Global_Name> ;
Do we need to shutdown the database before making the above change?? Or we can run the query when the database is running and the change will reflect correctly?? Please advise.
6. Query for db_domain and service_names and check:
Can set as below if not showing the correct one :
SQL> alter system set db_domain='<new_domain_name>' scope=spfile;
Restart the database.
7. Update the "tnsnames.ora" file with the new HOST & SERVICE_NAME.
8. Stop the listener and update the "listener.ora" file with the new HOST. Restart the listener.
9. We have 2 check the db_links, but since the global_names parameter is set to "false", db_links should work fine.
SQL> show parameter global_names;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
global_names boolean FALSE

--------------------------------------------------------------------------------------------------------------------
Also, the view "DBA_REGISTERED_SNAPSHOTS" has the below value for our database. Please let us know if we have to update the below or we can leave them as it is. If yes, then kindly advise how to update the below with the new global_database_name ????

SQL> select name, owner, SNAPSHOT_SITE from DBA_REGISTERED_SNAPSHOTS;

NAME OWNER SNAPSHOT_SITE
--------------------------------------------------------------------------------------------------------------------
MGMT_ECM_MD_ALL_TBL_COLUMNS SYSMAN <current_global_database_name>
COST_OBJECT_HIERARCHY_MV TSF_DIM <current_global_database_name>
CURRENCY_MV TSF_DIM <current_global_database_name>

Are there any other thing we need to take care of for these change to work perfectly?? Kindly advise.

and Connor said...

If you have CRS (grid) installed, or Oracle Restart, then please check MOS note 1059776.1 as things can get complicated in that scenario. But generally, these involves stopping/disabling facilities, then changing the hostname, then re-enabling them afterwards

A few other things to consider

- if you have EM console installed, then deconfigure it before the rename, and reconfigure it afterwards

emca -deconfig dbcontrol db -repos drop
emca -config dbcontrol db -repos create

- dont forget your password files/spfiles/pfiles

- look for any folders created on the db server with the old hostname in the name, and rename accordingly

- check sqlnet.ora, tnsnames.ora for old hostnames


The database must be open to rename the global name.

And finally....

TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST


Rating

  (5 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Thanks!

Sangjukta Dey, April 11, 2017 - 4:28 am UTC

Hello Connor,
Thank you so much for your response.
- We are not using RAC or Oracle Restart. But we are using ASM storage. Is there anything specific we need to take care of for ASM.
- Thank you for the EM part.
- I have checked the pwd files/pfiles/spfile, but there are no mention of the hostname or any other parameter which includes the hostname. So we dont need to change anything there, right?
- Regarding the folders named as the old hostname : I could find one under ORACLE_HOME. The folder has the below within it :
-rw-r-----. 1 oracle oinstall 54 Dec 15 21:30 oraInst.loc
drwxr-----. 7 oracle oinstall 85 Dec 15 21:30 sysman
-rw-r-----. 1 oracle oinstall 6 Mar 21 16:06 emctl.pid

Can we simply rename the folder after changing the hostname?? Or it will have some impact? If yes, then how to take care of it. Kindly advise.

Also, found a log under 'ORACLE_HOME/install' named as "root_<current_hostname>_2016-08-30_03-31-25.log". But we donot have to worry about this, right??

Thanks once again for your time and patience. I am bit new to this, hence have many confusions.
Connor McDonald
April 12, 2017 - 1:26 am UTC

"I have checked the pwd files/pfiles/spfile, but there are no mention of the hostname or any other parameter which includes the hostname. So we dont need to change anything there, right? "

The names of the files themselves may need to change (if you are changing the database name as well)

Renaming the folder should be ok, and the log file you dont need to worrry about

Correction on my last followup post

Sangjukta Dey, April 11, 2017 - 7:59 am UTC

Hello Connon,

Apologies for one wrong info. spfile & pfile have db_domain as the previous one. SO I guess we have to change that as below :
SQL> alter system set db_domain='<new_domain_name>' scope=spfile;
And then restart the database.
For pfile, we will edit it manually.

Also, for service_names, we can update as below :
SQL> alter system set service_names=<> scope=both;

Kindly let me know if I am wrong.

I am not able to add comments for this question, hence keeping on adding reviews. Apologies for that.
Connor McDonald
April 12, 2017 - 1:38 am UTC

Yes, but for me, I'm not a huge fan of changing "old" to "new" (or vice versa) and having a temporary conflict, eg

old is running and you change some param/cofig to new, OR
new is running and you still have some old param in there

So my inclination would be:

- create pfile old.ora from spile
- shutdown db
- edit pfile to have new entries (call it new.ora)
- startup pfile=new.ora
- create spfile from pfile

but that might be just my paranoia :-)

Followup on the linux level changes.

Sangjukta Dey, April 21, 2017 - 6:26 am UTC

Hello Connor,

Thanks a lot for this, I will follow this approach of updating the spfile.
Our TEST db is running on pfile and there is no spfile as of now, So I can directly update the pfile and create an spfile from pfile. Then restart the db with the newly created spfile and everything should be fine, right?

Also, regarding the linux level changes, we have Oracle linux 7.0. There is no linux admin available. So we have to make the linux level changes.
I have updated the steps as below :
- As 'root', update hostname as below :
# hostname <new_hostname>
- Change the IP address and hostname in "/etc/hosts" file.
-Change the hostname in "/etc/sysconfig/network " file.
-Change the hostname in "/etc/hostname" file.
- # service network restart
-For configuring network in the VM, we have to update the IP Address and DNS Names in the network configuration window.

- Do i have to update the below or it will be automatically updated???
# cd /etc/sysconfig/network-scripts
# ls
# cat ifcfg-eno16780032
# vi ifcfg-eno16780032

- Also, do i need to update below as well or it will be automatically updated after a network restart??
# sysctl kernel.hostname=NEW_HOSTNAME

- Also, should I restart the network as "# service network restart" after all the database level changes are done OR it doesnot matter??? I can connect to database from "sqlplus / as sysdba" after restarting the network and it will not matter??

- Also, after all Linux level changes, do I have to restart the VM?? If yes, then should I do it after updating the database domain, service_name, pfile, spfile as well, and shutting the db down?? And then restart the VM and startup database???

As I am new to this, I have many confusions. Kindly be patient. Thanks for all your time.
Connor McDonald
April 22, 2017 - 1:55 am UTC

My plan of attack (and I stress...I'm not a Linux admin) would be:

- prepare db for change (eg make a pfile from spfile)
- shut all database services (db, listener, asm, etc etc)
- then make OS level changes
- then make DB config level changes (edit pfile, change directory names etc)
- start database services

so that there isnt a period of "conflict", ie, the database being up thinking the hostname is "X" when you've changed it at the OS level to "Y" etc.

This is an addition to my last question.

Sangjukta Dey, April 21, 2017 - 11:51 am UTC

Hello Connor,

Our database is using ASM storage. Do we need to carry out any specific steps for ASM to work fine after hostname and IP address change?? Kindly advise.
Connor McDonald
April 22, 2017 - 1:58 am UTC

If you running the grid software to manage ASM, take a look here

https://www.pythian.com/blog/changing-hostnames-in-oracle-rac/

and

https://oradbn.wordpress.com/2013/09/17/oracle-restart-12c-how-to-change-hostname/

for a list of things to consider

Follow up query

S D, April 24, 2017 - 7:04 am UTC

Hello Connor,

Thank you once again for your patience and guidance.

The link provided mentions steps for RAC. But we donot have RAC or Oracle Restart. We are using only ASM storage for our database. In that case, do we need to carry out these steps, for e.g., deconfiguring ASM and reconfiguring it,etc ??
Kindly advise.