因為突然說要把某些資料寫到 Oracle database, 偏偏 Red Hat 9 的那台舊 Server 不支援 Oracle, 又正好 Glibc 是 2.3.2 版, 新版本的 Oracle Instant Client 10.2 以上版本都只支援 Glibc 2.3.3 以上版本, 因此, 就算成功 ReBuild PHP, 也是沒法使用, 只得下載 Oracle Instant Client 10.1 版本, 才有向下相容, 下面轉貼的這篇文章, 分享如何安裝 Oracle Client 包含 Oci8 的PHP5套件, 有需要的朋友請參考, 這個也搞了一個晚上, 多少有點經驗 ,若有遇上問題, 歡迎留言, 若你的問題我正好也遇到, 那我會回覆於板上的,謝謝大家.

Oracle ODBC Driver Unix Getting Started Guide

This guide shows you how to download, install and license the Oracle ODBC driver.

At the end, you will be able to access your Oracle databases (version 8.1.7 or above) from Unix systems using isql, an interactive SQL tool installed with unixODBC, the open source Driver Manager that is included in the ODBC driver distribution.

The process will take approximately 10–15 minutes, excluding software download time.

If you are installing in order to evaluate the ODBC driver, the process will allow you to obtain a free trial license.

Assumptions

  • The ODBC driver is to be installed on a Unix system to which you have root access.

Before You Begin

What You Need to Know

Obtain this information from your Oracle Database Administrator:

  • The host name or IP address of the Oracle database server.
  • The service name that identifies the database you want to connect to.
  • The Oracle listener port.
  • The Oracle database username and password.

Pre-requisites

Easysoft provide two variants of the Oracle ODBC driver: an OCI driver and a Wire Protocol (WP) driver. The OCI driver uses Oracle client software to access Oracle. If you are using the OCI driver, refer to the following section for information about obtaining, installing and testing this pre-requisite software. The WP driver does not use Oracle client software. If you are using the WP driver, skip the client software section and follow the instructions in Downloading, Installing and Testing the ODBC Driver.

Oracle Client Software

Although the OCI driver is compatible with both the standard Oracle Client and the Instant Client, this guide describes how to use the driver with the Instant Client. This is because the Instant Client:

  • Is quick to download and easy to install.
  • Is available for more platforms than the standard client.
  • Uses significantly less disk space than the standard client.
  • Is available for Oracle 10g, Oracle 11g and Oracle Database XE and backwards-compatible with Oracle 8, Oracle 9i.

If you want to use the standard Oracle Client (for example, you will be installing the ODBC driver on a machine where the Oracle Client is already installed), you can still follow the instructions in this guide. The process is the same for both versions of the client, unless noted otherwise in Notes on the Standard Oracle Client.

Install and test the Oracle Instant Client

  1. Visit the Oracle web site and login. If you have not yet done so, you need to register first.

    You need to be a registered Oracle user to download the Instant Client.

  2. Choose the Instant Client for your client platform at:

    http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html

  3. Download the Basic and SQL*Plus Instant Client Packages.

    These packages contain the Instant Client and a version of SQL*Plus that is compatible with the Instant Client. SQL*Plus lets you test that you can access Oracle with the Instant Client.

    Notes

    • On Linux, the Instant Client 10.2 requires a minimum of glibc 2.3.3. To check the glibc version, on the Linux system, look at the first line of the output produced by running /lib/libc.so.6 (on some platforms, libc.so.6 is located in /usr/lib):
      /lib/libc.so.6
      GNU C Library stable release version 2.3.2, by Roland McGrath et al.

      If you do not have the required glibc version, you need to download the Instant Client 10.1 packages. The Instant Client 10.1 is compatible with earlier versions of glibc.

    • On Linux, the Instant Client 11.1 requires glibc 2.3.3 or later and the libaio package (version 0.3 or later).
  4. On the machine from which you want to access Oracle, extract the Instant Client and SQL*Plus files. For example:
    cd /tmp
    unzip instantclient-basic-linux32-10.2.0.2-20060331.zip -d /usr/lib
    unzip instantclient-sqlplus-linux32-10.2.0.2-20060331.zip -d /usr/lib
  5. Add the Instant Client directory path to the LD_LIBRARY_PATH environment variable and export LD_LIBRARY_PATH. For example:
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/instantclient_10_2
    export LD_LIBRARY_PATH

    Replace /usr/lib with the directory where you extracted the Instant Client. For the Instant Client 10.1, replace instantclient_10_2 with instantclient10_1.

    Note On AIX, replace LD_LIBRARY_PATH with LIBPATH.

  6. Use SQL*Plus to test that you can access Oracle. For example:
    cd /usr/lib/instantclient_10_2
    ./sqlplus username/password@//machine_name:port/database_name

    where:

    • username and password are the database username and password.
    • machine_name is the host name or IP address of the Oracle database server.
    • port is the Oracle listener port.
    • database_name is the service name associated with the database you want to access.

    Note If you are unable to connect to Oracle with SQL*Plus, contact your Oracle Database Administrator. If you cannot access your Oracle database with SQL*Plus, you will not be able to access the database with the OCI driver.

  7. At the prompt, type a SELECT statement to test that you can retrieve some data:
    select * from dual;

    To exit SQL*Plus, type exit.

Downloading, Installing and Testing the ODBC Driver

The process has four steps:

  1. Login.
  2. Download the ODBC driver software.
  3. Install and configure the ODBC driver.
  4. Access your data sources.

Step 1. Login

  • Visit the Easysoft web site (http://www.easysoft.com) and login. If you have not yet done so, you need to register first. On the registration form, an asterisk (*) indicates that a field is mandatory.

Step 2. Download the ODBC driver software

  1. Download the ODBC driver.
  2. In the Download page, select the platform you require and click Download.
  3. Follow your browser instructions to save the distribution file to a temporary directory on the target machine.

Step 3. Install and configure the ODBC driver

  1. Login to your Unix system and change to the directory where you have saved the distribution.
  2. Untar the distribution file using the following command, substituting the version number and platform from your distribution filename. For example:
    tar -xvf odbc-oracle-version-platform.tar
  3. cd into the directory created by unpacking the distribution file. For example:
    cd odbc-oracle-version-platform
  4. As root, type ./install to start the install. After you have accepted the License Agreement, accept the defaults throughout the installation.
  5. When prompted to choose a product to license, choose the ODBC driver by typing its option number. For example:
    [0] Exit
    [1] View existing licenses
    [2] Oracle ODBC Driver V3.2
    
    Please choose the product you would like a license for by entering its
    item number or enter one of the other options.
    
    Option: 2

    Next, you need to supply:

    1. Your full name
    2. Your company name
    3. An email contact address. This must be the email address you registered on the Easysoft web site.
    4. Your telephone number (you need to specify this if you telephone the license request to us).
    5. Your fax number (you need to specify this if you fax the license request to us).
    6. A reference number. When applying for a trial license just press <Enter> on this field as this field is used to enter a reference number we will supply you for full (paid) licenses.

    You will then be asked for a method of obtaining the license. To obtain a license automatically, you will need to be connected to the Internet and allow outgoing connections to license.easysoft.com on port 8884. If you are not connected to the Internet or do not allow outgoing connections on port 8884, the License Client can create a license request file which you can:

    1. Enter at http://www.easysoft.com/support/licensing/trial_license.html to obtain your license.
    2. Mail, fax or telephone to Easysoft.

    If you choose option [2] the license request is written to the file license_request.txt and you should exit the License Client via option [0] and complete the installation. Once you have mailed, faxed or telephoned the license request to us, we will return a license key, which you should add to the end of the file /usr/local/easysoft/license/licenses.

  6. When prompted to create the sample data source, enter:
    • The host name or IP address of the Oracle database server.
    • The service name that identifies the database you want to connect to.
    • The Oracle listener port.
    • The Oracle database username and password.

    At the end of the installation, you will have installed and licensed the ODBC driver, installed the unixODBC Driver Manager and created an ODBC data source.

  7. Set and export the LD_LIBRARY_PATH environment variable:
    EASYSOFT=/usr/local/easysoft
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EASYSOFT/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EASYSOFT/unixODBC/lib
    export LD_LIBRARY_PATH

    Note On AIX, replace LD_LIBRARY_PATH with LIBPATH.

  8. If you are using the OCI version of the ODBC driver, set LD_LIBRARY_PATH to include the driver directory and the Instant Client directory. For example:
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EASYSOFT/oracle
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/instantclient_10_2
    export LD_LIBRARY_PATH

Step 4. Access your data sources

  • Use isql to test the new data source:
    cd /usr/local/easysoft/unixODBC/bin
    ./isql -v <sample_oracle_dsn>

    At the prompt, type "help" to display a list of tables. To exit, press return in an empty prompt line.

What Next?

Further Support

Notes on the Standard Oracle Client

Refer to this section if you want to use the OCI version of the ODBC driver with the standard Oracle client.

  • Obtain this information from your Oracle Database Administrator:

    • The tnsnames.ora service name for the Oracle database.
    • The Oracle database username and password.
  • To download the standard Oracle Database 10g Client or later, choose your client platform at:

    http://www.oracle.com/technology/software/products/database/index.html

    Alternatively, contact your Oracle Database Administrator for the Oracle distribution CD. The Oracle Client is included in the Oracle distribution.

    For installation instructions, refer to the relevant Oracle Client Installation Guide. (To access this manual at the Oracle web site, search the Oracle documentation for "Client Installation Guide" at: http://www.oracle.com/technology/documentation/index.html)

  • When prompted to create an ODBC data source during the Easysoft ODBC-Oracle Driver installation, enter:
    • The tnsnames.ora service name for the Oracle database.
    • The Oracle database username and password.
  • Set and export ORACLE_HOME rather than LD_LIBRARY_PATH to specify the directory where the Oracle client is installed. For example:
    ORACLE_HOME=/home/oracle/OraHome1
    export ORACLE_HOME
  • You need to include $ORACLE_HOME/lib when setting LD_LIBRARY_PATH. For example:
    EASYSOFT=/usr/local/easysoft
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EASYSOFT/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EASYSOFT/oracle
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EASYSOFT/unixODBC/lib
    export LD_LIBRARY_PATH
資料來源:http://www.easysoft.com/products/data_access/odbc_oracle_driver/getting_started.html

創作者介紹

經驗交流分享與備忘

Frank 發表在 痞客邦 PIXNET 留言(0) 人氣()