oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.25k stars 1.07k forks source link

DPI-1047: Cannot locate 64-bit Oracle Client library: libclntsh.so error with Docker #1617

Closed saikoushik5 closed 10 months ago

saikoushik5 commented 11 months ago
  1. What versions are you using?

Give your database version: Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production Version 19.17.0.0.0

Node Version:  12.22.9
oracledb:  "^5.0.0"
  1. Is it an error or a hang or a crash? Error

  2. What error(s) or behavior you are seeing?

image

  1. Include a runnable Node.js script that shows the problem.
const oracledb = require('oracledb');
const config = {
  user: 'testuser',
  password: 'testpassword',
  connectString: `(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(Host = 'testhost')(Port = 1522,
    )})))(CONNECT_DATA =(sid = 'testsid')(SERVER=dedicated)))`,
};
let conn;
try {
  conn = await oracledb.initOracleClient(config);
} catch (err) {
  console.error('Whoops!');
  console.error(err);
  process.exit(1);
} finally {
  conn.close();
}

Please help me resolve this error.

sharadraju commented 11 months ago

Please upgrade to the latest version node-oracledb 6.2 and also use Node.js 14.6 or later. If this issue still persists, let us know, if you have configured LD_LIBRARY_PATH to point to the Oracle Instant Client libraries.

saikoushik5 commented 11 months ago

@sharadraju node v12 and oracle v5.0.0 working in local. but the issue I have raised happening only in docker.

cjbj commented 11 months ago

@saikoushik5 see Docker for Oracle Database Applications in Node.js and Python.

saikoushik5 commented 11 months ago

@saikoushik5 see Docker for Oracle Database Applications in Node.js and Python.

@sharadraju @cjbj From oracledb v6.2.0, is it mandatory to use Oracle Instant client image in docker while doing the CI build? Is my understanding correct? We have an existing old application with oracledb version v5.0.0, and we didn't install any Oracle related docker images in our CI pipeline and its working like a charm till few days back.

cjbj commented 11 months ago

From oracledb v6.2.0, is it mandatory to use Oracle Instant client image in docker while doing the CI build?

You don't need to use an Oracle-owned or -created image. But with node-oracledb 5.x you do need Oracle client libraries installed somehow. The blog post gives tips.

Since you now state that your setup used to work, then you will need to dig into what has changed.

From node-oracledb 6.0 the Instant Client itself is optional but does give some extra functionality. We now call that mode 'Thick mode', see https://node-oracledb.readthedocs.io/en/latest/user_guide/appendix_a.html for the differences.

saikoushik5 commented 11 months ago

Please upgrade to the latest version node-oracledb 6.2 and also use Node.js 14.6 or later. If this issue still persists, let us know, if you have configured LD_LIBRARY_PATH to point to the Oracle Instant Client libraries.

@sharadraju I have upgraded the oracledb package to 6.2.0 and Node to v14.18.3. And now I get this error. Any suggestions? image

sharadraju commented 11 months ago

@saikoushik5 This error means that the oracledb package has not been installed locally to the Nestjs or typeorm directory that you have.

As the error indicates, please run npm install oracledb --save in the directory where your typeorm/nest.js app is running.

sharadraju commented 10 months ago

@saikoushik5 Please let us know if you were able to progress on this issue?

saikoushik5 commented 10 months ago

@saikoushik5 Please let us know if you were able to progress on this issue? Yes. It's resolved. Thanks for asking

sharadraju commented 10 months ago

Great! Please let us know how you solved the issue as well. It will useful for other users.

saikoushik5 commented 10 months ago

Great! Please let us know how you solved the issue as well. It will useful for other users.

We added this code in our Dockerfile and freeze the package version to 5.0.0 and its working.

# Install oracleclient USER root RUN wget https://objs3parlow01.fr.world.socgen:4443/byo-ad016-dev-acid/oracle/oracle-instantclient-basic-21.5.0.0.0- 1.x86_64.rpm && \ mv oracle-instantclient-basic-21.5.0.0.0-1.x86_64.rpm /tmp/ && \ yum -y install /tmp/oracle-instantclient*.rpm && echo /usr/lib/oracle/21.5/client64/lib > /etc/ld.so.conf.d/oracle-instantclient21.5.conf && ldconfig

ENV PATH=$PATH:/usr/lib/oracle/21.5/client64/bin

USER $user