How to install tnsping? - oracle

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.

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"

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.

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.

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:
After a few dlls, you'll run into a different kind of error:
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.
The missing registry key will show up like the following in process monitor (operation RegOpenKey, result 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):

Related

oracledb_exporter binary files

There is Prometheus Oracle database exporter https://github.com/iamseth/oracledb_exporter
Under Running section, "/path/to/binary -l log.level error -l web.listen-address 9161" is not clear me.
Here I am not getting what is "/path/to/binary" mean, is it oracle client or /usr/bin/ path, or which file I need to replace with? I have RHEL7.3
After setting DATA_SOURCE_NAME is set correctly and running below commman, its throwing error (no such cmd - /path/to/binary)
/path/to/binary -l log.level error -l web.listen-address 9161
Please refer ZIP/clone from location :-https://github.com/iamseth/oracledb_exporter
Oracle database exporter should start and fetch required values/status from oracle database.
In case you're still looking for the answer:
The easiest way is to download the pre-compiled version. Otherwise you will need to compile it yourself: https://github.com/iamseth/oracledb_exporter/releases
Download the version you want e.g. 'oracledb_exporter.0.2.2.linux-amd64.tar.gz' and unzip it.
You will get a folder 'oracledb_exporter.0.2.2.linux-amd64' which conatins two files:
default-metrics.toml
oracledb_exporter
The second one is the one you need to execute:
-> /path_to/oracledb_exporter.0.2.2.linux-amd64/oracledb_exporter log.level error web.listen-address 9161

DBD::Oracle: load_file:The specified module could not be found

It's a story as old as time itself. No, I'm not talking about the story of a man's wife running off with his best friend. I'm talking about getting DBD::Oracle to work. Although both stories have about the same amount of pain associated with them.
Let us start with the facts:
Running Windows 7 -64 bit
Running Strawberry Perl (v. 5.16.3 - 32 bit) (the reason we have 32 bit is because there is a module that is only 32 bit and we are stuck with it - don't ask)
Oracle Client (version 12.1.0 - 32 bit) successfully installed.
The bin directory of said Oracle Client has been included at the front of the PATH
the addition of the following environmental variables:
ORACLE_HOME - pointing to Oracle Client path
TNS_ADMIN -pointing to Oracle Client path
LD_LIBRARY_PATH - pointing to Oracle Client path
ORACLE_USER_ID - set to a valid oracle user in the form: user/pass#system:port\sid
ORACLE_SID - set to valid oracle sid
Successful connection of sqlplus to the desired database.
"Successful creation" of DBD::Oracle into Strawberry Perl using cpanm. Although I had to use --force because the tests failed.
An entry entered into tnsnames.ora, that I assume is correct:
nameIMadeUp.WORLD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = servername)(PORT = port#))
)
(CONNECT_DATA =
(SID = sid)
)
)
After all of that, we try to run this code (snipped for the sake of brevity):
use DBI;
use DBD::ODBC;
use Log4Perl;
#logger set up here.
my $user = "username";
my $passwd = "password";
my $DSN = "dbi:Oracle:host=servername;sid=sid;port=port#";
my $oracleDbh = DBI->connect($DSN,$user,$passwd) or $logger->logdie("$DBI::errstr\n at line:".__LINE__);
And we get this glorious error:
install_driver(Oracle) failed: Can't load 'C:/strawberry/perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified module could not be found at C:/strawberry/perl/lib/DynaLoader.pm line 190.
at (eval 84)[C:/strawberry/perl/vendor/lib/DBI.pm:770] line 3.
Compilation failed in require at (eval 84)[C:/strawberry/perl/vendor/lib/DBI.pm:770] line 3.
Perhaps a required shared library or dll isn't installed where expected
...stacktrace...
So, I have read that 'C:/strawberry/perl/site/lib/auto/DBD/Oracle/Oracle.dll' is looking for oci.dll which is causing the error. However oci.dll is in [oracle_client_path]/bin/. Theoretically, it should be able to find it.
Or is it looking for another dll? are there tools in windows or maybe even visual studio that can help here?
Or is there some magical step that I am missing?
I thank you in advance for any wise sage knowledge you put forth.
Apparently, a reboot was needed. After the reboot, connections through Perl were possible. This is here in case someone is as stupid as me. I'm going back my AS/400 now...

Turning off iODBC tracing

I'm using iODBC on OS X 10.6.8 agains MySQL (mysql-connector-odbc-5.1.8) from a C program that I'm writing, but tracing of all ODBC library calls, which is supposed to be turned off by default, is turned on.
I have found a set of odbc.ini and odbcinst.ini files in /etc and in /Library/ODBC/, but none of them contains "Trace = yes", and adding an [ODBC] section with "Tracing = no" to any of these files doesn't seem to do anything. I also do not have any private .odbc.ini or .odbcinst.ini files in the working directory nor in my home directory nor anywhere else.
The only way I can turn tracing off is to call SQLSetConnectAttr() to set SQL_ATTR_TRACE to SQL_OPT_TRACE_OFF after allocating a connection handle, but at that point, the trace file, sql.log, has already been created in the working directory.
Any help with tracking down where tracing is turned on (it's supposed to be off by default), alternatively, how to turn it off so that the log file never gets created, would be appreciated.
I'm not sure why you would be using odbc instead of the standard connector, but have you tried setting the option for the TraceFile to /dev/null in odbc.ini. This may at least remove the file if you can't get the Trace = OFF to work by itself.
[ODBC]
Trace = OFF
TraceFile = /dev/null
Don't have my Mac at the office to test this, but seems like it should work.
The default settings files for ODBC on Mac OS X are found at --
/Library/ODBC/odbc.ini
/Library/ODBC/odbcinst.ini
/Users/*/Library/ODBC/odbc.ini
/Users/*/Library/ODBC/odbcinst.ini
The first two are for system-level settings and DSNs; the latter are for user-level.
Some buggy installers and libraries create files at --
/Users/*/.odbc.ini
/Users/*/.odbcinst.ini
/etc[/*]/.odbc.ini
/etc[/*]/.odbcinst.ini
/etc[/*]/odbc.ini
/etc[/*]/odbcinst.ini
These can lead to trouble. This command will reveal all potentially trouble-making files --
sudo find / \( -name '.odbc*.ini' -or -name 'odbc*.ini' \) -ls
Best is to --
blend the content of existing non-default files into the default locations, and drop the non-default files
create symlinks from the buggy .odbc[inst].ini locations to the default files
update the iODBC components on your Mac
enjoy trouble free ODBC use
(ObDisclaimer: I am an employee of OpenLink Software, who maintain and support the iODBC project, which is the ODBC Driver Manager chosen by Apple for Mac OS X, bundled since Jaguar (10.2.x).)

VS2010 DB Project Deploy Error SQL01268 Directory Lookup Failed

My VS2010 database deploy is failing on my build server, which has SQL Server 2008 R2 installed on it. Here's the output that's relevant:
Creating Acme.Database...
D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0): Error SQL01268: .Net SqlClient Data Provider: Msg 5133, Level 16, State 1, Line 1 Directory lookup for the file "C:\Program Files\Microsoft SQL Server**MSSQL10.MSSQLSERVER**\MSSQL\DATA\Acme_Database_log.ldf" failed with the operating system error 3(The system cannot find the path specified.).
D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0): Error SQL01268: .Net SqlClient Data Provider: Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
An error occurred while the batch was being executed.
The actual path is here:
C:\Program Files\Microsoft SQL Server**MSSQL10_50.MSSQLSERVER**\MSSQL\DATA\Acme_Database.mdf
The only reference to the path I could find in the database project was in the root folder, a file called:
PRIMARY.Acme_Database.sqlfile.sql
It includes an ALTER DATABASE statement that I changed to use the _50 path, but this did not fix the issue.
I'm not sure why the db project needs to know where the actual database MDF file is located in any case - I would have thought it could just connect to it vis TSQL, but in any case I can't get the project to deploy with this error and would appreciate any help.
Turns out if you specify a "file" in Schema Objects\Database Level Objects\Storage\Files (use Add Item, File) the values specified in the path override those looked up from the Server. If you must specify them use the variables from sqlcmdvariables $(DefaultdataPath)$(Databasename) to fill things out.
Take a look at the default file path on the server itself.
Screencast: http://screencast.com/t/OWM5ODFjZj
The fact that you don't have a path specified could likely be the issue.
[Update]
The reason I suggest this is that during the creation of the deployment script, if you have not specified the settings in the Project Settings -> Deployment tab, the DefaultDataPath is looked up from the target server's path.
I don't know anything about TeamCity really so this may be a stupid question, but how are you doing the deployment? It looks like the MSBuild deploy task for a DB project can take a property that gives the data path:
http://www.codewrecks.com/blog/index.php/2009/10/06/deploy-a-database-project-with-tfs-build/
Can you set the path that way?
I had the same error, but a different solution.
For me everything was correct (as far as I can tell), but the generated deploy script set the path variables before the databasename variable - resulting in a reference to a variable that did not exist. I updated Database.sqlcmdvars to hardcode the database name value - not best practice, but a sufficient workaround for my needs.

clsql connect oracle database

I am doing some practice with clsql. I want to connect my oracle server hence my connection function is;
(connect '("192.168.2.3" "xe" "username" "password") :database-type :oracle)
when i hit the return, the following error message shows up.
Couldn't load foreign libraries "libclntsh", "oci". (searched *FOREIGN-LIBRARY-SEARCH-PATHS*)
[Condition of type SIMPLE-ERROR]
I have already installed oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm
and define export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib
So, what else should I do to connect the server?
I was playing with oracle lately and found out that all you need is to put path to libclntsh into /etc/ld.conf.d/oracle.conf
My setup was following( redhat,centos - as root): downloaded from oracle
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
install via rpm -ivh oracle*.rpm
Create file /etc/ld.so.conf.d/oracle.conf:
/usr/lib/oracle/12.1/client64/lib
then execute ldconfig
Now as clsql-oracle is not in quicklisp, I downloaded and extracted clsql-6.6.2, then
(require "asdf")
(push #P"/opt/jeff/clsql-6.6.2/" asdf:*central-registry*)
(asdf:load-system :clsql-oracle)
(defparameter *some-db* (connect '("127.0.0.1:1521/db1" "SOME_USER_RO" "*******") :database-type :oracle))
and voila, it works
One thing that trips me up with dynamic linking to the Oracle libs (in C/C++ that is), is the fact that the libclntsh.so shared object comes with the version after the so name. So you may need to create a soft link in the same directory, ensuring that the soft link name is just libclntsh.so

Resources