当Java 调用python 脚本遇到ImportError: libclntsh.so.11.1: : No such file or directory,脚本本身正常的情况解决

    技术2022-07-13  68

    当python 脚本正常运行或者不正常运行的时候,使用下面方式解决问题,但是必须要保证python配置正确

    python脚本运行正常,java调用出现问题,这种方式可以解决。

    Oracle 安装需要正确,ORACLE_HOME目录存在netwok/admin文件夹和ORA文件。

     

    一、首先检查which sysresv依赖关系

    [oracle@RHELDB admin]$ ldd `which sysresv`         linux-vdso.so.1 =>  (0x00007fff42291000)         libclntsh.so.11.1 => /app/u01/oracle/lib/libclntsh.so.11.1 (0x00002b6a95b97000)         libnnz11.so => /app/u01/oracle/lib/libnnz11.so (0x00002b6a981c1000)         libdl.so.2 => /lib64/libdl.so.2 (0x0000003f5ec00000)         libm.so.6 => /lib64/libm.so.6 (0x0000003f5f000000)         libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003f5f400000)         libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003f62800000)         libc.so.6 => /lib64/libc.so.6 (0x0000003f5e800000)         libaio.so.1 => /usr/lib64/libaio.so.1 (0x00002b6a9859e000)         /lib64/ld-linux-x86-64.so.2 (0x0000003f5e400000)

    二、进入$ORACLE_HOME/lib文件夹,检查libclntsh是否存在

    进入$ORACLE_HOME/lib文件夹,检查libclntsh是否存在

    [oracle@RHELDB bin]$ cd $ORACLE_HOME/lib

    [oracle@RHELDB lib]$ ll |grep libclntsh lrwxrwxrwx 1 oracle oinstall        37 Aug 24 11:11 libclntsh.so -> /app/u01/oracle/lib/libclntsh.so.11.1 lrwxrwxrwx 1 oracle oinstall        32 Aug 24 11:09 libclntsh.so.10.1 -> /app/u01/oracle/lib/libclntsh.so -rwxr-xr-x 1 oracle oinstall  48724657 Aug 24 11:11 libclntsh.so.11.1

    pwd 获取绝对路径:/app/u01/oracle/lib

    三、以root用户修改/etc/ld.so.conf添加$ORACLE_HOME/lib路径

    vi /etc/ld.so.conf

    文件内容如下:

    include ld.so.conf.d/*.conf ~ ~ ~

    /app/u01/oracle/lib #注:这里只能写绝对路径,不能写$ORACLE_HOME/lib

    四、输入ldconfig

    出现一堆下面的东西

    ldconfig: File /app/u01/oracle/lib/libnmemso.so.0 is empty, not checked. 忽略。。。。。。 ldconfig: /app/u01/oracle/lib/libexpat.so.1 is not a symbolic link

    五、进入Oracle 用户 su - oracle

    六、输入csscan help=y

    出现一堆内容

    Character Set Scanner v2.2 : Release 11.2.0.1.0 - Production on Sat Aug 30 19:35:18 2014 Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved. You can let Scanner prompt you for parameters by entering the CSSCAN         command followed by your username/password:                                                                                                              Example: CSSCAN \"SYSTEM/MANAGER AS SYSDBA\"                                                                                                   Or, you can control how Scanner runs by entering the CSSCAN command          followed by various parameters. To specify parameters, you use keywords:                                                                               Example:                                                                       CSSCAN \"SYSTEM/MANAGER AS SYSDBA\" FULL=y TOCHAR=utf8 ARRAY=1024000 PROCESS=3  

    其他内容忽略.....

     

    ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory 这个问题就解决了

     

    七、linux出现ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory和Unable to acquire Oracle environment handle

    修改驱动文件解决

    下载以下文件

    instantclient-basic-linux.x64-11.2.0.4.0.zip instantclient-sdk-linux.x64-11.2.0.4.0.zip

    tar -zxvf 顺序解压 得到到  instantclient_11_2 这个目录

    vi  /etc/ld.so.conf.d/ora.conf

    填入这个到根目录即可(/opt/instantclient_11_2)

    Processed: 0.011, SQL: 9