简体   繁体   English

“导入 ibm_db”期间出错

[英]error during “import ibm_db”

I am getting this error !我收到这个错误!

Traceback (most recent call last): File "/home/e****/RRR/RRR_Success.py", line 37, in ?回溯(最近一次通话):文件“/home/e****/RRR/RRR_Success.py”,第 37 行,在 ? import ibm_db ImportError: libdb2.so.1: cannot open shared object file: No such file or directory导入 ibm_db 导入错误:libdb2.so.1:无法打开共享对象文件:没有这样的文件或目录

Please help me to solve this problem请帮我解决这个问题

From my experience LD_LIBRARY_PATH was not needed.根据我的经验,不需要 LD_LIBRARY_PATH。 I got this problem on a system where the python db2 odbc driver and db2 server were on the same machine.我在 python db2 odbc 驱动程序和 db2 服务器位于同一台机器上的系统上遇到了这个问题。

First check if there is only one libdb2.so.1 file on the system.首先检查系统上是否只有一个 libdb2.so.1 文件。
find / -name libdb2.so.1 find / -name libdb2.so.1

If there are two, chances are they are different, so check the md5sum.如果有两个,它们很可能不同,因此请检查 md5sum。

[root@localhost ~]# cat /etc/ld.so.conf.d/db2-odbc.conf
/opt/ibm/db2/odbc_cli/clidriver/lib
[root@localhost ~]# ll /opt/ibm/db2/odbc_cli/clidriver/lib/libdb2.so.1
[root@localhost ~]# ll /home/db2inst1/sqllib/lib64/libdb2.so.1
-r-xr-xr-x 1 bin bin 42685547 Dec 15 08:49 /home/db2inst1/sqllib/lib64/libdb2.so.1

[root@localhost ~]# md5sum /home/db2inst1/sqllib/lib64/libdb2.so.1
ffca929b98201e3934e9625d1480890f  /home/db2inst1/sqllib/lib64/libdb2.so.1
[root@localhost ~]# md5sum /opt/ibm/db2/odbc_cli/clidriver/lib/libdb2.so.1
a1247f1582eb1bd2fc248b3901812951  /opt/ibm/db2/odbc_cli/clidriver/lib/libdb2.so.1
[root@localhost ~]#



The files are different, you can control which file is linked by modifying ldconfig.文件不同,可以通过修改ldconfig来控制链接哪个文件。

[root@localhost ~]# ll /etc/ld.so.conf.d/
total 24
-rw-r--r--. 1 root root  17 Feb  9  2012 atlas-x86_64.conf
-rw-r--r--  1 root root  28 Dec 15 08:50 db2.conf
-rw-r--r--  1 root root  36 Dec 15 09:07 db2-odbc.conf
-r--r--r--. 1 root root 324 Jun  6  2014 kernel-2.6.32-431.20.3.el6.x86_64.conf
-rw-r--r--. 1 root root  17 Feb  3  2014 mysql-x86_64.conf
-rw-r--r--. 1 root root  22 Jul 18  2011 qt-x86_64.conf
[root@localhost ~]#


I removed the db2.conf file from this folder, and ran ldconfig, it then started to work.我从这个文件夹中删除了 db2.conf 文件,然后运行 ​​ldconfig,然后它就开始工作了。

[root@localhost ~]# mv /etc/ld.so.conf.d/db2.conf mahesh/
[root@localhost ~]# ldconfig


Note that the db2 client from db2inst1 still works and this is where the LD_LIBRARY_PATH is set.请注意,来自 db2inst1 的 db2 客户端仍然有效,这是设置 LD_LIBRARY_PATH 的地方。

[root@localhost ~]# su - db2inst1
[db2inst1@localhost ~]$ db2 connect to dbname

   Database Connection Information

 Database server        = DB2/LINUXX8664 10.5.3
 SQL authorization ID   = DB2INST1
 Local database alias   = dbname

[db2inst1@localhost ~]$ env | grep LIBRARY
LD_LIBRARY_PATH=/home/db2inst1/sqllib/lib64:/home/db2inst1/sqllib/lib32
[db2inst1@localhost ~]$

Above error indicate DB2 client libraries is not in your LD_LIBRARY_PATH, Please set /home/../path/to/sqllib/lib in your LD_LIBRARY_PATH.以上错误表明 DB2 客户端库不在您的 LD_LIBRARY_PATH 中,请在您的 LD_LIBRARY_PATH 中设置 /home/../path/to/sqllib/lib。 For more info you can go through http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.apdv.gs.doc/doc/c0006321.html?lang=en有关更多信息,您可以访问http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.apdv.gs.doc/doc/c0006321.html?lang=en

(重新)安装ibm-db

This is what I did for a docker image:这是我为 docker 图像所做的:

WORKDIR /home/db2_cli_odbc_driver
RUN apt-get update && \
    apt-get --assume-yes install \
       wget && \
    wget https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/linuxx64_odbc_cli.tar.gz -O odbc_cli.tar.gz && \
    tar -xvf odbc_cli.tar.gz && rm odbc_cli.tar.gz && \
    echo /home/db2_cli_odbc_driver/clidriver/lib > /etc/ld.so.conf.d/db2.conf && \
    ldconfig && \
    apt-get purge -y --auto-remove wget && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
ENV IBM_DB_HOME=/home/db2_cli_odbc_driver/clidriver

In order words,换句话说,

  • download the driver下载驱动程序
  • unpack it打开包装
  • create a /etc/ld.so.conf.d/db2.conf file pointing to the target folder创建一个指向目标文件夹的/etc/ld.so.conf.d/db2.conf文件
  • run ldconfig运行ldconfig
  • set the IBM_DB_HOME variable before installing the python package在安装 python 包之前设置IBM_DB_HOME变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM