2012-10-10 159 views
0

我想要做的就是連接並通過perl的檢索從oracle數據庫的數據是什麼。Perl的DBI/Perl的DBD-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 [email protected] -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 /應用/ ORACLE /產品/ 102/lib中/ libnnz10的許可。所以。
我的機器是在CentOS 5.5發佈和10g企業版發佈10.2.0.5.0 ... 我缺少什麼?

+0

感謝您的意見... – KIM

回答

2

聽起來像SELinux的一個問題。嘗試禁用它,看看這是否可以解決您的問題: http://www.crypt.gen.nz/selinux/disable_selinux.html

+0

感謝您的幫助......不幸的是,服務器不能重新啓動。 – KIM

+0

@KIM,公正,僅供參考,但你可以禁用SELinux使用以下命令行:setenforce 0 – BillMan

1

我不知道你錯過了什麼和你要去哪裏錯了。但我總是遵循下面的方法,它爲我工作了100%。試試這個方法,如果不工作的話,我絕對可以讓它爲你工作....

一兩件事,我在您的文章注意的是,你所得到的權限問題。嘗試以root身份運行這些步驟。

我的環境:甲骨文11G在遠程機器上運行

我的臺式機:ubunt/Fedora的/ RHEL/CenOS

我已經實現了這上面所有4種口味的Linux,他們都很好地工作。

以下是具體步驟(按照「時間給出的順序):

安裝Perl DBI模塊

安裝下面3轉Oracle即時客戶端從http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

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從CPAN您PATH變量

下載DBD::Oracle ver 1.44。 解壓模塊並在給定的順序運行下面的命令:

perl Makefile.PL 
make make 
install 

DONE !!!