从 cron 运行时出现 dbi::Oracle 错误
您好,我在脚本中使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来确实没有为 cron 设置所需的 Oracle 环境变量(回复:ysth 对 amphetamachine 答案的评论)。
看看这个 回答 SO 问题:如何通过 Perl CGI 脚本使用数据库服务器? 获取一些指导。
为了提供帮助,请查看您在登录配置文件中设置了哪些 Oracle ENV 变量:
您在此处看到的几乎所有内容都应在 Perl 脚本中设置为 $ENV{} 变量,或者根据您正在运行的 cron 版本,也可以添加它到您的 crontab 文件:
/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:
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:
/I3az/
看起来您可能需要安装 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.