33

Please suggest a solution for solving this issue?? While giving the command:

sqlplus /nolog

the error that occurred:

 sqlplus: error while loading shared libraries:
 libsqlplus.so: cannot open shared object file: No such file or directory
jkeys
  • 3,803
  • 11
  • 39
  • 63
Priyanka U
  • 443
  • 1
  • 5
  • 8

16 Answers16

34

The minimum configuration to properly run sqlplus from the shell is to set ORACLE_HOME and LD_LIBRARY_PATH. For ease of use, you might want to set the PATH accordingly too.

Assuming you have unzipped the required archives in /opt/oracle/instantclient_11_1:

$ export ORACLE_HOME=/opt/oracle/instantclient_11_1
$ export LD_LIBRARY_PATH="$ORACLE_HOME"
$ export PATH="$ORACLE_HOME:$PATH"

$ sqlplus

SQL*Plus: Release 11.1.0.7.0 - Production on Wed Dec 31 14:06:06 2014
...
Nicolás Alarcón Rapela
  • 2,714
  • 1
  • 18
  • 29
Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125
  • 2
    yes, but only when executables and libraries are all in $ORACLE_HOME/ and not when they are installed in their own dirs like $ORACLE_HOME/bin/ and $ORACLE_HOME/lib/ –  Jan 23 '15 at 07:44
  • 1
    @ik_zelf Right. But for some reasons I assumed the OP was using SQL*Plus as provided as part of the [instantclient package](http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html). Those are mostly _flat_ archives with all libraries and binaries in the base directory. Of course, if you move the files after having extracted them as explained [here](http://ronr.blogspot.fr/2014/10/how-to-install-oracle-instant-client-on.html) ( ;) ), you have to adjust the various environment variables accordingly. – Sylvain Leroux Jan 23 '15 at 16:53
  • 1
    With Instant Client you shouldn't set ORACLE_HOME. The best thing to do is use the most recent version of Instant Client and follow [Oracle installation instructions](https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html#ic_x64_inst). – Christopher Jones Mar 12 '20 at 22:28
20
sudo sh -c "echo /usr/lib/oracle/12.2/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf";sudo ldconfig

from https://help.ubuntu.com/community/Oracle%20Instant%20Client

Toolkit
  • 10,779
  • 8
  • 59
  • 68
  • 1
    Even if you install from a RPM, you still need this little bit of magic sauce that allows sqlplus to work (with corrections to the correct version of the Oracle client, of course). Setting the LD_LIBRARY_PATH environment variable, as so many other pages suggest, does not work. It's a shame that it needs to be wired into the system, because it turns it from a "download the client and run it" to "get a syadmin's help to install it". – Andrew Beals Sep 21 '18 at 17:10
  • 4
    Version 18.3 is the current version and this little bit of script will also get around weirdly restrictive sudo permissions: `echo /usr/lib/oracle/18.3/client64/lib > /tmp/oracle-instantclient.conf ; sudo cp /tmp/oracle-instantclient.conf /etc/ld.so.conf.d ; sudo ldconfig` – Andrew Beals Sep 28 '18 at 14:38
  • 2
    With 19c, the `ldconfig` command is run automatically when the RPMs are installed. – Christopher Jones Mar 12 '20 at 22:26
14

I did solve this error by setting

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME

yes, not only $ORACLE_HOME/lib but $ORACLE_HOME too.

Leon Rom
  • 537
  • 4
  • 6
9

You should already have all needed variables in /etc/profile.d/oracle.sh. Make sure you source it:

$ source /etc/profile.d/oracle.sh

The file's content looks like:

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

If you don't have it, create it and source it.

forzagreen
  • 2,509
  • 30
  • 38
4

I know it's an old thread, but I got into this once again with Oracle 12c and LD_LIBRARY_PATH has been set correctly. I have used strace to see what exactly it was looking for and why it failed:

 strace sqlplus /nolog

sqlplus tries to load this lib from different dirs, some didn't exist in my install. Then it tried the one I already had on my LD_LIBRARY_PATH:

open("/oracle/product/12.1.0/db_1/lib/libsqlplus.so", O_RDONLY) = -1 EACCES (Permission denied)

So in my case the lib had 740 permissions, and since my user wasn't an owner or didn't have oracle group assigned I couldn't read it. So simple chmod +r helped.

michal
  • 323
  • 3
  • 15
  • This helped me to find out the cause. The installer is really awful. I had to reinstall it so the paths are correct. – Leon Aug 14 '18 at 03:47
4

On Ubuntu Server 20.04 and using instant client version 19.10.0.0, I used alien to install the rpm package. I got this error when I just used the -i option. However when, I added -c I did not have this issue. from the man page for alien:

-c, --scripts
Try to convert the scripts that are meant to be run when the package is installed and removed. Use this with caution, because these scripts might be designed to work on a system unlike your own, and could cause problems. It is recommended that you examine the scripts by hand and check to see what they do before using this option.

So it seems the correct configuration (in 19c) or the environment variables (in earlier versions) are set in these scripts which are not generated unless you run alien like this. (Thanks @Christopher Jones for correcting me on this)

sudo alien -i -c BasicPackage.rpm
sudo alien -i -c SqlPlus.rpm
hayden.mumm
  • 101
  • 1
  • 6
  • To be technical, the 19c (and later) RPMs create `/etc/ld.so.conf.d/oracle-instantclient.conf` and run `ldconfig`. There is no environment variable – Christopher Jones Apr 06 '21 at 22:39
3

PERMISSIONS: I want to stress the importance of permissions for "sqlplus".

  1. For any "Other" UNIX user other than the Owner/Group to be able to run sqlplus and access an ORACLE database , read/execute permissions are required (rx) for these 4 directories :

    $ORACLE_HOME/bin , $ORACLE_HOME/lib, $ORACLE_HOME/oracore, $ORACLE_HOME/sqlplus

  2. Environment. Set those properly:

    A. ORACLE_HOME (example: ORACLE_HOME=/u01/app/oranpgm/product/12.1.0/PRMNRDEV/)

    B. LD_LIBRARY_PATH (example: ORACLE_HOME=/u01/app/oranpgm/product/12.1.0/PRMNRDEV/lib)

    C. ORACLE_SID

    D. PATH

     export PATH="$ORACLE_HOME/bin:$PATH"
    
gidi gob
  • 51
  • 1
  • 6
2

You can try usage:

# echo "/usr/lib/oracle/12.2/client64/lib" > /etc/ld.so.conf.d/oracle.conf
# ldconfig

This problem are because oracleinstant client not configure shared library.

ndmeiri
  • 4,979
  • 12
  • 37
  • 45
1

Could you please check if LD_LIBRARY_PATH points to the oracle libs

Charmi
  • 594
  • 1
  • 5
  • 20
1

Don't forget

apt-get install libaio1 libaio-dev

or

yum install libaio
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
1

On Oracle's own Linux (Version 7.7, PRETTY_NAME="Oracle Linux Server 7.7" in /etc/os-release), if you installed the 18.3 client libraries with

sudo yum install oracle-instantclient18.3-basic.x86_64
sudo yum install oracle-instantclient18.3-sqlplus.x86_64

then you need to put the following in your .bash_profile:

export ORACLE_HOME=/usr/lib/oracle/18.3/client64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME

in order to be able to invoke the SQLPlus client, which, incidentally, is called sqlplus64 on this platform.

András Aszódi
  • 8,948
  • 5
  • 48
  • 51
  • 1
    It's much easier to use the 19c Instant Client RPMs which do the equivalent configuration for you without you needing to set environment variables. Also, with Instant Client you shouldn't set ORACLE_HOME. And the general recommendation is to use `ldconfig` instead of `LD_LIBRARY_PATH` if possible - check the Instant Client installation instructions. – Christopher Jones Mar 12 '20 at 22:24
  • @ChristopherJones Thank you for the tip. I installed the 18.3 client because when I ran `yum search instantclient` on the abovementioned system, only that showed up (this is an "Always Free VM" in the Oracle Cloud BTW). I assume the 19c Instant Client RPMs must be downloaded separately or some other repo must be added to `yum` -- I haven't had time to explore that option yet. But I was somewhat surprised to see that so much after-configuration is needed after installing a package... – András Aszódi Mar 13 '20 at 10:30
1

This worked for me: sudo dnf install libnsl

0

It means you didn't set ORACLE_HOME and ORACLE_SID variables. Kindly set proper working $ORACLE_HOME and $ORACLE_SID and after that execute sqlplus /nolog command. It will be working.

doc123
  • 106
  • 6
0

@laryx-decidua: I think you are only seeing the 18.x instant client releases that are in the ol7_oci_included repo. The 19.x instant client RPMs, at the moment, are only in the ol7_oracle_instantclient repo. Easiest way to access that repo is:

yum install oracle-release-el7

0

As mentioned on Oracle documentation, check the runtime link path ie. https://www.oracle.com/fr/database/technologies/instant-client/linux-x86-64-downloads.html

If Instant Client is the only Oracle Software installed on this system then update the runtime link path, for example:

sudo sh -c "echo /opt/oracle/instantclient_19_3 > \
      /etc/ld.so.conf.d/oracle-instantclient.conf" 
sudo ldconfig 

Using docker image nginx:stable


apt-get update -y
apt-get upgrade -y
apt-get install -y wget
apt-get install -y unzip
apt-get install -y libaio1

mkdir /opt/oracle
cd /opt/oracle

wget https://download.oracle.com/otn_software/linux/instantclient/219000/instantclient-basic-linux.x64-21.9.0.0.0dbru.zip
unzip instantclient-basic-linux.x64-21.9.0.0.0dbru.zip

wget https://download.oracle.com/otn_software/linux/instantclient/219000/instantclient-sqlplus-linux.x64-21.9.0.0.0dbru.zip
unzip instantclient-sqlplus-linux.x64-21.9.0.0.0dbru.zip

wget https://download.oracle.com/otn_software/linux/instantclient/219000/instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip
unzip instantclient-sdk-linux.x64-21.9.0.0.0dbru.zip

sh -c "echo /opt/oracle/instantclient_21_9 > /etc/ld.so.conf.d/oracle-instantclient.conf"
ldconfig

export ORACLE_HOME=/opt/oracle/instantclient_21_9
export LD_LIBRAY_PATH=$ORACLE_HOME
export PATH=$PATH:$ORACLE_HOME

sqlplus
David KELLER
  • 464
  • 4
  • 8
0

In my case /Red Hat) I had to install libnsl :

yum install libnsl.x86_64

With the command "strace sqlplus /nolog" I found:

openat(AT_FDCWD, "/usr/lib/oracle/12.2/client64/lib/libnsl.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

And googling I found the solution.

Majid Hajibaba
  • 3,105
  • 6
  • 23
  • 55