13

How do I have to install tnsping? I tried to install oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm and I'm able to use some client commands but nog tnsping.

DenCowboy
  • 13,884
  • 38
  • 114
  • 210
  • 5
    For some unknown reason Oracle refuses to add tnsping into instant client package. There were some HOWTOs in Internet how to copy this utility from "thick" client installation into InstantClient directory. – ibre5041 Sep 29 '16 at 13:20

4 Answers4

11

Oracle Instance Client does not include tsnping application. You must run "Oracle Universal Installer" and enable the option for it.

I don't' remember exactly which option you have to set, either it was "Oracle Database Utilities" or "Oracle Net"

enter image description here

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
7

Also see McTnsping [link broken] "a Windows stand-alone program which requires no Oracle client". It's portable and doesn't need to be installed.

Usage 1: McTnsping.exe { <tns entry> | <host>:<port> } [<count>]

<tns entry>    the net service name in the tnsnames.ora file.
<host>:<port>  server name or IP and port (mandatory)
<count>        number of times to check target, default is 1.
matt wilkie
  • 17,268
  • 24
  • 80
  • 115
  • That link no longer works. This appears to be the source to McTnsping http://www.orafaq.com/wiki/images/1/13/McTnsping.zip – TrojanName Jan 31 '23 at 17:31
  • @TrojanName firefox gives a security warning with that url due to mixed http and https. Combine that with your nick and... Hmmmm. ;-) Changing the url to https and there's no warning. (Onlookers: Virustotal is happy with the file: https://www.virustotal.com/gui/url/1ffa25798049c1eeb50663334542f5b07510ff7b520f7107b0b18b9d48beb6fd .) – matt wilkie Feb 02 '23 at 12:30
  • 1
    Haha, my motives are innocent, I swear! Any true Oracle user would know to trust OraFAQ.com ;-) Thanks for correcting. – TrojanName Feb 02 '23 at 12:54
5

If whoever will reach the place like me... This is what worked for me:

Instant client Version 12.2.0.1 + sqlplus + tnsping (copied from another server of the same version)

Directory structure and env (as in bash profile):

export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=${ORACLE_BASE}/instant_client122
export PATH=$ORACLE_HOME:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME #since all binaries are in $ORACLE_HOME - no bin or lib are present
export TNS_ADMIN=$ORACLE_HOME/network/admin

copy from another server to target:

'tnsping' to $ORACLE_HOME
'$ORACLE_HOME/network/mesg/tnsus.msb' to $ORACLE_HOME/network/mesg

Then put proper values to $TNS_ADMIN/tnsnames.ora and load env variables. After this it should be able to perform 'tnsping' and show proper message as a response.

st0ne_c0ld
  • 129
  • 1
  • 5
  • if you use LDAP instead of local tnsnames, then you need the $ORACLE_HOME/ldap/mesg folder as well – anilech Mar 08 '22 at 12:59
  • you also may want to remove old `$ORACLE_HOME/lib` path from the `tnsping` executable to make sure it doesn't hit the old libs: `strings -a -t d tnsping | awk 'NF==2 && $1 ~ /[[:digit:]]+/ && $2 ~ /^\/[[:print:]]+\/lib$/ {printf "0x%08X: %s\n",$1,$2; system("dd --help | grep -q notrunc && printf \"\\x00%.0s\" {1.."length($2)"} | dd of=tnsping bs=1 seek="$1" count="length($2)" conv=notrunc")}'`. Use `ldd tnsping` to check which libs it uses. – anilech Mar 28 '22 at 15:22
2

Here's what I did to copy tnsping over to another machine. In my case, the oracle client is installed at C:\Oracle\product\12.1.0\client_1.

This assumes there's already an Instant Client or similar installed on the destination machine; and that the oracle path and registry keys are set.

(1) Copy tnsping.exe from the source to the destination machine, into client_1\bin.

(2) Copy the following files from client_1\bin to client_1\bin:

oraasmclnt12.dll
oracell12.dll
oraclient12.dll
oraclsce12.dll
oracommon12.dll
oracore12.dll
orageneric12.dll
orahasgen12.dll
oraldapclnt12.dll
oran12.dll
orancds12.dll
orancrypt12.dll
oranhost12.dll
oranl12.dll
oranldap12.dll
oranls12.dll
oranro12.dll
orantcp12.dll
orantns12.dll
oraocr12.dll
oraocrb12.dll
oraocrutl12.dll
oraplp12.dll
orapls12.dll
ORASLAX12.DLL
orasnls12.dll
oraunls12.dll
orauts.dll
oravsn12.dll
oraxml12.dll
orazt12.dll
oraztkg12.dll 

This should be about 84.6 MB.

(3) In the client_1 on the destination machine, make a backup of the following files:

oci.dll
orannzsbb12.dll
oraons.dll
orasql12.dll
orawsec12.dll  

Now on the source machine, find those files in client_1\bin and copy them to client_1\ (no bin) on the destination machine, overwriting the existing files. (Note: oci.dll is ~330 kb smaller, orasql12.dll is ~300 kb smaller. I'm not sure what's lost, hence the backup).

(4) On the destination machine, create the directory mesg in client_1\Network. Now copy the following file from the source to the destination:

client_1\Network\mesg\tnsus.msb  

(5) Open up regedit. Create the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home1_32bit  

(From another machine, it looks like the x64 version is named HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home1, but the tnsping program I'm using says it's 64 bit, so ...)

Under the key, create a string named ORACLE_HOME with the value C:\Oracle\product\12.1.0\client_1.

You should be done now ($$$ = redacted):

C:\Users\$$$>tnsping $$$

TNS Ping Utility for 64-bit Windows: Version 12.1.0.2.0 - Production on 03-APR-2
019 08:47:37

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

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


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = $$$)(PORT = $$$))) (CONNECT_DATA = (SERVICE_NAME = $$$
$$$) (SERVER = DEDICATED)))
OK (30 msec)

Troubleshooting

Here's the process I followed, sharing for when these steps invariably fail to work on a later version.

First off, I just copied the tnsping.exe over.

I didn't haphazardly pick the above dlls, as far as I can tell everyone is required. I ran the exe, and it would popup an error, I would copy the dll over and try again:

missing from your computer

After a few dlls, you'll run into a different kind of error:

application unable to start

If that happens, fire up process monitor and put a filter in for the ProcessName to contain tnsping and try to run the program again. You should see something like the following. The main thing to notice is that it tries to load (in this example) orawsec12.dll, which succeeds, but then it continues to try to load the dll looking in different paths, and then at the end it triggers werfault and the program ends. I guess it realizes there's some kind of version mismatch and keeps looking for the right version.

application unable to start

The missing registry key will show up like the following in process monitor (operation RegOpenKey, result NAME NOT FOUND):

registry name not found

If the tnsus.msb file is missing, you should see something like the following in process monitor (operation CreateFile, result NAME NOT FOUND):

filesystem name not found

Community
  • 1
  • 1
BurnsBA
  • 4,347
  • 27
  • 39
  • The question seem to refer to Linux not Windows. – Wernfried Domscheit Jun 05 '19 at 10:07
  • 1
    @WernfriedDomscheit This page is one of the only search results for how to setup tnsping without the oracle client. The other answer mentions a windows binary, this is an alternative to that answer. – BurnsBA Jun 05 '19 at 13:13