Install SQL Instant client on Ubuntu

Install SQL Instant client on Ubuntu

Directly we don’t have the RPM/Zip Packages to install the instant client on Ubuntu, as we need to download the Linux Packages/Zip Files from the Oracle Site (http://www.oracle.com/technetwork/database/features/instant-client/index...)  And convert into Ubuntu compatible then install.

The below are the files to download & place into opt directory # /opt

root@xyz-deploy:/opt# ls

instantclient-basic-linux.x64-12.2.0.1.0.zip
instantclient-sqlplus-linux.x64-12.2.0.1.0.zip

Before unzip the above files, we need to install some packages like alien & unzip etc, Internet access should be present on server

Take the backup of the source.list file & make some changes to existing source file

Verify the internet

root@xyz-deploy:/opt#ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=36 time=141 ms

root@xyz-deploy:/opt#cp /etc/apt/sources.list /etc/apt/sources.list_bckup

root@xyz-deploy:/opt#vim /etc/apt/sources.list

root@xyz-deploy:/opt# vi /etc/apt/sources.list

# deb cdrom:[Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801)]/ xenial main restricted

#deb cdrom:[Ubuntu-Server 16.04.3 LTS _Xenial Xerus_ - Release amd64 (20170801)]/ xenial main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirror.iranserver.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirror.iranserver.com/ubuntu/ xenial-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirror.iranserver.com/ubuntu/ xenial universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://mirror.iranserver.com/ubuntu/ xenial-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirror.iranserver.com/ubuntu/ xenial multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://mirror.iranserver.com/ubuntu/ xenial-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirror.iranserver.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse

:wq!

root@xyz-deploy:/opt#apt-get install alien
or
root@xyz-deploy:/opt# apt-get -f install alien

root@xyz-deploy:/opt# apt-get clean

root@xyz-deploy:/opt#apt-get update

root@xyz-deploy:/opt#apt-get upgrade –f

Choose (Yes) to continue

root@xyz-deploy:/opt#apt-get -f install unzip

Verify the alien & unzip are install

root@xyz-deploy:/opt# ali
alias  alien
root@xyz-deploy:/opt# unzip
unzip     unzipsfx

Now start the installation of the Instant Client

root@xyz-deploy:/opt# unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
root@xyz-deploy:/opt#unzip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip

root@xyz-deploy:/opt# ls

instantclient-basic-linux.x64-12.2.0.1.0.zip instantclient-sqlplus-linux.x64-12.2.0.1.0.zip  likewise  pbis  instantclient_12_1

Rename the default instantclient_12_1 directory to sqlplus:

root@xyz-deploy:/opt# mv instantclient_12_1 sqlplus

Create a log folder:

root@xyz-deploy:/opt#mkdir -p /opt/sqlplus/log/diag/clients

Configure

Need to Add /opt/sqlplus to the shared library path LD_LIBRARY_PATH:

root@xyz-deploy:/opt# export LD_LIBRARY_PATH=/opt/sqlplus:${LD_LIBRARY_PATH}

Also add /opt/sqlplus to the PATH variable to avoid using absolute/relative paths:

root@xyz-deploy:/opt# export PATH=/opt/sqlplus:${PATH}

Set SQLPATH /opt/sqlplus so glogin.sql can be found:

root@xyz-deploy:/opt# export SQLPATH=/opt/sqlplus:${SQLPATH}

Note that no ORACLE_HOME or ORACLE_SID environment variables need to be set for SQL Plus Instant Client.

Now, we want those variables to be persistent across system reboots. We also want those variables to be set for all users when they log in to the system so they can use sqlplus client without a need to export variables.
Listed below are the files that are processed when a regular user logs in (when Bash is invoked as an interactive login shell):
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile

The first file that is processed when logging in is /etc/profile. This file sets file sets the global environment for all users.
The user’s ~/.bash_profile is run only if it exists. If the file is missing, bash then looks for a ~/.bash_login to run. If that file is also missing, bash finally tries to run ~/.profile.
It is likely that ~/.bash_profile and ~/.bash_login files may not exits on a system.
In this case the best way to set global environment variables for all users is to put them into /etc/profile.

root@xyz-deploy:/opt# echo "export LD_LIBRARY_PATH=/opt/sqlplus:${LD_LIBRARY_PATH}" >>/etc/profile

root@xyz-deploy:/opt# echo "export PATH=/opt/sqlplus:${PATH}" >>/etc/profile

root@xyz-deploy:/opt# echo "export SQLPATH=/opt/sqlplus:${SQLPATH}" >>/etc/profile

root@xyz-deploy:/opt# sqlplus 'mir@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.120.125) (PORT=1521))(CONNECT_DATA=(SID=etick)))'

You get the error as below

“sqlplus: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory”

No worries – Install the below packages & then run

Make sure you have the libaio1 library installed:
# apt-get update && apt-get install libaio1

Again try to Test & verified

root@xyz-deploy:/opt# sqlplus 'mir@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.xxx.xxx) (PORT=1521))(CONNECT_DATA=(SID=xyz)))'

SQL*Plus: Release 12.2.0.1.0 Production on Tue Aug 29 09:08:52 2017

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data mining and Real Application testing options

SQL>

Hence it’s resolved




Comments

Popular posts from this blog

ORA-01110: data file 1: '/oradata/datafiles/system01.dbf'

Expdp from Higher version 12c (12.1.0.2) to lower version 11g (11.2.0.4)

Solutions: error while starting of Oracle Single instance ASM Database