Installing Oracle Instantclient on Linux Without Setting Environment Variables

installing Oracle Instantclient on Linux without setting environment variables?

Oracle's instantclient installation instructions specify that the user set LD_LIBRARY_PATH. This is very troublesome to manage for multiple users.

To use the instantclient without setting any environment variables:

Download the instantclient distribution from oracle.com. For doing non-java software development, you will need (assuming Oracle 10.2):

instantclient-basic-linux-x86_64-10.2.0.4.0.zip
instantclient-sdk-linux-x86_64-10.2.0.4.0.zip
instantclient-sqlplus-linux-x86_64-10.2.0.4.0.zip

Unzip the three files. This will give you a directory

instantclient_10_2/

Copy the files to /usr, which is one of the default places the dynamic loader searches.

sudo cp instantclient_10_2/sdk/include/*.h /usr/include
sudo cp instantclient_10_2/sqlplus /usr/bin
sudo cp instantclient_10_2/*.so* /usr/lib

If you use tnsnames.ora, copy it to /etc, which is the default global place the oracle runtime searches.

sudo cp tnsnames.ora /etc

Test with

/usr/bin/sqlplus scott/tiger@myoracle

installing Oracle Instantclient on Mac OS/X without setting environment variables?

Oracle's instantclient installation instructions specify that the user set DYLD_LIBRARY_PATH. This is very troublesome to manage for multiple users.

To use the instantclient without setting any environment variables:

Download the instantclient distribution from oracle.com. For doing non-java software development, you will need (assuming Oracle 10.2):

instantclient-basic-macosx-10.2.0.4.0.zip
instantclient-sdk-macosx-10.2.0.4.0.zip
instantclient-sqlplus-macosx-10.2.0.4.0.zip

Unzip the three files. This will give you a directory

instantclient_10_2/

Copy the files to /usr, which is one of the default places the dynamic loader searches.

sudo cp instantclient_10_2/sdk/include/*.h /usr/include
sudo cp instantclient_10_2/sqlplus /usr/bin
sudo cp instantclient_10_2/*.dylib /usr/lib

If you use tnsnames.ora, copy it to /etc, which is the default global place the oracle runtime searches.

sudo cp tnsnames.ora /etc

Test with

/usr/bin/sqlplus scott/tiger@myoracle

JupyterHub Oracle InstantClient and cx_Oracle installation

I solved the problem finally by creating a new JupyterHub environment by customizing the Dockerfile from https://github.com/jupyter/docker-stacks/blob/master/minimal-notebook/Dockerfile, and embedded it as new "Minimal Oracle environment" in JupyterHub.

The custom Dockerfile has following content (I only added the "cx_Oracle installation begin/end" part):

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/base-notebook
FROM $BASE_CONTAINER

LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>"

USER root

# Install all OS dependencies for fully functional notebook server
RUN apt-get update && apt-get install -yq --no-install-recommends \
build-essential \
vim-tiny \
git \
inkscape \
libsm6 \
libxext-dev \
libxrender1 \
lmodern \
netcat \
# ---- nbconvert dependencies ----
texlive-xetex \
texlive-fonts-recommended \
texlive-plain-generic \
# ----
tzdata \
unzip \
nano-tiny \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# cx_Oracle installation begin
WORKDIR /opt/oracle
RUN apt-get update && apt-get install -y libaio1 wget
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip && \
unzip instantclient-basiclite-linuxx64.zip && rm -f instantclient-basiclite-linuxx64.zip && \
cd /opt/oracle/instantclient* && rm -f *jdbc* *occi* *mysql* *README *jar uidrvci genezi adrci && \
echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
RUN python -m pip install cx_Oracle
WORKDIR $HOME
# cx_Oracle installation end

# Create alternative for nano -> nano-tiny
RUN update-alternatives --install /usr/bin/nano nano /bin/nano-tiny 10

# Switch back to jovyan to avoid accidental container runs as root
USER $NB_UID

After building the custom Dockerfile locally, and embedding it into the Kubernetes Cluster as "Minimal Oracle environment", I started a new Jupyter Notebook in the newly created JupyterHub environment, and tested the ORACLE connect as follows:

Sample Image

Install Oracle Client from command line without user-interaction

After some investigations I found out how to get the full command line options:

setup.exe -help

This works for version 11.2, 12.1 and 12.2. In version 18c and 19c this does work not anymore, instead you have to execute:

setup.exe -help -silent

Here the example output of an 18c setup:

Usage:  setup.exe [<flag>] [<option>]
Following are the possible flags:
-help - display help.
-silent - run in silent mode. The inputs can be a response file or a list of command line variable value pairs.
[-ignorePrereqFailure - ignore all prerequisite checks failures.]
[-lenientInstallMode - perform the best effort installation by automatically ignoring invalid data in input parameters.]
[-showProgress - show the installation progress on the console. This option is supported for silent mode installation only.]
-responseFile - specify the complete path of the response file to use.
-invPtrLoc - point to a different inventory location. The orainst.loc file contains the location of the central inventory (inventory_loc) and the inventory group (inst_group).
-jreLoc - specify the location for the jre used in the installation.
-logLevel - enable the log of messages up to the priority level provided in this argument. Valid options are: severe, warning, info, config, fine, finer, finest.
-paramFile - specify the location of the oraparam.ini file to be used in the installation.
-executePrereqs | -executeConfigTools | -deinstall
-executePrereqs - execute the prerequisite checks only.
-executeConfigTools - execute the config tools for an installed home.
[-all - execute all the config tools for an installed home, including the config tools that have already succeeded.]
-deinstall - uninstall the specified home.
-debug - run in debug mode.
-executeSysPrereqs - execute the system prerequisite checks and exit.
-ignoreSysPrereqs - ignore the results of the system prerequisite checks.
-printdiskusage - log the debug information for the disk usage.
-printmemory - log the debug information for the memory usage.
-printtime - log the debug information for the time usage.
-waitForCompletion - wait for the completion of the installation, instead of spawning the installer and returning the console prompt.
-suppressPreCopyScript - suppress the execution of the precopy script.
-acceptUntrustedCertificates - accept untrusted certificates from a secure site.
-suppressPostCopyScript - suppress the execution of the postcopy script.
-noconfig - do not execute the config tools.
-noconsole - suppress the display of messages in the console. The console is not allocated.
-ignoreInternalDriverError - ignore any internal driver errors.
-promptForPassword - provide the passwords on the console during a silent installation of an Oracle database.
-remotecp - specify the path to the remote copy program on the local cluster node. Used only for cluster installs.
-remoteshell - specify the path to the remote shell program on the local cluster node. Used only for cluster installs.

Finally I managed to run full setup with single command even without a Response file which can be executed by a software deployment system. Here are some examples (needs to be in a single line):

setup.exe -silent -nowait -ignoreSysPrereqs -ignorePrereq -waitforcompletion -force \
"INVENTORY_LOCATION=C:\Program Files\Oracle\Inventory" \
"ORACLE_BASE=c:\oracle\product" \
"ORACLE_HOME=c:\oracle\product\12.1\Client_x64" \
"SELECTED_LANGUAGES=de,en,fr,it" \
"oracle.install.IsBuiltInAccount=true" \
"oracle.install.client.installType=Custom" \
"oracle.install.client.customComponents=oracle.rdbms.util:12.1.0.2.0,oracle.sqlplus:12.1.0.2.0,oracle.odbc:12.1.0.2.0"

setup.exe -silent -nowait -ignoreSysPrereqs -ignorePrereqFailure -skipPrereqs -waitForCompletion -force \
"INVENTORY_LOCATION=C:\Program Files\Oracle\Inventory" \
"ORACLE_BASE=c:\oracle\product" \
"ORACLE_HOME=c:\oracle\product\12.2\Client_x64" \
"oracle.install.IsBuiltInAccount=true" \
"oracle.install.client.installType=Custom" \
"oracle.install.client.customComponents=oracle.rdbms.util:12.2.0.1.0,oracle.sqlplus:12.2.0.1.0,oracle.odbc:12.2.0.1.0"

setup.exe -silent -nowait -ignoreSysPrereqs -ignorePrereqFailure -waitForCompletion -force \
"ORACLE_BASE=c:\oracle\product" \
"ORACLE_HOME=c:\oracle\product\18c\Client_x86" \
"oracle.install.IsBuiltInAccount=true" \
"oracle.install.client.installType=Custom" \
"oracle.install.client.customComponents=oracle.rdbms.util:18.0.0.0.0,oracle.sqlplus:18.0.0.0.0,oracle.odbc:18.0.0.0.0"

Note, option -nowait is not mentioned in help but required to suppress prompt "Press ENTER to close the program".

Option -force is not mentioned in help of version 12.2 and newer but seems to be still valid to force installation in non-empty directory

Apparently 18c 32-bit installer does not like option "INVENTORY_LOCATION=C:\Program Files (x86)\Oracle\Inventory", skip this entry. Using "INVENTORY_LOCATION=C:\PROGRA~2\Oracle\Inventory" causes an exception for lock files in c:\Program Files (x86)\Oracle\Inventory\locks\

How to configure oracle instantclient for mono?

Use oracle easy connect naming method or create a tnsnames.ora yourself at the right location (check instant client docs for search order of locations).
tnsping is not part of instant client (or any add on package).

From the instant client faq
How do I ensure that my "tnsnames.ora" file is being used in Instant Client?
Always set the TNS_ADMIN environment variable or registry setting to the full path of the tnsnames.ora file. This practice will ensure that you are using the appropriate tnsnames.ora for your application when running with Instant Client.

How do I specify connection strings in Instant Client mode?
All Oracle net naming methods that do not require use of ORACLE_HOME or TNS_ADMIN (to locate configuration files such as tnsnames.ora or sqlnet.ora) work in the Instant Client mode. In particular, the connect string can be specified in the following formats:

A SQL Connect URL string of the form:

//host:[port][/service name]

such as:

//dbase-server-5:4321/ORDERS

As an Oracle Net keyword-value pair. For example:

"(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp) (HOST=dlsun242)
(PORT=5521))
(CONNECT_DATA=(SERVICE_NAME=bjava21)))"

Naming methods that require TNS_ADMIN to locate configuration files continue to work if the TNS_ADMIN environment variable is set.

If the TNS_ADMIN environment variable is not set, and TNSNAMES entries such as inst1, and so on, are used, then the ORACLE_HOME variable must be set, and the configuration files are expected to be in the $ORACLE_HOME/network/admin directory.

Please note that the ORACLE_HOME variable in this case is only used for locating Oracle Net configuration files, and no other component of Client Code Library (OCI, NLS, and so on) uses the value of ORACLE_HOME.

The bequeath adapter or the empty connect strings are not supported. However, an alternate way to use the empty connect string is to set the TWO_TASK environment variable on UNIX, or the LOCAL variable on Windows, to either a tnsnames.ora entry or an Oracle Net keyword-value pair. If TWO_TASK or LOCAL is set to a tnsnames.ora entry, then the tnsnames.ora file must be able to be loaded by TNS_ADMIN or ORACLE_HOME setting.

Oracle instantclient DYLD_LIBRARY_PATH error

I had a similar problem when I first installed Instant Client on Mac OS/X.

I found the following blog:

http://blog.caseylucas.com/2013/03/03/oracle-sqlplus-and-instant-client-on-mac-osx-without-dyld_library_path/

Hopefully it will work for you, too.



Related Topics



Leave a reply



Submit