Selasa, 07 Mei 2019

Install Oracle Instant Client on Linux CentOS


The installation of an Oracle client on a server is always a tedious task and although you have done it many times, there are always things to review.

In this case we are going to install an Oracle InstantClient of version 11 for the CentOS operating system.

As we also want to be able to compile applications that will be used by Oracle libraries, we will also have to install the header files.


Download installation packages


The installation files can be found at this URL:

https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

The client version to be used is 11.2.0.4.0

The packages to download are:

oracle-instantclient11.2-basic-11.2.0.4.0–1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0–1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.4.0–1.x86_64.rpm

The package with sqlplus is only needed to check that the installation was correct


Installing the RPM files


We proceed to the installation of previously downloaded packages

$ sudo yum localinstall -y oracle-instantclient11.2-basic-11.2.0.4.0–1.x86_64.rpm
$ sudo yum localinstall -y oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
$ sudo yum localinstall -y oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm


Environment Variables


We will need to define some environment variables for the Oracle client to work correctly

$ export ORACLE_HOME=/usr/lib/oracle/11.2/client64
$ export TNS_ADMIN=$ORACLE_HOME/network/admin
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
$ export PATH=$PATH:$ORACLE_HOME/bin

To be able to work with the tnsnames.ora file, we will have to copy it to the directory defined in the environment variable

$ sudo mkdir -p /usr/lib/oracle/11.2/client64/network/admin

Create new /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora like this:

TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS =       
          (PROTOCOL = TCP)
          (Host = testdboracle)
          (Port = 1521)
        )
    )
    (CONNECT_DATA = (SID = ORCL)
    )
  )


Installation test


To verify that the installation was correct, we will open a sqlplus session against one of our databases

Connect to Your database with:

$ sqlplus scott/tiger@TEST

You can also use the Easy Connect connection string format (does not use TNSNAMES):

$ sqlplus scott/tiger@testdboracle:1521/ORCL


Tidak ada komentar: