Saturday 25 May 2024

New Ping command in Oracle 23ai database

 Oracle 23ai offers a very useful command Ping. Lets go deep and understand what it is :


Firstly to make the confusion clear it is just like tnsping, so if you want to test connectivity and see the network reachability for listener, database and so on this is very helpful. As per Oracle officially ping utility : Pings the database or database network listener to check availability. The PING command will fail with an error if either the database or the network listener are unavailable. It indicates that either the network listener or the database needs to be restarted, or that the database connection is not usable and needs to be recreated.

When the PING command is executed without a connect identifier, then a round-trip message is sent through the network listener to the currently connected database. When it is executed with a connect identifier, then a round-trip message is sent to the specified network listener to verify if it is able to handle the database connections.

When i fired just ping it did this to me :

SQL> ping
Ok (1.398 msec)

So it tests the current connection reachability.

Now when i give a wrong name which means i dont have an entry in respective tnsnames.ora it hangs for a moment for obvious reasons and returns this info :

SQL> ping a
>> Hangs here for a while (few seconds)

SP2-1679: Connect identifier (a) was not found.
Help: https://docs.oracle.com/error-help/db/sp2-1679/
Cause:  Connect identifier passed was not found in tnsnames.ora.
Action: Check the connect identifier used in the PING command.

Now lets try to actually ping something whose entry exists in the tnsnames.ora i.e :

SQL> ping FREEPDB1
Local Net Naming configuration file: /opt/oracle/product/23ai/dbhomeFree/network/admin/tnsnames.ora
Attempting to contact: (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = FREEPDB1)))
Ok (20.312 msec)


SQL> !cat /opt/oracle/product/23ai/dbhomeFree/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/23ai/dbhomeFree/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

FREE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = FREE)
    )
  )

LISTENER_FREE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


FREEPDB1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = FREEPDB1)
    )
  )

#Happy learning, thanks



No comments:

Post a Comment