Site icon IT Tutorial

Tnsping Tips in Oracle

I will explain Tnsping Tips in Oracle in this post.

 

Tnsping Tips in Oracle

 

 

 

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 Command in Oracle

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 Click this link.
Exit mobile version