ODPI-C Installation

Overview

To use ODPI-C in your own project, download its source from GitHub. A sample Makefile is provided if you wish to build ODPI-C as a shared library. Otherwise, add the ODPI-C source code to your project. On Windows, Visual Studio 2008 or higher is required. On macOS, Xcode 6 or higher is required. On Linux, GCC 4.4 or higher is required.

Projects using ODPI-C require Oracle Client libraries to be installed. The libraries provide the necessary network connectivity allowing applications to access an Oracle Database instance. They also provide basic and advanced connection management and data features to ODPI-C applications.

The simplest Oracle Client is the free Oracle Instant Client. Only the “Basic” or “Basic Light” package is required. Oracle Client libraries are also available in any Oracle Database installation or full Oracle Client installation.

ODPI-C explicitly loads available Oracle Client libraries at runtime. This allows code using ODPI-C to be built only once, and then run using available Oracle Client 11.2, 12.1 or 12.2 libraries. On non-Windows platforms, if no Oracle Client is located in the standard operating system search page (e.g. LD_LIBRARY_PATH), then ORACLE_HOME is searched. If Oracle Client libraries are still not found, the error “DPI-1047: Oracle Client library cannot be loaded” is raised.

The following sections explain how to ensure the Oracle Client is installed and configured correctly on the various platforms so that ODPI-C is able to find it.

ODPI-C has been tested on Linux, Windows and macOS. Other platforms should also work but have not been tested.

Oracle Client and Database Versions

ODPI-C can use Oracle Client 11.2, 12.1 or 12.2 libraries.

Oracle’s standard client-server network interoperability allows connections between different versions of Oracle Client and Oracle Database. For certified configurations see Oracle Support’s Doc ID 207303.1. In summary, Oracle Client 12.2 can connect to Oracle Database 11.2 or greater. Oracle Client 12.1 can connect to Oracle Database 10.2 or greater. Oracle Client 11.2 can connect to Oracle Database 9.2 or greater. The technical restrictions on creating connections may be more flexible. For example Oracle Client 12.2 can successfully connect to Oracle Database 10.2.

Since a single ODPI-C binary can use multiple client versions and access multiple database versions, it is important your application is tested in your intended release environments. Newer Oracle clients support new features, such as the oraaccess.xml external configuration file available with 12.1 or later clients, and session pool enhancements to dead connection detection in 12.2 clients.

The function dpiContext_getClientVersion() can be used to determine which Oracle Client version is in use and the function dpiConn_getServerVersion() can be used to determine which Oracle Database version a connection is accessing. These can then be used to adjust application behavior accordingly. Attempts to use some Oracle features that are not supported by a particular client/server combination may result in runtime errors. These include:

  • when attempting to access attributes that are not supported by the current Oracle Client library you will get the error “ORA-24315: illegal attribute type”
  • when attempting to use implicit results with Oracle Client 11.2 against Oracle Database 12c you will get the error “ORA-29481: Implicit results cannot be returned to client”
  • when attempting to get array DML row counts with Oracle Client 11.2 you will get the error “DPI-1013: not supported”

Linux

ODPI-C requires Oracle Client libraries, which are found in Oracle Instant Client, or an Oracle Database installation, or in a full Oracle Client installation. The libraries must be either 32-bit or 64-bit, matching your application and ODPI-C library (if one is created separately).

On Linux, ODPI-C first searches for a library called “libclntsh.so” using the standard library search order. If this is not found, it will then search for “libclntsh.so.12.1” and then for “libclntsh.so.11.1” before returning an error.

Oracle Instant Client Zip

To run ODPI-C applications with Oracle Instant Client zip files:

  1. Download an Oracle 11.2, 12.1 or 12.2 “Basic” or “Basic Light” zip file: 64-bit or 32-bit, matching your application architecture.

  2. Unzip the package into a single directory that is accessible to your application. For example:

    1. mkdir -p /opt/oracle
    2. cd /opt/oracle
    3. unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
  3. Install the libaio package with sudo or as the root user. For example:

    1. sudo yum install libaio

    On some Linux distributions this package is called libaio1 instead.

  4. If there is no other Oracle software on the machine that will be impacted, permanently add Instant Client to the runtime link path. For example, with sudo or as the root user:

    1. sudo sh -c "echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf"
    2. sudo ldconfig

    Alternatively, set the environment variable LD_LIBRARY_PATH to the appropriate directory for the Instant Client version. For example:

    1. export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH
  5. If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml with Instant Client, then create a network/admin subdirectory. For example:

    1. mkdir -p /opt/oracle/instantclient_12_2/network/admin

    This is the default Oracle configuration directory for applications linked with this Instant Client.

    Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

Oracle Instant Client RPM

To run ODPI-C applications with Oracle Instant Client RPMs:

  1. Download an Oracle 11.2, 12.1 or 12.2 “Basic” or “Basic Light” RPM: 64-bit or 32-bit, matching your application architecture.

  2. Install the downloaded RPM with sudo or as the root user. For example:

    1. sudo yum install oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm

    Yum will automatically install required dependencies, such as libaio.

  3. If there is no other Oracle software on the machine that will be impacted, permanently add Instant Client to the runtime link path. For example, with sudo or as the root user:

    1. sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
    2. sudo ldconfig

    Alternatively, set the environment variable LD_LIBRARY_PATH to the appropriate directory for the Instant Client version. For example:

    1. export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib:$LD_LIBRARY_PATH
  4. If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml with Instant Client, then create a network/admin subdirectory under lib/. For example:

    1. sudo mkdir -p /usr/lib/oracle/12.2/client64/lib/network/admin

    This is the default Oracle configuration directory for applications linked with this Instant Client.

    Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

Local Database or Full Oracle Client

ODPI-C applications can use Oracle Client 11.2, 12.1 or 12.2 libraries from a local Oracle Database or full Oracle Client installation.

The libraries must be either 32-bit or 64-bit, matching your application and ODPI-C library (if one is created separately).

  1. Set required Oracle environment variables by running the Oracle environment script. For example:

    1. source /usr/local/bin/oraenv

    For Oracle Database XE, run:

    1. source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
  2. Optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml can be placed in $ORACLE_HOME/network/admin.

    Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

Windows

ODPI-C requires Oracle Client libraries, which are found in Oracle Instant Client, or an Oracle Database installation, or in a full Oracle Client installation. The libraries must be either 32-bit or 64-bit, matching your application and ODPI-C library (if one is created separately).

On Windows, ODPI-C searches for the Oracle Client library “OCI.dll” using the standard library search order.

Oracle Client libraries require the presence of the correct Visual Studio redistributable.

Oracle Instant Client Zip

To run ODPI-C applications with Oracle Instant Client zip files:

  1. Download an Oracle 11.2, 12.1 or 12.2 “Basic” or “Basic Light” zip file: 64-bit or 32-bit, matching your application architecture.

  2. Unzip the package into a single directory that is accessible to your application, for example C:\oracle\instantclient_12_2.

  3. Set the environment variable PATH to include the path that you created in step 2. For example, on Windows 7, update PATH in Control Panel -> System -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> PATH.

  4. If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml with Instant Client, then create a network\admin subdirectory, for example C:\oracle\instantclient_12_2\network\admin.

    This is the default Oracle configuration directory for applications linked with this Instant Client.

    Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

Local Database or Full Oracle Client

The Oracle libraries must be either 32-bit or 64-bit, matching your application and ODPI-C library (if one is created separately).

To run ODPI-C applications using client libraries from a local Oracle Database (or full Oracle Client) 11.2, 12.1 or 12.2 installation:

  1. Set the environment variable PATH to include the path that contains OCI.dll, if it is not already set. For example, on Windows 7, update PATH in Control Panel -> System -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> PATH.

  2. Optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml can be placed in the network/admin subdirectory of the Oracle software.

    Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

macOS

ODPI-C requires Oracle Client libraries, which are found in Oracle Instant Client for macOS.

On macOS, ODPI-C first searches for a library called “libclntsh.dylib” using the standard library search order. If this is not found, it will then search for “libclntsh.dylib.12.1” and then for “libclntsh.dylib.11.1” before returning an error.

Oracle Instant Client Zip

To run ODPI-C applications with Oracle Instant Client zip files:

  1. Download the 11.2, 12.1 or 12.2 “Basic” or “Basic Light” zip file from here. Choose either a 64-bit or 32-bit package, matching your application architecture. Most applications use 64-bit.

  2. Unzip the package into a single directory that is accessible to your application. For example:

    1. mkdir -p /opt/oracle
    2. unzip instantclient-basic-macos.x64-12.2.0.1.0.zip
  3. Add links to $HOME/lib or /usr/local/lib to enable applications to find the library. For example:

    1. mkdir ~/lib
    2. ln -s /opt/oracle/instantclient_12_2/libclntsh.dylib.12.1 ~/lib/

    Alternatively, copy the required OCI libraries. For example:

    1. mkdir ~/lib
    2. cp /opt/oracle/instantclient_12_2/{libclntsh.dylib.12.1,libclntshcore.dylib.12.1,libons.dylib,libnnz12.dylib,libociei.dylib} ~/lib/

    For Instant Client 11.2, the OCI libraries must be copied. For example:

    1. mkdir ~/lib
    2. cp /opt/oracle/instantclient_11_2/{libclntsh.dylib.11.1,libnnz11.dylib,libociei.dylib} ~/lib/
  4. If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml with Instant Client, then create a network/admin subdirectory. For example:

    1. mkdir -p /opt/oracle/instantclient_12_2/network/admin

    This is the default Oracle configuration directory for applications linked with this Instant Client.

    Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

Other Platforms

To run ODPI-C applications on other platforms (such as Solaris and AIX), follow the same general directions as for Linux Instant Client zip files or Local Database. Add the Oracle libraries to the appropriate library path variable, such as LD_LIBRARY_PATH on Solaris, or LIBPATH on AIX.

cx_Oracle.DatabaseError: DPI-1047的更多相关文章

  1. cx_Oracle.DatabaseError: ORA-12541: TNS:no listener

    问题:利用Python连接Oracle时报错,完整过程如下 import cx_Oracle conn = cx_Oracle.connect('testma/dingjia@192.168.88.1 ...

  2. cx_Oracle.DatabaseError: ORA-28759: failure to open file

    找了好久这个问题,有人说是tcps的问题,需要自己生成证书什么的,后来才发现原来是 钱包文件路径 的问题,钱包文件解压后必须放在instantclien/network/admin下,在Windows ...

  3. (cx_Oracle.DatabaseError) DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory"

    打开https://oracle.github.io/odpi/doc/installation.html 官方相关如下 Oracle Instant Client RPM¶ To run ODPI- ...

  4. windows10,redhat6.5下python3.5.2使用cx_Oracle链接oracle

    0.序言 项目主要使用oracle但是我不太喜欢其他编程语言,加上可能需要用python部署算法包,从oracle表中读出数据,处理完成后在放回oracle中去,所以在windows上就想到先用pyt ...

  5. python使用cx_Oracle连接oracle

    1.使用pip命令安装cx_Oracle $ pip install cx_Oracle 2.安装oracle客户端,并添加到path 下载路径: http://www.oracle.com/tech ...

  6. cx_Oracle连接数据库总结

    python中连接oracle数据库使用第三方库文件cx_Oracle时遇到了各种问题,网上查找资料调试了几天才弄好,下面是不断调试后总结的一些经验.1.oracle客户端(Oracle Instan ...

  7. Python cx_Oracle问题处理

    今天第一次使用Python连接Oracle数据库(多么可怕,三年码农没用Python手动连过Oracle) 首先: pip install cx_Oracle 好,安装完成,测试代码如下: from ...

  8. Python3安装cx_Oracle连接oracle数据库实操总结

    弄清版本,最重要!!! 首先安装配置时,必须把握一个点,就是版本一致!包括:系统版本,python版本,oracle客户端的版本,cx_Oracle的版本,然后安装配置就容易了! 如果已经安装Pyth ...

  9. 第八篇:cx_Oracle出现的问题

    1.cx_Oracle.DatabaseError: ORA-24315: illegal attribute type 2.cx_Oracle.InterfaceError: Unable to a ...

随机推荐

  1. Spring AOP 之编译期织入、装载期织入、运行时织入(转)

    https://blog.csdn.net/wenbingoon/article/details/22888619 一   前言 AOP 实现的关键就在于 AOP 框架自动创建的 AOP 代理,AOP ...

  2. Jmeter(十)检查点

    检查点又名断言,我们在手工测试过程中肉眼以及自己的逻辑思维对实际结果进行判断是否与预期结果一致,但是工具是死的,没有眼睛,没有思维,并不知道需要判断的信息在哪块,或者是来判断什么东西,我们需要让工具更 ...

  3. [UE4]封装蓝图函数Print String

    World Context Object一定要赋值才会在多人游戏中出现Server和Client,如下图所示:

  4. [UE4]时间轴线TimeLine,Lerp插值

    一.TimeLine时间轴线 勾选“User Last Keyframe”表示使用时间轴最后一个关键帧所在时间点作为结束时间,而不是使用设置的5秒作为结束时间点. 二.Lerp插值 Lerp插值一般与 ...

  5. js时间加减

    1.选择上一周方法(不算当天) $("#weekSel").click(function () { //当前时间 var now = new Date(); //当前时间往前推一周 ...

  6. python类的全面介绍

    转载:全面介绍python面向对象的编程——类的基础 转载:类的实例方法.静态方法.类方法的区别

  7. InfluxDB 基本认识

    一.InfluxDB 简介 InfluxDB 是用Go语言编写的一个开源分布式时序.事件和指标数据库,无需外部依赖.类似的数据库有Kairosdb.OpenTsdb等. 三大特性: 时序性(Time ...

  8. 由echarts想到的js中的时间类型

    在工作中使用echarts时,偶然发现折线图中对时间类型变量的用法: now前面的+号何解? now = new Date(+now + oneDay); 后来查阅资料,看到一篇博客,解释如下:这是对 ...

  9. angular的常见问题

    ng-if 跟 ng-show/hide 的区别有哪些? 第一点区别是,ng-if 在后面表达式为 true 的时候才创建这个 dom 节点,ng-show 是初始时就创建了,用 display:bl ...

  10. 【死磕 Spring】—— IoC 之加载 BeanDefinition

    本文主要基于 Spring 5.0.6.RELEASE 摘要: 原创出处 http://cmsblogs.com/?p=2658 「小明哥」,谢谢! 作为「小明哥」的忠实读者,「老艿艿」略作修改,记录 ...