Docker 上的 cx_Oracle:DPI-1047:无法加载 64 位 Oracle 客户端库:“libclntsh.so

闪点

我正在尝试使用 cx_Oracle 构建 Docker 映像。

这是我正在使用的 Dockerfile:

FROM oraclelinux:7-slim

ARG release=18
ARG update=3

RUN  yum -y install oracle-release-el7 && \
     yum-config-manager --enable ol7_oracle_instantclient && \
     yum -y install oracle-instantclient${release}.${update}-basic && \
     rm -rf /var/cache/yum

COPY ./fetch_session_iptv.py /opt/
COPY ./conf/fetch_session_iptv.conf /opt/conf/
#COPY ./conf/certs/* /opt/conf/certs/
COPY ./logs /opt/logs

RUN yum install -y \
    #https://yum.oracle.com/repo/OracleLinux/OL7/developer/x86_64/getPackage/oracle-instantclient18.3-basic-18.3.0.0.0-2.x86_64.rpm \
    https://yum.oracle.com/repo/OracleLinux/OL7/developer/x86_64/getPackage/python36-cx_Oracle-7.0-1.0.2.el7.x86_64.rpm \
    https://yum.oracle.com/repo/OracleLinux/OL7/developer/x86_64/getPackage/python36-pytz-2016.10-2.0.1.el7.noarch.rpm

COPY ./python_requirements/elasticsearch-7.8.0-py2.py3-none-any.whl .
COPY ./python_requirements/certifi-2020.4.5.2-py2.py3-none-any.whl .
COPY ./python_requirements/urllib3-1.25.9-py2.py3-none-any.whl .

RUN pip3 install --user \
    certifi-2020.4.5.2-py2.py3-none-any.whl \
    urllib3-1.25.9-py2.py3-none-any.whl \
    elasticsearch-7.8.0-py2.py3-none-any.whl


#CMD ["/bin/bash"]

CMD [ "python3", "/opt/fetch_session_iptv.py" ]

这直接来自 Oracle 文档:ODPI-C 安装

图像似乎正确构建:

Sending build context to Docker daemon  3.214GB
Step 1/13 : FROM oraclelinux:7-slim
 ---> 7442ca158991
Step 2/13 : ARG release=18
 ---> Using cache
 ---> a9601d8b5721
Step 3/13 : ARG update=3
 ---> Using cache
 ---> 9c82b94480af
Step 4/13 : RUN  yum -y install oracle-release-el7 &&      yum-config-manager --enable ol7_oracle_instantclient &&      yum -y install oracle-instantclient${release}.${update}-basic &&      rm -rf /var/cache/yum
 ---> Using cache
 ---> aadfe1be7fe3
Step 5/13 : COPY ./fetch_session_iptv.py /opt/
 ---> Using cache
 ---> b3346172a4d4
Step 6/13 : COPY ./conf/fetch_session_iptv.conf /opt/conf/
 ---> Using cache
 ---> a0b0def735fc
Step 7/13 : COPY ./logs /opt/logs
 ---> Using cache
 ---> 32e1a82972f7
Step 8/13 : RUN yum install -y  https://yum.oracle.com/repo/OracleLinux/OL7/developer/x86_64/getPackage/python36-cx_Oracle-7.0-1.0.2.el7.x86_64.rpm     https://yum.oracle.com/repo/OracleLinux/OL7/developer/x86_64/getPackage/python36-pytz-2016.10-2.0.1.el7.noarch.rpm
 ---> Running in 50a6545982aa
Loaded plugins: ovl
Examining /var/tmp/yum-root-5QFxy8/python36-cx_Oracle-7.0-1.0.2.el7.x86_64.rpm: python36-cx_Oracle-7.0-1.0.2.el7.x86_64
Marking /var/tmp/yum-root-5QFxy8/python36-cx_Oracle-7.0-1.0.2.el7.x86_64.rpm to be installed
Examining /var/tmp/yum-root-5QFxy8/python36-pytz-2016.10-2.0.1.el7.noarch.rpm: python36-pytz-2016.10-2.0.1.el7.noarch
Marking /var/tmp/yum-root-5QFxy8/python36-pytz-2016.10-2.0.1.el7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package python36-cx_Oracle.x86_64 0:7.0-1.0.2.el7 will be installed
--> Processing Dependency: python(abi) = 3.6 for package: python36-cx_Oracle-7.0-1.0.2.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python36-cx_Oracle-7.0-1.0.2.el7.x86_64
---> Package python36-pytz.noarch 0:2016.10-2.0.1.el7 will be installed
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-13.0.1.el7 will be installed
--> Processing Dependency: python3-pip for package: python3-3.6.8-13.0.1.el7.x86_64
--> Processing Dependency: python3-setuptools for package: python3-3.6.8-13.0.1.el7.x86_64
---> Package python3-libs.x86_64 0:3.6.8-13.0.1.el7 will be installed
--> Processing Dependency: libtirpc.so.1()(64bit) for package: python3-libs-3.6.8-13.0.1.el7.x86_64
--> Running transaction check
---> Package libtirpc.x86_64 0:0.2.4-0.16.el7 will be installed
---> Package python3-pip.noarch 0:9.0.3-7.el7_8 will be installed
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch   Version           Repository                    Size
================================================================================
Installing:
 python36-cx_Oracle x86_64 7.0-1.0.2.el7     /python36-cx_Oracle-7.0-1.0.2.el7.x86_64
                                                                          1.3 M
 python36-pytz      noarch 2016.10-2.0.1.el7 /python36-pytz-2016.10-2.0.1.el7.noarch
                                                                          919 k
Installing for dependencies:
 libtirpc           x86_64 0.2.4-0.16.el7    ol7_latest                    89 k
 python3            x86_64 3.6.8-13.0.1.el7  ol7_latest                    69 k
 python3-libs       x86_64 3.6.8-13.0.1.el7  ol7_latest                   7.0 M
 python3-pip        noarch 9.0.3-7.el7_8     ol7_latest                   1.8 M
 python3-setuptools noarch 39.2.0-10.el7     ol7_latest                   628 k

Transaction Summary
================================================================================
Install  2 Packages (+5 Dependent packages)

Total size: 12 M
Total download size: 9.5 M
Installed size: 50 M
Downloading packages:
--------------------------------------------------------------------------------
Total                                              1.5 MB/s | 9.5 MB  00:06     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libtirpc-0.2.4-0.16.el7.x86_64                               1/7 
  Installing : python3-libs-3.6.8-13.0.1.el7.x86_64                         2/7 
  Installing : python3-setuptools-39.2.0-10.el7.noarch                      3/7 
  Installing : python3-pip-9.0.3-7.el7_8.noarch                             4/7 
  Installing : python3-3.6.8-13.0.1.el7.x86_64                              5/7 
  Installing : python36-cx_Oracle-7.0-1.0.2.el7.x86_64                      6/7 
  Installing : python36-pytz-2016.10-2.0.1.el7.noarch                       7/7 
  Verifying  : python3-3.6.8-13.0.1.el7.x86_64                              1/7 
  Verifying  : libtirpc-0.2.4-0.16.el7.x86_64                               2/7 
  Verifying  : python36-cx_Oracle-7.0-1.0.2.el7.x86_64                      3/7 
  Verifying  : python3-libs-3.6.8-13.0.1.el7.x86_64                         4/7 
  Verifying  : python3-setuptools-39.2.0-10.el7.noarch                      5/7 
  Verifying  : python36-pytz-2016.10-2.0.1.el7.noarch                       6/7 
  Verifying  : python3-pip-9.0.3-7.el7_8.noarch                             7/7 

Installed:
  python36-cx_Oracle.x86_64 0:7.0-1.0.2.el7                                     
  python36-pytz.noarch 0:2016.10-2.0.1.el7                                      

Dependency Installed:
  libtirpc.x86_64 0:0.2.4-0.16.el7           python3.x86_64 0:3.6.8-13.0.1.el7  
  python3-libs.x86_64 0:3.6.8-13.0.1.el7     python3-pip.noarch 0:9.0.3-7.el7_8 
  python3-setuptools.noarch 0:39.2.0-10.el7 

Complete!
Removing intermediate container 50a6545982aa
 ---> 3345ba39b755
Step 9/13 : COPY ./python_requirements/elasticsearch-7.8.0-py2.py3-none-any.whl .
 ---> dcc4f0c5a5c5
Step 10/13 : COPY ./python_requirements/certifi-2020.4.5.2-py2.py3-none-any.whl .
 ---> e47c23f75225
Step 11/13 : COPY ./python_requirements/urllib3-1.25.9-py2.py3-none-any.whl .
 ---> f850ea09150d
Step 12/13 : RUN pip3 install --user    certifi-2020.4.5.2-py2.py3-none-any.whl urllib3-1.25.9-py2.py3-none-any.whl     elasticsearch-7.8.0-py2.py3-none-any.whl
 ---> Running in d01bf60be689
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Processing /certifi-2020.4.5.2-py2.py3-none-any.whl
Processing /urllib3-1.25.9-py2.py3-none-any.whl
Processing /elasticsearch-7.8.0-py2.py3-none-any.whl
Installing collected packages: certifi, urllib3, elasticsearch
Successfully installed certifi-2020.4.5.2 elasticsearch-7.8.0 urllib3-1.25.9
Removing intermediate container d01bf60be689
 ---> 4d38468f3a00
Step 13/13 : CMD [ "python3", "/opt/fetch_session_iptv.py" ]
 ---> Running in c2fdb466cd69
Removing intermediate container c2fdb466cd69
 ---> a614ef5071ac
Successfully built a614ef5071ac
Successfully tagged kansas-fetch:1.5-SNAPSHOT

但是当我尝试运行它时,我收到以下错误消息,即使应该安装 Oracle 客户端:

Traceback (most recent call last):
python_metro_kansas_sql |   File "/opt/fetch_session_iptv.py", line 27, in <module>
python_metro_kansas_sql |     with cx_Oracle.connect("test","test", "test") as connection:
python_metro_kansas_sql | 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". See https://oracle.github.io/odpi/doc/installation.html#linux for help

知道如何解决这个问题吗?

我为 Oracle Client 和 cx_Oracle 尝试了不同的版本,但没有区别。

克里斯托弗·琼斯

对于 19c 之前的 RPM,您需要在安装 Instant Client RPM 时更新系统库搜索路径。推荐的方法是使用ldconfigOracle 的示例 18c Dockerfile 所示

RUN  yum -y install oracle-release-el7 \
     yum -y install oracle-instantclient${release}.${update}-basic oracle-instantclient${release}.${update}-devel oracle-instantclient${release}.${update}-sqlplus && \
     rm -rf /var/cache/yum && \
     echo /usr/lib/oracle/${release}.${update}/client64/lib > /etc/ld.so.conf.d/oracle-instantclient${release}.${update}.conf && \
     ldconfig

但是,您应该改用 19c,它会在 RPM 包安装期间自动执行此操作,请参阅示例 Instant Client 19c Dockerfile19c 版本将使您的应用程序连接到与 18c Instant Client 相同的数据库版本,因此使用旧版本毫无意义。

(注意使用 Instant Client 19c ZIP 文件,您仍然需要手动设置系统库搜索路径)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

cx_Oracle连接失败,并显示“ DPI-1047:无法找到64位Oracle客户端库”

使用即时客户端通过Python3(cx_Oracle)连接到Oracle数据库时,错误“ DPI-1047:无法找到64位Oracle客户端库”

如何修复:cx_Oracle.DatabaseError:DPI-1047:无法找到64位Oracle客户端库-Python

DPI-1047:无法从 nodejs 代码中找到 64 位 Oracle 客户端库

Python 3.6,用于 64 位 Windows 上的 11g 客户端的 cx_oracle

泊坞窗运行错误:DPI-1047:无法找到64位Oracle客户端库

使用cx_oracle连接到Oracle数据库会在Windows上提供DPI-1047

无法加载Python3 cx-Oracle Oracle Client库:Linux上的“ libclntsh.so”

在 ml-engine 中使用 cx_oracle 导致“无法加载 Oracle 客户端库”

在同一台服务器上使用带有 64 位 oracle 客户端的 php 7.3.4 64 位和带有 32 位 oracle 客户端的 php 7.3.4 32 位

如何在Windows 7 64位上运行使用Oracle 10g客户端的应用程序?

win 10 32位无法安装Oracle数据库客户端18c

libclntsh.so.12.1的CX_Oracle导入错误

Windows,PyCharm:DPI-1047:无法找到32位Oracle Client库

使用64位Excel连接到32位Oracle客户端

Oracle 11g 64位客户端连接到8i

软件包:cx_Oracle for Python 3.5,Windows64位。甲骨文11.2.0.1.0

如何在 cPanel 上安装 Oracle 客户端库

当 Python 和 Oracle 都是 64 位时,为什么 cx_Oracle 会给出不正确的架构错误?

cx_Oracle无法识别要在Linux上安装的Oracle软件安装位置

在 python cx_Oracle DatabaseError DPI-1004 中捕获:无法获取错误消息

在cx_oracle上使用多个主机

无法在64位ubuntu上安装32位库

无法使用SysWow64 / odbcad32.exe在Window 7 64位上创建ORACLE-ODBC DSN

无法在32位JVM上加载64位SWT库(替换SWT文件)

如何修复“无法为目标:Linux,64位加载共享库'libgdx64.so'”

无法用python的cx_Oracle连接oracle远程数据库

具有多个Oracle客户端版本的cx_Oracle

在64位Ubuntu上安装32位版本的Oracle JDK 7?