recent

Titulo

TNSPING Utility

TNSPING is an Oracle utility to determine if the listener for a service on an oracle network can be reached successfully. This utility is located on ORACLE_HOME/bin directory. Oracle Client should be installed to use this utility not Oracle database. This only tests if the listener for a given service name is up or not. This does not report back the database status.

TNSPING Syntax:
tnsping  <net service name> <count>
The net service name is found on tnsnames.ora, the count is the number of times you want test your connections.
>tnsping ora.dbarepublic.com
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 10-APR-2
017 13:57:31

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

Used parameter files:
C:\Oracle\product\11.2.0\client_1\network\admin\sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora_linux.dbarepublic.com)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ora_db.dbarepublic.com)))
OK (90 msec)
>tnsping oracl_db.dbarepublic.com 10
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 10-APR-2
017 14:09:38

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

Used parameter files:
C:\Oracle\product\11.2.0\client_1\network\admin\sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ora_linux.dbarepublic.com
1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = oracl_db.dbarepublic.com
)))
OK (10 msec)
OK (0 msec)
OK (20 msec)
OK (0 msec)
OK (10 msec)
OK (20 msec)
OK (0 msec)
OK (20 msec)
OK (0 msec)
OK (30 msec)
All the above examples showed the successful tnsping connection. There are cases where tnsping can or might fails. I am more interested in showing why it fails? and how you can make it works vs why it works. Off the top of my head, these are few reasons why tnsping fails
  1. Invalid syntax
  2. Wrong net service name
  3. Database host Server Down
  4. Listener Down.
Wrong net Service Name: See what happens when you enter invalid net service name.
C:\Users\dbarepublic>tnsping wrongservice

TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 10-APR-2
017 14:20:21

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

Used parameter files:
C:\Oracle\product\11.2.0\client_1\network\admin\sqlnet.ora

TNS-03505: Failed to resolve name
Solutions: find the correct service name. Where can you find the correct net service name? Go to C:\Oracle\product\11.2.0\client_1\network\admin and look for tnsnames.ora. It has the net service name that you need.
Example of TNSNAMES.ora
dbarepublic.example.com =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = myserver.example.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )
dbarepublic.example.com is the net service name that you need for tnsping. If you don't see the service name on tnsnames.ora, your tnsping won't work. The net service name must exist in the tnsnames.ora file. This file is used by client and database servers to identify server destination. The net service name used was wrong, now you now the correct name from tnsnames.ora file. Your tnsping is still erroring out even if the service name is correct. First, I will check to see if the database host, this is where you database is installed is up and working. How do you check that?
ping  or ip-address
ping myserver.example.com: 
This will tell you weather the host service is up and running, if this is not, you can contact system administrators managing these servers. After few phone calls and a ticket to system admin, the server is up and working.

Now, you are getting TNS-12541: TNS: no listener which means the listener is either not configured right or it is down. To resolve this you will need to ensure the the configuration on tnsnames.ora is correct and then check the status of listener using lnsrctl status. By now, you must have corrected the issue. Alternately, this utility is also used in confirming to ensure the oracle names service is running as well.

Interested in working with me? I can be reached at pbaniya04[at]gmail.com for any questions, consulting opportunities or you may drop a line to say HELLO. Thank your again for visiting my blog and looking forward to serving you more.

Have a Database-ious Day!

No comments

Powered by Blogger.