Tnsping Tips in Oracle

Hi,

I will explain Tnsping Tips in Oracle in this post.

 

 

Tnsping is an Oracle popular utility and used to check if a SQL*Net connection string can connect to listener and check if it is reachable.

You can check and test if the listener is available and up or not using this utility.

Tnsping utility is in the ORACLE HOME/bin directory

For example; there is a MSDB Tns alias in the tnsnames.ora under $ORACLE_HOME/network/admin on the Remote Server.

Tnsping utility is used as follows.

$ tnsping <TNS-ALIAS>

 

This TNS Alias and its description must exist in the tnsnames.ora file

 

I want to check if the listener is available and up using tnsping utility as follows.

 

[oracle@msdbadm01 ]$ tnsping MSDB

TNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 17-MAY-2020 05:29:07

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

Used parameter files:
/u01/app18c/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.63.34)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MSDB)))
OK (0 msec)
[oracle@msdbadm01 ]$

 

If you see OK (0 msec) message, then everything is fine and you can connect it.

 

You can use count parameter with the tnsping and it will show the number of times the command should try to connect to the  TNS alias.

 

[oracle@msdbadm01 ]$ tnsping MSDB 10

TNS Ping Utility for Linux: Version 18.0.0.0.0 - Production on 17-MAY-2020 05:29:07

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

Used parameter files:
/u01/app18c/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.63.34)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MSDB)))
OK (0 msec)
OK (10 msec)
OK (0 msec)
OK (0 msec)
OK (0 msec)
OK (0 msec)
OK (0 msec)
OK (0 msec)
OK (0 msec)
OK (0 msec)

[oracle@msdbadm01 ]$

 

 

If there is a problem with the remote server or remote listener, you can get the following errors during the tnsping test.

 

[oracle@msdbadm01 admin]$ tnsping MSDB

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-MAY-2020 13:02:57

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

Used parameter files:
/ggateb01/oracle_client/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 = 192.168.63.34)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MSDB)))
TNS-12535: TNS:operation timed out
[oracle@msdbadm01 admin]$



Or you can get the following error during the tnsping.

 

[oracle@msdbadm01 ~]$ tnsping MSDB

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-MAY-2020 16:46:20

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

Used parameter files:
/u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin/sqlnet.ora

TNS-03505: Failed to resolve name
[oracle@msdbadm01 ~]$

 

 

 

 

After fixing the  hostname and port in the tnsnames.ora, it will work fine as follows.

[oracle@msdbadm01 ~]$ tnsping MSDB

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 03-MAY-2020 16:46:22

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

Used parameter files:
/u01/app/oracle/product/12.1.0.2/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.63.34)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MSDB)))
OK (0 msec)
[oracle@msdbadm01 ~]$



 

Do you want to learn Oracle Database Performance Tuning detailed, then read the following articles.

Performance Tuning and SQL Tuning Tutorial in the Oracle Database

 

 512 views last month,  7 views today

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience. I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource. I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks. I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients. If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress mehmetsalih.deveci@outlook.com. -                                                                                                                                                                                                                                                 - Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  mehmetsalih.deveci@outlook.com a mail atabilirsiniz.

Leave a Reply