Practical Linux environment configuration DBD: Oracle Module

Source: Internet
Author: User

Web development involves two aspects: layout and content.
On the layout, the CGI Module of PERL is powerful and easy to use. In just a few lines, HTML webpages can be dynamically generated.

To be fair, you must use a database to manage the content. PERL supports a wide range of databases, and almost all mainstream databases have corresponding PERL module support. In order to develop PERL applications that can be transplanted to different databases, the DBI (DataBase Interface) module came into being. Using this module, applications can operate different databases only by using a unified Interface, it is truly portable. Of course, this DBI is also equipped with corresponding switches to support various features of different databases. Each database can be written separately. This article does not cover this point for the time being.

DBI is only an abstraction layer. To support different databases, you must write drivers for different databases under DBI. For MySql, there are DBD: Mysql, and for Oracle, It is DBD: Oracle. DBD is short for DataBase Driver.

The overall architecture is as follows:

Application)-> DBI-> DBD-> DB

To connect to different types of databases, You have to configure and install DBI and the corresponding DBD module on the host where the application is located. You can refer to this article for the installation and configuration of DBI, I will not re-build the wheel. The installation sequence is to first install DBI and then install DBD: Oracle.
DBD: The Oracle module is not officially developed by Oracle, but developed by Pythian Group, a famous DBA consulting company. The latest version is 1.22.
Next we will list the steps for installing DBD: Oracle as follows for your reference.

DBD: The Oracle module can be installed either on a host with an Oracle Database or on a host without an Oracle Database. The latter requires the Oracle Instant Client to be installed for remote Database connection, this article only focuses on the second configuration, that is, DBD: Oracle implements database access through the Instant Client.

Step 1: Download the Oracle Instant Client

Oracle Instant Client home page in http://www.oracle.com/technology/tech/oci/instantclient/index.html; Adhering to the Oracle company's consistent practice, the same software is divided into different Downloadable packages by configuration, so that users can according to their own needs, find the most appropriate part to download. To successfully configure DBD: Oracle, Basic, SQL * Plus, and SDK, You need to download these three packages and put them in the same directory, the three packages I have downloaded are as follows: the latest version is 11.1.0.7.

Shawn @ shawn-laptop:/tmp/InstantClient $ ls
Instantclient-basic-linux32-11.1.0.7.zip
Instantclient-sdk-linux32-11.1.0.7.zip
Instantclient-sqlplus-linux32-11.1.0.7.zip

Decompress the three zip files in the current directory by running the unzip command. The instantclient_11_1 directory is automatically generated. All the files in the preceding three packages are included in the package. The decompressed directory structure is as follows:

Shawn @ shawn-laptop:/tmp/InstantClient $ ls
Instantclient_11_1
Instantclient-basic-linux32-11.1.0.7.zip
Instantclient-sdk-linux32-11.1.0.7.zip
Instantclient-sqlplus-linux32-11.1.0.7.zip

At this time, the three zip files are useless and can be deleted or backed up for reuse in the future.

Step 2: Download DBD: Oracle


At this time, we can use the PERL built-in CPAN for automatic installation, or you can manually download this module, compile and install it, This article uses the latter.
DBD: Oracle in search.cpan.org isHttp://search.cpan.org/CPAN/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.22.tar.gzDownload the package and place it in a directory. Put it in/tmp and decompress the package as follows:

Shawn @ shawn-laptop:/tmp $ tarzxf DBD-Oracle-1.22.tar.gz
DBD-Oracle-1.22
Shawn @ shawn-laptop:/tmp/DBD-Oracle-1.22 $ ls
Changes Makefile. PL oraperl. ph README.login.txt
Dbdimp. c MANIFEST Oraperl. pm README.longs.txt
[... Omitted some screen output...]

Step 3: configure the ORACLE_HOME Environment Variable

If the Oracle Database software is installed, ORACLE_HOME is the value set when oracle is installed. When only the Instant Client is installed, this value is set to the absolute path of the instantclient_11_1 directory in step 1, as follows:

Shawn @ shawn-laptop:/tmp/DBD-Oracle-1.22 $ exportORACLE_HOME =/tmp/InstantClient/instantclient_11_1
Shawn @ shawn-laptop:/tmp/DBD-Oracle-1.22 $ echo $ ORACLE_HOME
/Tmp/InstantClient/instantclient_11_1

Step 4: Compile and install the DBD: Oracle Module


First, generate Makefile using PERL makefile. PL.

shawn@shawn-laptop:/tmp/DBD-Oracle-1.22$perl Makefile.PL
Using DBI 1.607 (for perl 5.008008 on i486-linux-gnu-thread-multi)
 installed in /usr/local/lib/perl/5.8.8/auto/DBI/
Configuring DBD::Oracle for perl 5.008008 on linux (i486-linux-gnu-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/tmp/InstantClient/instantclient_11_1
DEFINE _ SQLPLUS_RELEASE = "1101000700" (CHAR)
Oracle version 11.1.0.7 (11.1)
Looks like an Instant Client installation, okay
[... Omitted some screen output...]

Run make

Shawn @ shawn-laptop:/tmp/DBD-Oracle-1.22 $ 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
I/Driver. xst> Oracle. xsi
[... Omitted some screen output...]

Then switch to the root user make install

Shawn @ shawn-laptop:/tmp/DBD-Oracle-1.22 $ su
Password:
Root @ shawn-laptop:/tmp/DBD-Oracle-1.22 # makeInstall
[... Omitted some screen output...]

So far, DBD: After Oracle configuration and installation is complete, you can use this module to connect to Oracle for corresponding operations,

  1. Explain several Oracle Performance Tuning Methods
  2. Oracle DBA responsibilities and daily work analysis
  3. In-depth analysis of Oracle data block principles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.