0

我想要做的是通过 perl 从 oracle 数据库连接和检索数据。

我所做的(作为 oracle 帐户)如下所示......

$ rpm -qa|grep DBI
perl-DBI-1.52-2.el5

$ wget http://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.17.tar.gz
$ tar -zxf DBD-Oracle-1.17.tar.gz
$ cd DBD-Oracle-1.17
$ perl Makefile.PL
Using DBI 1.52 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/

Configuring DBD::Oracle for perl 5.008008 on linux (x86_64-linux-thread-multi)

Remember to actually *READ* the README file! Especially if you have any problems.

Using Oracle in /sw/oracle/app/oracle/product/102
DEFINE _SQLPLUS_RELEASE = "1002000500" (CHAR)
Oracle version 10.2.0.5 (10.2)
Found /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk
Using /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk
Your LD_LIBRARY_PATH env var is set to '/sw/oracle/app/oracle/product/102/lib:/usr/lib:/sw/oracle/app/oracle/product/102/lib32:.'
Reading /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk
Reading /sw/oracle/app/oracle/product/102/rdbms/lib/env_rdbms.mk

Attempting to discover Oracle OCI build rules
gcc    -c -o DBD_ORA_OBJ.o DBD_ORA_OBJ.c
by executing: [make -f /sw/oracle/app/oracle/product/102/rdbms/demo/demo_rdbms.mk build ECHODO=echo ECHO=echo GENCLNTSH='echo genclntsh' CC=true OPTIMIZE= CCFLAGS= EXE=DBD_ORA_EXE OBJS=DBD_ORA_OBJ.o]
Oracle oci build command:
    [true -L/sw/oracle/app/oracle/product/102/lib/ -L/sw/oracle/app/oracle/product/102/rdbms/lib/ -o DBD_ORA_EXE DBD_ORA_OBJ.o -lclntsh   `cat /sw/oracle/app/oracle/product/102/lib/sysliblist` -ldl -lm  -lpthread]

Found header files in /sw/oracle/app/oracle/product/102/rdbms/public.

Checking for functioning wait.ph
Constant subroutine __USE_POSIX undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 8.
Constant subroutine __USE_POSIX2 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 9.
Constant subroutine __USE_POSIX199309 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 10.
Constant subroutine __USE_POSIX199506 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 11.
Constant subroutine __USE_XOPEN undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 12.
Constant subroutine __USE_XOPEN_EXTENDED undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 13.
Constant subroutine __USE_UNIX98 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 14.
Constant subroutine __USE_LARGEFILE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 16.
Constant subroutine __USE_LARGEFILE64 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 17.
Constant subroutine __USE_FILE_OFFSET64 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 18.
Constant subroutine __USE_BSD undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 19.
Constant subroutine __USE_SVID undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 20.
Constant subroutine __USE_MISC undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 21.
Constant subroutine __USE_GNU undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 23.
Constant subroutine __USE_REENTRANT undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 24.
Constant subroutine _POSIX_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 49.
Constant subroutine _POSIX_C_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 51.
Constant subroutine _XOPEN_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 53.
Constant subroutine _XOPEN_SOURCE_EXTENDED undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 55.
Constant subroutine _LARGEFILE64_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 57.
Constant subroutine _LARGEFILE_SOURCE undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 104.
Constant subroutine __USE_ISOC99 undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 108.
Constant subroutine __GNU_LIBRARY__ undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/features.ph line 156.
Operator or semicolon missing before &__inline at (eval 167) line 1.
Ambiguous use of & resolved as operator & at (eval 167) line 1.
Constant subroutine __need_size_t undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/stddef.ph line 148.
Scalar found where operator expected at (eval 241) line 1, near "'int'  $__val"
    (Missing operator before   $__val?)
Number found where operator expected at (eval 245) line 1, near ") 0"
    (Missing operator before 0?)
Number found where operator expected at (eval 246) line 1, near ") 1"
    (Missing operator before 1?)
Number found where operator expected at (eval 247) line 1, near ") 2"
    (Missing operator before 2?)
Constant subroutine __need_timespec undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/time.ph line 49.
Hexadecimal number > 0xffffffff non-portable at (eval 447) line 1.
Hexadecimal number > 0xffffffff non-portable at (eval 448) line 1.
Constant subroutine __need_timeval undefined at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/bits/time.ph line 23.


System: perl5.008008 linux builder10.centos.org 2.6.18-53.el5 #1 smp mon nov 12 02:14:55 est 2007 x86_64 x86_64 x86_64 gnulinux 
Compiler:   gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
Linker:     /usr/bin/ld
Sysliblist: -ldl -lm -lpthread -lnsl -lirc 
Oracle makefiles would have used these definitions but we override them:
  CC:       $(COMPDIR)/bin/gcc
  CFLAGS:   $(GFLAG) $(OPTIMIZE) $(CDEBUG) $(CCFLAGS) $(PFLAGS)\
    $(SHARED_CFLAG) $(USRFLAGS)
           [$(GFLAG) -O3 $(CDEBUG) -m32 -trigraphs -fPIC -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -DLINUX -D_GNU_SOURCE -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -DSLTS_ENABLE -DSLMXMX_ENABLE -D_REENTRANT -DNS_THREADS -fno-strict-aliasing $(LPFLAGS) $(USRFLAGS)]
  LDFLAGS:  $(LDFLAGS32)
           [-m32 -o $@ -L/sw/oracle/app/oracle/product/102/rdbms//lib32/ -L/sw/oracle/app/oracle/product/102/lib32/ -L/sw/oracle/app/oracle/product/102/lib32/stubs/]
Linking with OTHERLDFLAGS = -L/sw/oracle/app/oracle/product/102/lib/ -L/sw/oracle/app/oracle/product/102/rdbms/lib/   -lclntsh   `cat /sw/oracle/app/oracle/product/102/lib/sysliblist` -ldl -lm  -lpthread [from 'build' rule]

Checking if your kit is complete...
Looks good
LD_RUN_PATH=/sw/oracle/app/oracle/product/102/lib:/sw/oracle/app/oracle/product/102/rdbms/lib
Using DBD::Oracle 1.17.
Using DBD::Oracle 1.17.
Using DBI 1.52 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::Oracle

***  If you have problems...
     read all the log printed above, and the README and README.help.txt files.
     (Of course, you have read README by now anyway, haven't you?)

$ make
cp Oracle.pm blib/lib/DBD/Oracle.pm
cp oraperl.ph blib/lib/oraperl.ph
cp dbdimp.h blib/arch/auto/DBD/Oracle/dbdimp.h
cp ocitrace.h blib/arch/auto/DBD/Oracle/ocitrace.h
cp Oraperl.pm blib/lib/Oraperl.pm
cp Oracle.h blib/arch/auto/DBD/Oracle/Oracle.h
cp lib/DBD/Oracle/GetInfo.pm blib/lib/DBD/Oracle/GetInfo.pm
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm
/usr/bin/perl -p -e "s/~DRIVER~/Oracle/g" /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/Driver.xst > Oracle.xsi
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap  Oracle.xs > Oracle.xsc && mv Oracle.xsc Oracle.c
gcc -c  -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -I/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\"1.17\" -DXS_VERSION=\"1.17\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DNEW_OCI_INIT -DORA_OCI_VERSION=\"10.2.0.5\" Oracle.c
Oracle.c: In function 'XS_DBD__Oracle__db_ora_lob_append':
Oracle.xs:201: warning: unused variable 'startp'
gcc -c  -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -I/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\"1.17\" -DXS_VERSION=\"1.17\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DNEW_OCI_INIT -DORA_OCI_VERSION=\"10.2.0.5\" dbdimp.c
dbdimp.c: In function 'ora_db_login6':
dbdimp.c:652: warning: value computed is not used
dbdimp.c: In function 'dbd_rebind_ph_char':
dbdimp.c:1052: warning: value computed is not used
gcc -c  -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/rdbms/demo -I/sw/oracle/app/oracle/product/102/rdbms/public -I/sw/oracle/app/oracle/product/102/plsql/public -I/sw/oracle/app/oracle/product/102/network/public -I/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\"1.17\" -DXS_VERSION=\"1.17\" -fPIC "-I/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DNEW_OCI_INIT -DORA_OCI_VERSION=\"10.2.0.5\" oci8.c
oci8.c: In function 'fetch_func_rset':
oci8.c:626: warning: value computed is not used
oci8.c: In function 'dbd_rebind_ph_lob':
oci8.c:711: warning: value computed is not used
oci8.c: In function 'ora_blob_read_mb_piece':
oci8.c:778: warning: comparison is always false due to limited range of data type
oci8.c: In function 'ora_describe':
oci8.c:1267: warning: comparison is always false due to limited range of data type
oci8.c: In function 'post_execute_lobs':
oci8.c:2118: warning: value computed is not used
oci8.c: At top level:
oci8.c:563: warning: 'fetch_func_nty' defined but not used
Running Mkbootstrap for DBD::Oracle ()
chmod 644 Oracle.bs
rm -f blib/arch/auto/DBD/Oracle/Oracle.so
gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic Oracle.o dbdimp.o oci8.o -L/sw/oracle/app/oracle/product/102/lib/ -L/sw/oracle/app/oracle/product/102/rdbms/lib/   -lclntsh   `cat /sw/oracle/app/oracle/product/102/lib/sysliblist` -ldl -lm  -lpthread -o blib/arch/auto/DBD/Oracle/Oracle.so    \
            \

chmod 755 blib/arch/auto/DBD/Oracle/Oracle.so
cp Oracle.bs blib/arch/auto/DBD/Oracle/Oracle.bs
chmod 644 blib/arch/auto/DBD/Oracle/Oracle.bs
/usr/bin/perl "-Iblib/arch" "-Iblib/lib" ora_explain.PL ora_explain
Extracted ora_explain from ora_explain.PL with variable substitutions.
cp ora_explain blib/script/ora_explain
/usr/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" blib/script/ora_explain
Manifying blib/man1/ora_explain.1
Manifying blib/man3/DBD::Oracle.3pm
Manifying blib/man3/DBD::Oraperl.3pm

$ make install


Warning: You do not have permissions to install into /usr/share/man/man1 at /usr/lib/perl5/5.8.8/ExtUtils/Install.pm line 114.
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod

$ sudo - chmod 777 /usr/share/man

Warning: You do not have permissions to install into /usr/bin at /usr/lib/perl5/5.8.8/ExtUtils/Install.pm line 114.
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod

$ sudo - chmod 777 /usr/bin

Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod

$ perl -e 'use DBD::Oracle'
install_driver(Oracle) failed: Can't load '/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: /sw/oracle/app/oracle/product/102/lib/libnnz10.so:  cannot restore segment prot after reloc: Permission denied at /usr/lib64/perl5/5.8.8/x86_64-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 ./ora_dump.pl line 7

我已经检查了 /sw/oracle/app/oracle/product/102/lib/libnnz10.so 的权限。
我的机器在 CentOS 5.5 版和 10g 企业版 10.2.0.5.0 版上......我错过了什么?

4

2 回答 2

2

听起来像是 SELinux 的问题。尝试禁用它,看看这是否能解决您的问题: http ://www.crypt.gen.nz/selinux/disable_selinux.html

于 2012-10-10T07:02:37.573 回答
1

我不知道你错过了什么以及你哪里出错了。但我总是遵循下面的方法,它对我来说是 100% 的。试试这个方法,如果它不起作用,那么我绝对可以让它为你工作....

我在您的帖子中注意到的一件事是您遇到了权限问题。尝试以 root 身份运行这些步骤。

我的环境:Oracle 11G 在远程机器上运行

我的桌面:ubunt/fedora/RHEL/CenOS

我已经在以上 4 种 Linux 风格上实现了这一点,它们都运行良好。

以下是步骤(按照给定的顺序进行操作):

安装 Perl DBI 模块

从http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html为 oracle 即时客户端安装低于 3 rpm

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

我使用的是 64 位 linux 机器,因此请相应地选择您的 RPM。

设置以下变量:

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

也添加ORACLE_HOME到你的PATH变量

DBD::Oracle ver 1.44从 CPAN下载。解压模块并按给定顺序运行以下命令:

perl Makefile.PL 
make make 
install

完毕 !!!

于 2012-10-10T04:55:18.460 回答