Perl DBD::Oracle 模块安装

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11407513/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:19:19  来源:igfitidea点击:

Perl DBD::Oracle Module installation

perloracle

提问by slayedbylucifer

Could someone guide me how to install the Perl DBD::Oraclemodule?

有人可以指导我如何安装 PerlDBD::Oracle模块吗?

Here is what I have done so far:

这是我到目前为止所做的:

  • Platform: RHEL 5.8 64 bit
  • Installed Perl DBI package
  • Installed Oracle Instant client for Linux 64 bit (basi + sdk + sqlplus component for the instant client
  • Have set the correct $ORACLE_HOMEand $LD_LIBRARY_PATH
  • Then when I do perl Makefile.plit fails with the following error:

    I'm having trouble finding your Oracle version number... trying harder
    
    WARNING: I could not determine Oracle client version so I'll just
    default to version 8.0.0.0. Some features of DBD::Oracle may not work.
    Oracle version based logic in Makefile.PL may produce erroneous results.
    You can use "perl Makefile.PL -V X.Y.Z" to specify a your client version.
    
    Oracle version 8.0.0.0 (8.0)
    DBD::Oracle no longer supports Oracle client versions before 9.2
     Try a version before 1.25 for 9 and 1.18 for 8! at Makefile.PL line 271.
    
  • The instant client version: 11.1.0

  • The DBD::Oracleversion is 1.44
  • 平台:RHEL 5.8 64 位
  • 安装的 Perl DBI 包
  • 已安装适用于 Linux 64 位的 Oracle Instant 客户端(即时客户端的基础 + sdk + sqlplus 组件)
  • 已设置正确$ORACLE_HOME$LD_LIBRARY_PATH
  • 然后当我这样做perl Makefile.pl时失败并出现以下错误:

    I'm having trouble finding your Oracle version number... trying harder
    
    WARNING: I could not determine Oracle client version so I'll just
    default to version 8.0.0.0. Some features of DBD::Oracle may not work.
    Oracle version based logic in Makefile.PL may produce erroneous results.
    You can use "perl Makefile.PL -V X.Y.Z" to specify a your client version.
    
    Oracle version 8.0.0.0 (8.0)
    DBD::Oracle no longer supports Oracle client versions before 9.2
     Try a version before 1.25 for 9 and 1.18 for 8! at Makefile.PL line 271.
    
  • 即时客户端版本:11.1.0

  • DBD::Oracle版本是1.44

If you have installed successfully with the Oracle instant client, then could you please let me know what am I missing?

如果您已成功安装 Oracle 即时客户端,那么您能否告诉我我缺少什么?

Is it possible to install DBD::Oraclewithout using the Oracle instant client?

是否可以DBD::Oracle不使用 Oracle 即时客户端进行安装?

回答by slayedbylucifer

  • Install if missing ExtUtils-MakeMaker module (sudo yum install perl-ExtUtils-MakeMaker)
  • Install Perl DBI module ($ yum install perl-DBI)
  • Manually install below three RPMs for Oracle instant client (from Instant Client Downloads for Linux x86-64. The example is for v11.2.0.3.0-1: adapt the commands below to the actual version.)

    oracle-instantclient11.2-basic-11.2.0.3.0-1
    oracle-instantclient11.2-devel-11.2.0.3.0-1
    oracle-instantclient11.2-sqlplus-11.2.0.3.0-1
    
  • 如果缺少 ExtUtils-MakeMaker 模块,请安装 ( sudo yum install perl-ExtUtils-MakeMaker)
  • 安装 Perl DBI 模块 ( $ yum install perl-DBI)
  • 为 Oracle 即时客户端手动安装以下三个 RPM(来自Instant Client Downloads for Linux x86-64。示例适用于 v11.2.0.3.0-1:将以下命令调整为实际版本。)

    oracle-instantclient11.2-basic-11.2.0.3.0-1
    oracle-instantclient11.2-devel-11.2.0.3.0-1
    oracle-instantclient11.2-sqlplus-11.2.0.3.0-1
    

I am using 64 bit Linux box, so select your RPM filenames accordingly. Something like sudo yum -y install oracle-instantclient*rpmshould do)

我使用的是 64 位 Linux 机器,因此请相应地选择您的 RPM 文件名。喜欢的东西sudo yum -y install oracle-instantclient*rpm应该做的)

  • set below variables:

    export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
    export ORACLE_HOME=/usr/lib/oracle/11.2/client64
    

    MacOS users will need:

    DYLD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/
    

    Also add ORACLE_HOMEto your PATHvariable.

  • download DBD::Oraclefrom CPAN

  • untar the module and run below commands in given sequence:

    perl Makefile.PL
    make
    sudo make install
    
  • 设置以下变量:

    export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
    export ORACLE_HOME=/usr/lib/oracle/11.2/client64
    

    MacOS 用户需要:

    DYLD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/
    

    还要添加ORACLE_HOME到您的PATH变量中。

  • CPAN下载DBD::Oracle

  • 解压模块并按给定顺序运行以下命令:

    perl Makefile.PL
    make
    sudo make install
    

In case you get complaints about missing gcc you can (temporarily) install it and then remove it.

如果您收到有关缺少 gcc 的投诉,您可以(暂时)安装它然后将其删除。

DONE !!!

完毕 !!!

Issues I had faced were due to the wrong LD_LIBRARY_PATH. I had set it to /usr/lib/oracle/11.2/client64whereas the correct value is /usr/lib/oracle/11.2/client64/lib.

我遇到的问题是由于错误造成的LD_LIBRARY_PATH。我已将其设置为,/usr/lib/oracle/11.2/client64而正确的值为/usr/lib/oracle/11.2/client64/lib.

Certainly, this was a great learning for a newbie like me.

当然,这对于像我这样的新手来说是一次很好的学习。

回答by Gianluca Casati

you can also read my article How to install DBD::Oraclewhich contains all the steps required to install DBD::Oracle CPAN module, which is not a straightforward installation. The purpose is to reduce headache and turn it into a repeatable process.

您还可以阅读我的文章如何安装 DBD::Oracle,其中包含安装 DBD::Oracle CPAN 模块所需的所有步骤,这不是一个简单的安装。目的是减少头痛并将其变成可重复的过程。

回答by Maxirus

Here's what I did on CentOS 7.2 using yum packages and CPAN. This assumes you're using Oracle version 12.1 but I would imagine most versions will work this way.

这是我使用 yum 包和 CPAN 在 CentOS 7.2 上所做的。这假设您使用的是 Oracle 12.1 版,但我想大多数版本都会以这种方式工作。

Install Oracle Instant Client

安装 Oracle 即时客户端

yum install oracle-instantclient12.1-basic-12.1.0.2.0-1 oracle-instantclient12.1-devel-12.1.0.2.0-1 oracle-instantclient12.1-sqlplus-12.1.0.2.0-1

Copy demo make files

复制演示制作文件

The install expects the *.mk file to be in /usr/share/oracle/12.1/client64 but the yum package install puts them in /usr/share/oracle/12.1/client64/demo.

安装期望 *.mk 文件在 /usr/share/oracle/12.1/client64 中,但 yum 包安装将它们放在 /usr/share/oracle/12.1/client64/demo 中。

sudo cp /usr/share/oracle/12.1/client64/demo/* /usr/share/oracle/12.1/client64

Modify .bashrc

修改 .bashrc

Add the following lines to your ~/.bashrc

将以下行添加到您的 ~/.bashrc

export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
export PATH=$ORACLE_HOME:$PATH

Now source the file

现在获取文件

source ~/.bashrc

Update CPAN and DBI

更新 CPAN 和 DBI

Update CPAN and DBI to the latest

将 CPAN 和 DBI 更新到最新

cpan> install CPAN
cpan> reload cpan
cpan> install DBI

Install DBD::Oracle

安装 DBD::Oracle

cpan> install DBD::Oracle

回答by Charmin

A little addition to slayedbylucifer answer. I had the same problem like mentioned in the question. I've done all the steps described by slayedbylucifer. But still I got the problem like mentioned here:

slayedbylucifer 答案的一点补充。我遇到了与问题中提到的相同的问题。我已经完成了 slayedbylucifer 描述的所有步骤。但我仍然遇到了这里提到的问题:

/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /opt/oracle/app/oracle/product/11.2.0/client_1/lib//libclntsh.so when searching for -lclntsh
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -lclntsh

So I created the following symbolic link:

所以我创建了以下符号链接:

ln -s /opt/oracle/app/oracle/product/<YOUR_ORACLE_VERSION>/client_1/lib/libclntsh.so $ORACLE_HOME/libclntsh.so*

After that step the error from above (cannot find -lclntsh) was fixed. The execution of the make command was without any errors.

在那一步之后,上面的错误(找不到 -lclntsh)被修复了。make 命令的执行没有任何错误。

The only problem I still have is that I don't understand why this symbolic link is necessary.

我仍然遇到的唯一问题是我不明白为什么这个符号链接是必要的。