Sunday, December 11, 2011

Hostname changed and tnsping not working for Oracle Database server

Let's assume we have Oracle Database server installed on our machine. For some reasons, we had to change the hostname of the machine on which the Oracle db server is installed.

In that case , the tnsping stops working (host1 has been changed to host2 ).

C:\Documents and Settings\amit.upadhyay>tnsping ams

TNS Ping Utility for 32-bit Windows: Version 11.1.0.6.0 - Production on 11-DEC-2
011 17:28:54

Copyright (c) 1997, 2007, Oracle. All rights reserved.

Used parameter files:
C:\app\amit.upadhyay\product\11.1.0\db_1\network\admin\sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = HOST1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_N
AME = AMS)))
TNS-12545: Connect failed because target host or object does not exist

We come to know that tnsnames.ora has to be changed and we go and change it to host2 but now we get the following error -

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = HOST2)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_N
AME = AMS)))
TNS-12541: TNS:no listener

This means the listener has not started but when we try to start from services , it shows getting started but it doesn't really start. So, to see what is the actual error , open command prompt and go to the location where LSNRCTL.EXE is present -
C:\app\amit.upadhyay\product\11.1.0\db_1\BIN

Type LSNRCTL.EXE

C:\app\amit.upadhyay\product\11.1.0\db_1\BIN>LSNRCTL.EXE

LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 - Production on 11-DEC-2011 17:53
:58

Copyright (c) 1991, 2007, Oracle. All rights reserved.

Welcome to LSNRCTL, type "help" for information.

LSNRCTL>

Enter Start and we will get some error which will point to the actual issue -

LSNRCTL> start
Starting tnslsnr: please wait...

TNSLSNR for 32-bit Windows: Version 11.1.0.6.0 - Production
System parameter file is C:\app\amit.upadhyay\product\11.1.0\db_1\network\admin
listener.ora
Log messages written to c:\app\amit.upadhyay\diag\tnslsnr\inmuml0087\listener\a
ert\log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC152
ipc)))
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=HOST1)(PORT=1521)))
TNS-12545: Connect failed because target host or object does not exist
TNS-12560: TNS:protocol adapter error
TNS-00515: Connect failed because target host or object does not exist
32-bit Windows Error: 1001: Unknown error

Listener failed to start. See the error message(s) above...


It points to listener.ora and when we go and modify the host in this file ( host1 to host2 ) and then try perform start , the tns listener starts successfully.

LSNRCTL can be used from command prompt to debug any issues related to tns listener not starting.





No comments:

Post a Comment