安装DBD :: Oracle时出错

时间:2014-10-05 06:23:49

标签: linux oracle perl cpan

我正在尝试在RHEL6.1服务器上安装Perl模块DBD :: Oracle。在这样做的同时,我遵循了以下步骤:

  1. 安装以下RPM:

    • 甲骨文instantclient12.1碱性-12.1.0.2.0-1.x86_64.rpm
    • 甲骨文instantclient12.1-devel的-12.1.0.2.0-1.x86_64.rpm
    • 甲骨文instantclient12.1-SQLPLUS-12.1.0.2.0-1.x86_64.rpm
  2. 导出环境变量

    export ORACLE_HOME=/usr/lib/oracle/12.1/client64

    export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib

  3. 安装DBD :: Oracle

    cpan -i DBD::Oracle

  4. 在执行此操作时,它会显示以下错误消息:

    Installing on a linux, Ver#2.6
    Using Oracle in /usr/lib/oracle/12.1/client64
    DEFINE _SQLPLUS_RELEASE = "1201000200" (CHAR)
    Oracle version 12.1.0.2 (12.1)
    
            Unable to locate an oracle.mk or other suitable *.mk
            file in your Oracle installation.  (I looked in
            /usr/lib/oracle/12.1/client64/rdbms/demo/demo_xe.mk /usr/lib/oracle/12.1/client64/rdbms/lib/oracle.mk /usr/lib/oracle/12.1/client64/rdbms/demo/oracle.mk /usr/lib/oracle/12.1/client64/rdbms/demo/demo_rdbms.mk /usr/lib/oracle/12.1/client64/rdbms/demo/demo_rdbms64.mk /usr/lib/oracle/12.1/client64/rdbms/lib/ins_rdbms.mk /usr/share/oracle/12.1/client64/demo.mk under /usr/lib/oracle/12.1/client64)
    
            The oracle.mk (or demo_rdbms.mk) file is part of the Oracle
            RDBMS product.  You need to build DBD::Oracle on a
            system which has one of these Oracle components installed.
            (Other *.mk files such as the env_*.mk files will not work.)
            Alternatively you can use Oracle Instant Client.
    
            In the unlikely event that a suitable *.mk file is installed
            somewhere non-standard you can specify where it is using the -m option:
                    perl Makefile.PL -m /path/to/your.mk
    
            See the appropriate README file for your OS for more information and some alternatives.
    
         at Makefile.PL line 1187.
    Warning: No success on command[/usr/bin/perl Makefile.PL INSTALLDIRS=site]
      PYTHIAN/DBD-Oracle-1.74.tar.gz
      /usr/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
    Running make test
      Make had some problems, won't test
    Running make install
      Make had some problems, won't install
    

    安装过程有什么问题?我按照this指南。

5 个答案:

答案 0 :(得分:24)

安装和设置Oracle Instant Client后,使用不带cpan工具的常规构建步骤,并将-l选项传递给Makefile.PL

  1. 下载tar.gz包并将其解压缩

  2. 构建

    perl Makefile.PL -l
    make && make test
    
  3. 安装

    make install
    

答案 1 :(得分:14)

实际上如果要使用rpms和cpan进行安装,则必须将ORACLE_HOME设置为lib文件夹,而不仅仅是client64并将sqlplus添加到路径中:

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

使用cpan -i DBD::Oracle不会返回任何错误。

答案 2 :(得分:1)

CPAN安装程序唯一找不到的是* .mk文件。 Oracle必须使用CPAN安装程序玩猫捉老鼠游戏,因为安装程序正在多个位置搜索多个文件名。

我用了命令

locate -r '\.mk$'

发现demo.mk现在位于/usr/lib/oracle/12.1/client64/demo/而不是/usr/lib/oracle/12.1/client64/

所以我创建了一个符号链接

sudo ln -s /usr/share/oracle/12.1/client64/demo/demo.mk /usr/share/oracle/12.1/client64/demo.mk

并且CPAN安装程序成功。

答案 3 :(得分:1)

通过安装以下3个即时客户端RPM软件包,我能够使用CPAN为11.2.0.4安装DBD :: Oracle:

  • oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64
  • oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64
  • oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64

一旦我安装了这些,cpan就可以构建。这是CentOS 7.3.1611的版本。

答案 4 :(得分:0)

开始之前,您需要:

  • 下载Oracle 12c即时客户端和SDK:

    • instantclient-basic-linux.x64-12.2.0.1.0.zip
    • instantclient-sdk-linux.x64-12.2.0.1.0.zip
    • instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
  • 使用以下命令安装:

    sudo apt-get install libaio1

  • 使用以下命令下载并解压缩DBD :: Oracle软件包:

    cpan get DBD::Oracle

如果您拥有Windows 10下的DBD :: Oracle 1.74 + Oracle 12c(12.2.0.1)和Ubuntu 18应用程序,则需要进行更多更改。

  1. 在Makefile.PL中注释行1613

    #local $ENV{PATH} = join $Config{path_sep}, "$OH_path/bin", $OH_path, $ENV{PATH} if $OH;

  2. 替换第1630行

    我的$ sqlplus_release =`sqlplus -S / nolog \ @ define.sql`;

与行

my $sqlplus_release = qq {SQL> DEFINE _SQLPLUS_RELEASE
DEFINE _SQLPLUS_RELEASE = "1202000100" (CHAR)
SQL> QUIT};
  1. 以以下方式执行Perl脚本:

    perl Makefile.PL -l

  2. 用下面的行替换第569-581行(因为Windows下的Ubuntu不支持带冒号的路径):

    lib/DBD/Oracle.pm $(INST_MAN3DIR)/DBD_Oracle.$(MAN3EXT) \ lib/DBD/Oracle/GetInfo.pm $(INST_MAN3DIR)/DBD_Oracle_GetInfo.$(MAN3EXT) \ lib/DBD/Oracle/Object.pm $(INST_MAN3DIR)/DBD_Oracle_Object.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Aix.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Aix.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Cygwin.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Cygwin.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Hpux.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Hpux.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Linux.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Linux.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Macos.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Macos.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Sun.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Sun.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Vms.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Vms.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Win32.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Win32.$(MAN3EXT) \ lib/DBD/Oracle/Troubleshooting/Win64.pod $(INST_MAN3DIR)/DBD_Oracle_Troubleshooting_Win64.$(MAN3EXT)

    1. 执行以下命令:

    make && make test

    1. 使用命令安装

    sudo make install

并希望在开始之前已安装所有先决条件。