本文只是學(xué)習(xí)如何配置PERL DBI、PERL DBD時(shí),整理的一個(gè)學(xué)習(xí)實(shí)踐文檔,大部分參考網(wǎng)上資料,詳情請(qǐng)見下面參考資料。
PERL對(duì)數(shù)據(jù)庫的支持廣而且全,幾乎所有的主流數(shù)據(jù)庫都有與之相應(yīng)的PERL模塊支持。為了開發(fā)可在不同數(shù)據(jù)庫上移植的PERL應(yīng)用,DBI(DataBase Interface)模塊應(yīng)運(yùn)而生,使用這個(gè)模塊,應(yīng)用只需使用統(tǒng)一的接口便能操作不同的數(shù)據(jù)庫,真正實(shí)現(xiàn)了可移植;當(dāng)然,這個(gè)DBI也配備有相應(yīng)的開關(guān)來支持不同數(shù)據(jù)庫的各種特性。
DBI只是個(gè)抽象層,要實(shí)現(xiàn)支持不同的數(shù)據(jù)庫,則需要在DBI之下,編寫針對(duì)不同數(shù)據(jù)庫的驅(qū)動(dòng)。對(duì)MySQL來說,有DBD::Mysql, 而對(duì)ORACLE來說,則是DBD::Oracle。其中的DBD這是DataBase Driver的簡寫。
安裝順序是先裝DBI,再裝DBD::Oracle,DBD::Oracle模塊不是Oracle官方開發(fā)的,而是由Pythian Group這個(gè)很有名的DBA咨詢公司組織專人開發(fā),目前的最新版本是1.74,主頁在http://www.pythian.com/resources/dba-resources/dbdoracle-PRoject/,讀者可以到那里找到關(guān)于此模塊的最新動(dòng)態(tài)。
1:檢查當(dāng)前系統(tǒng)的Perl版本
[root@getlnx01 ~]# perl -v
This is perl, v5.8.8 built for x86_64-linux-thread-multi
Copyright 1987-2006, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
2: 檢查驗(yàn)證系統(tǒng)中安裝了哪些Perl modules
check.pl腳本
#!/usr/bin/perl
use strict;
use ExtUtils::Installed;
my $inst=ExtUtils::Installed->new();
my @modules = $inst->modules();
foreach(@modules){my $ver = $inst->version($_) || "???";
printf("%-12s -- %s/n",$_,$ver);}
exit;
[root@getlnx01 tmp]# chmod +x check.pl
[root@getlnx01 tmp]# perl check.pl
Perl -- 5.8.8

3:具體安裝步驟
[root@getlnx01 tmp]# tar xvf DBI-1.627.tar
[root@getlnx01 tmp]# cd DBI-1.627
[root@getlnx01 DBI-1.627]# perl Makefile.PL
[root@getlnx01 DBI-1.627]# make
[root@getlnx01 DBI-1.627]# make test
[root@getlnx01 DBI-1.627]# make install

二: 安裝DBD-ORACLE組件,安裝步驟簡單如下所示:
[root@getlnx01 DBI-1.627]# cd /tmp
[root@getlnx01 tmp]# tar zxf DBD-Oracle-1.64.tar
[root@getlnx01 tmp]# cd DBD-Oracle-1.64
[root@getlnx01 DBD-Oracle-1.64]# export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1;
[root@getlnx01 DBD-Oracle-1.64]# export PATH=$ORACLE_HOME/bin:$PATH;
[root@DB-Server DBD-Oracle-1.64]# export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;
[root@DB-Server DBD-Oracle-1.64]# perl Makefile.PL
[root@getlnx01 DBD-Oracle-1.64]# perl Makefile.PL
Using DBI 1.627 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/site_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.
Installing on a linux, Ver#2.6
Using Oracle in /u01/app/oracle/product/10.2.0/db_1
DEFINE _SQLPLUS_RELEASE = "1002000400" (CHAR)
Oracle version 10.2.0.4 (10.2)
Found /u01/app/oracle/product/10.2.0/db_1/rdbms/demo/demo_rdbms.mk
Found /u01/app/oracle/product/10.2.0/db_1/rdbms/demo/demo_rdbms64.mk
Found /u01/app/oracle/product/10.2.0/db_1/rdbms/lib/ins_rdbms.mk
Using /u01/app/oracle/product/10.2.0/db_1/rdbms/demo/demo_rdbms.mk
Your LD_LIBRARY_PATH env var is set to '/u01/app/oracle/product/10.2.0/db_1/lib:/lib:/usr/lib'
Reading /u01/app/oracle/product/10.2.0/db_1/rdbms/demo/demo_rdbms.mk
Reading /u01/app/oracle/product/10.2.0/db_1/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 /u01/app/oracle/product/10.2.0/db_1/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:
新聞熱點(diǎn)
疑難解答
圖片精選