oracle libclntsh.so.11.1:无法打开共享对象文件。
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2708317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
libclntsh.so.11.1: cannot open shared object file.
提问by e.b.white
I want to schedule a task on Linux by icrontab, and the task is written in python and have to import cx_Oracle
module, so I export ORACLE_HOME
and LD_LIBRARY_PATH
in .bash_profile, but
it raise the error:
我想通过 icrontab 在 Linux 上安排一个任务,并且该任务是用 python 编写的并且必须导入cx_Oracle
模块,所以我在.bash_profile 中导出ORACLE_HOME
和,但它引发了错误:LD_LIBRARY_PATH
libclntsh.so.11.1: cannot open shared object file.
libclntsh.so.11.1:无法打开共享对象文件。
Since it is ok to run the task by issue the command in shell like:
由于可以通过在 shell 中发出命令来运行任务,例如:
python a.py # ok
I change the task in icrontab into a shell script which invoke my Python script, but the exception recurred?
我将 icrontab 中的任务更改为调用我的 Python 脚本的 shell 脚本,但异常再次出现?
# the shell script scheduled in icrontab
#! bash
python a.py
Could you help how to do with it?
你能帮忙怎么做吗?
采纳答案by Yasir Arsanukaev
回答by Dimitri
The libs are located in
/u01/app/oracle/product/11.2.0/xe/lib
(For Oracle XE) or similar.
这些库位于
/u01/app/oracle/product/11.2.0/xe/lib
(对于 Oracle XE)或类似位置。
You should add this path to /etc/ld.so.conf
or if this file shows only an include location, as in a separate file in the /etc/ld.so.conf.d
directory
/etc/ld.so.conf
如果此文件仅显示包含位置,则应将此路径添加到/etc/ld.so.conf.d
目录中的单独文件中
I have oracle.conf in /etc/ld.so.conf.d
, just one file with the path. Nothing else.
我有 oracle.conf /etc/ld.so.conf.d
,只有一个包含路径的文件。没有其他的。
Of course don't forget to run ldconfig as a last step.
当然不要忘记在最后一步运行 ldconfig。
回答by user151019
Cron does not load the user's profile when running a task and you have to include the profile in your shell script explicitly.
Cron 在运行任务时不会加载用户的配置文件,您必须在 shell 脚本中明确包含该配置文件。
回答by ol3man
If you have problem with libclntsh.so, need create symlink for libclntsh.so from /usr/lib/oracle/11.2/client64/lib
to /usr/lib
如果 libclntsh.so 有问题,需要为 libclntsh.so 创建符号链接从/usr/lib/oracle/11.2/client64/lib
到/usr/lib
回答by Jay Taylor
I ran into this same problem last weekend when I needed to use cx_Oracle. After spending a lot of time trying to modify the LD_LIBRARY_PATH variable to include the $ORACLE_HOME/lib directoy, where libclntsh.so resides, I ended up solving the problem by creating symbolic links from all the Oracle xlibx.so libraries into /lib/xlibx.so. This certainly isn't the "cleanest" solution, but it has a good chance of working without causing too much trouble:
上周末我需要使用 cx_Oracle 时遇到了同样的问题。在花了很多时间尝试修改 LD_LIBRARY_PATH 变量以包含 libclntsh.so 所在的 $ORACLE_HOME/lib 目录之后,我最终通过从所有 Oracle xlibx.so 库创建符号链接到 /lib/xlibx 来解决问题。所以。这当然不是“最干净”的解决方案,但它很有可能在不造成太多麻烦的情况下工作:
cd $ORACLE_HOME/lib
for f in `ls ./*.so*`; do;
sudo ln -s $ORACLE_HOME/lib/$f /lib/$f
done
After I did that, cx_Oracle worked like a charm.
在我这样做之后,cx_Oracle 就像一个魅力。
回答by Josemar Furegatti
This post helped me solve a similar problem with a PostgreSQL database link to Oracle using oracle_fdw
.
这篇文章帮助我解决了使用oracle_fdw
.
I installed oracle_fdw
but when I tried CREATE EXTENSION oracle_fdw;
I got error could not load library libclntsh.so.11.1: cannot open shared object file: No such file or directory.
我安装了oracle_fdw
但是当我尝试时CREATE EXTENSION oracle_fdw;
我得到了error could not load library libclntsh.so.11.1: cannot open shared object file: No such file or directory.
I checked $ORACLE_HOME
, $PATH
and $LD_LIBRARY_PATH
.
我查了一下$ORACLE_HOME
,$PATH
然后$LD_LIBRARY_PATH
。
It worked only AFTER I put Oracle Shared Library on Linux Shared Library
它仅在我将 Oracle 共享库放在 Linux 共享库上后才起作用
echo /opt/instantclient_11_2 > oracle.conf
ldconfig
回答by Ujjawal Khare
Just pass your Oracle path variables before you run any scripts:
Like for perl you can do add below in beginning of your script:
只需在运行任何脚本之前传递您的 Oracle 路径变量:
就像 perl 一样,您可以在脚本的开头添加以下内容:
BEGIN {
my $ORACLE_HOME = "/usr/lib/oracle/11.2/client64";
my $LD_LIBRARY_PATH = "$ORACLE_HOME/lib";
if ($ENV{ORACLE_HOME} ne $ORACLE_HOME
|| $ENV{LD_LIBRARY_PATH} ne $LD_LIBRARY_PATH
) {
$ENV{ORACLE_HOME} = "/usr/lib/oracle/11.2/client64";
$ENV{LD_LIBRARY_PATH} = "$ORACLE_HOME/lib";
exec { $^X } $^X, ##代码##, @ARGV;
}
}
回答by Cleber Spirlandeli
I always have this problem, I can solve by running the code below: export LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH
我总是有这个问题,我可以通过运行下面的代码来解决:export LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH
OBS: This code I saved in the configuration file because I always use it. good luck.
OBS:这段代码我保存在配置文件中,因为我一直在使用它。祝你好运。
回答by Ritesh Maddala
I have copied all library files from installer media databases/stage/ext/libto $ORACLE_HOME/liband it resolved the issue.
我已将所有库文件从安装程序媒体数据库/stage/ext/lib复制到$ORACLE_HOME/lib并解决了该问题。
回答by JSharm
For the benefit of anyone else coming here by far the best thing to do is to update cx_Oracle
to the latest version (6+). This version does not need LD_LIBRARY_PATH
set at all.
到目前为止,为了其他人的利益,最好的办法是更新cx_Oracle
到最新版本 (6+)。这个版本根本不需要LD_LIBRARY_PATH
设置。