39

I am working on AWS services. I have an ec2 ( centos ) instance. I need to configure SQL*Plus client on this centos machine.

The server with whom I want to connect is at some remote area. The server version is oracle-se(11.2.0.2)

How can I get the client installed on the CentOS machine?

starball
  • 20,030
  • 7
  • 43
  • 238
Megha Sharma
  • 2,235
  • 8
  • 27
  • 31

6 Answers6

97

Go to Oracle Linux x86-64 instant clients download page

Download the matching client

oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm

Install

rpm -ivh oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm

Set environment variables in your ~/.bash_profile

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

Reload your .bash_profile by simply typing source ~/.bash_profile (suggested by jbass) or Log-out user and log-in again.

Now you're ready to use SQL*Plus and connect your server. Type in :

sqlplus "username/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.1)(PORT=1521))(CONNECT_DATA=(SID=YOURSID)))"
Chamara Keragala
  • 5,627
  • 10
  • 40
  • 58
  • Hi I have installed it now when I am trying to connect to the server it is givig me an error : `-bash: sqlplus: command not found` – Megha Sharma May 06 '14 at 09:57
  • Okay i added the `export ORACLE_SID= "oracledb" export ORACLE_HOME=/usr/lib/oracle/11.2/client64/ export PATH=$ORACLE_HOME/bin:$PATH` in bash_prfile. Now when I try to connect it gives me error: `sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory` – Megha Sharma May 06 '14 at 10:33
  • @MeghaSharma try setting env variable `export LD_LIBRARY_PATH=$ORACLE_HOME/lib` – Chamara Keragala May 06 '14 at 10:54
  • @MeghaSharma Pls refer the updated answer. Thank you. – Chamara Keragala May 06 '14 at 11:18
  • 2
    I have done everything but now getting this error :`ERROR: ORA-12154: TNS:could not resolve the connect identifier specified` – Megha Sharma May 06 '14 at 11:20
  • @MeghaSharma can you show how you're trying to connect to SQL*Plus? Your whole sqplus command – Chamara Keragala May 06 '14 at 11:28
  • `sqlplus "rdsuser@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=oracledbrds.abcdefg.us-east-2.rds.amazonaws.com)(Port=1521))(CONNECT_DATA(SID=oracledb)))"` the oracle server is residing on AWS RDS instance. – Megha Sharma May 06 '14 at 11:42
  • Its done. there was an error in the command. was giving double quotes instead of single quotes. – Megha Sharma May 06 '14 at 11:57
  • Do we need to set `NS_ADMIN` and how to import dump to the server. Kindly check my question and please help m eout – Megha Sharma May 07 '14 at 07:18
  • 1
    I cant find the TNSNAMES.ORA in the home directory of oracle – Megha Sharma May 07 '14 at 08:11
  • Please help, I think so the instant client don't have all the packages the bin folder has `adrci genezi sqlplus` – Megha Sharma May 07 '14 at 11:52
  • 2
    the admin/network directory is also not there. Also the bin dir contains only adrci genezi sqlplus. I am not able to import the dump – Megha Sharma May 07 '14 at 13:07
  • @MeghaSharma Under your $ORACLE_HOME (after setting up .bash_profile properly), create these directories: `mkdir -p $ORACLE_HOME/network/admin` (Also, it should be network/admin, not admin/network). Then create `tnsnames.ora` file under `$ORACLE_HOME/network/admin`, and add your tns entries in it. That worked for me. – TheWalkingData Mar 09 '17 at 05:36
  • the sqlplus package does not install because the dependency to the basic package cannot be resolved ?!? this didnt seem to be an issue back then. – U.V. Nov 17 '22 at 11:28
6

The solution by @ChamaraKeragala is good, but it is unnecessary to logout/login. Instead type:

source ~/.bash_profile
jbass
  • 116
  • 1
  • 8
  • 5
    this should not be an answer but a comment, also is already integrated in the @ChamaraKeragala aswer ( accepted ) – Thomas8 Oct 26 '16 at 10:28
  • 5
    @Thomas8 It was added as an edit in ChamaraKeragala answer after jbass answer (it's specified in the answer as a thanks to). – krlzlx Oct 26 '16 at 14:39
2

For everyone still getting the following error:

sqlplus command not found

The original post refers to a set of environment variables, the most important of which is ORACLE_HOME. This is the parent directory where the oracle binaries get installed.

Depending on what version of oracle you downloaded you'll have to change the ORACLE_HOME accordingly. For example, the original question's ORACLE_HOME was set to:

ORACLE_HOME=/usr/lib/oracle/11.2/client64

My version of Oracle happens to be 12.1, so my ORACLE_HOME is set to:

ORACLE_HOME=/usr/lib/oracle/12.1/client64 

If you are unsure of the version that you downloaded, you can:

  1. cd /usr/lib/oracle after the installation and find the version.
  2. Look at the RPM file oracle-instantclient12.1, where the bolded bits would refer to the version number.
Madness
  • 2,730
  • 3
  • 20
  • 29
Naresh
  • 31
  • 1
2

There's a good blog post[1] on $subject. setup oracle client in ubuntu with minimum effort. Following are the main steps on how to step up the client. In my case, I was installing rpm files using alien package.

  1. Install alien and related packages

    sudo apt-get install alien

  2. Install oracle client packages using alien.

    sudo alien -i oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm

    sudo alien -i oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

In my opinion these two steps are the easiest way to install oracle client rpm's on your ubuntu system. (I'm not going to mention about export oracle specific variables as it's already clearly explained in above answers)

Hope it helps someone.

[1] http://pumuduruhunage.blogspot.com/2016/04/setup-oracle-sql-plus-client-on-aws.html

plr
  • 511
  • 3
  • 5
  • 15
0

For any one who is using proxy, you'd need to add an extra line to the bash profile. At least this is what made it work for me. I'm using cntlm.

export no_proxy=

Tadas V.
  • 39
  • 3
0

Install via zip (tried with 12_2)

First of all there is no need to set ORACLE_HOME.

Simply download the .zip files from here starting with the first one Basic: followed by SQL*Plus: and any additional zips you may need.

Extract them all under /opt/oracle

You will then have a directory: /opt/oracle/instantclient_x_y

On ubuntu I had to do also:

sudo apt install libaio1

To run:

# This can be also done by adding only the path below in: /etc/ld.so.conf.d/oracle-instantclient.conf
export LD_LIBRARY_PATH=/opt/oracle/instantclient_x_y:$LD_LIBRARY_PATH

# This can be added in ~/.profile or ~/.bashrc
export ORACLE_HOME=/opt/oracle/instantclient_x_y
/opt/oracle/instantclient_x_y/sqlplus user/pass@hostname:1521/sidorservicename

At the bottom of the the above link page there are more details.

Marinos An
  • 9,481
  • 6
  • 63
  • 96