从 cron 运行时出现 dbi::Oracle 错误

发布于 2024-09-07 17:38:59 字数 711 浏览 5 评论 0原文

您好,我在脚本中使用 DBD::Oracle 来查询 Oracle 数据库。当我运行这个脚本时,它工作正常,但是当我计划从 cron 运行它时,它给出的错误

install_driver(Oracle) failed: Can't load '/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libnnz10.so: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
 at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at /scripts/db/dbquery.pl line 50

第 50 行是:

my $dbh = DBI->connect("dbi:Oracle:$tns","$dbuser","$dbpass");

请建议,如何解决这个问题。

Hi I am using DBD::Oracle in my script to query into oracle database. When I am running this script its working fine but when i schedule to run this from cron its giving below error

install_driver(Oracle) failed: Can't load '/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libnnz10.so: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
 at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at /scripts/db/dbquery.pl line 50

Line 50 is:

my $dbh = DBI->connect("dbi:Oracle:$tns","$dbuser","$dbpass");

Please suggest, how to fix this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

花心好男孩 2024-09-14 17:38:59

听起来确实没有为 cron 设置所需的 Oracle 环境变量(回复:ysth 对 amphetamachine 答案的评论)。

看看这个 回答 SO 问题:如何通过 Perl CGI 脚本使用数据库服务器? 获取一些指导。

为了提供帮助,请查看您在登录配置文件中设置了哪些 Oracle ENV 变量:

env | grep -i oracle

您在此处看到的几乎所有内容都应在 Perl 脚本中设置为 $ENV{} 变量,或者根据您正在运行的 cron 版本,也可以添加它到您的 crontab 文件:

ORACLE_HOME=/home/oracle/product/10.x.x
* * * * * /path/to/your/script.pl

/I3az/

Does sound like the required Oracle environment variables have not been set for cron (re: ysth comment to amphetamachine answer).

Have a look at this answer to SO question: How can I use a database server from a Perl CGI script? for some guidance.

To help, see what Oracle ENV variables you have set in your login profile:

env | grep -i oracle

Pretty much all what you see here should be set as $ENV{} variables in your Perl script or depending on version of cron you are running it could also be added to your crontab file:

ORACLE_HOME=/home/oracle/product/10.x.x
* * * * * /path/to/your/script.pl

/I3az/

站稳脚跟 2024-09-14 17:38:59

看起来您可能需要安装 Oracle 客户端库为了使其发挥作用。 libnnz10.so 需要由模块动态加载,显然是安装的一部分。

值得注意的是,Oracle 是专有的,不符合 GPL,因此几乎没有 Linux 发行版会通过其存储库提供它。这意味着您可能必须自己安装它。

编辑:确保LD_CONFIG_PATH指向库所在的目录。

或者,您可以在 /etc/ld.so.conf 中附加一行,其中包含 Oracle 客户端库的路径。

Looks like you may need to install Oracle client libraries in order for this to work. libnnz10.so, which needs to be dynamically loaded by the module, is apparently part of the install.

Of note is that Oracle is proprietary and not GPL-compliant, therefore almost no Linux distro will make it available through their repository. This means you are probably going to have to install it yourself.

Edit: Make sure LD_CONFIG_PATH points to the directory where the library resides.

Alternately, you could just append a line to /etc/ld.so.conf with the path to the Oracle client libraries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文