node.js libclntsh.so.12.1:运行 node-oracledb 示例时无法打开共享对象文件错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29330841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:35:24  来源:igfitidea点击:

libclntsh.so.12.1 : cannot open shared object file error when running sample of node-oracledb

node.jsoraclenode-oracledb

提问by Ishan

My goal is to connect to a oracle database on a VMWare guest machine (OpenSuse) from Ubuntu.

我的目标是从 Ubuntu 连接到 VMWare 来宾计算机 (OpenSuse) 上的 oracle 数据库。

For now I have only installed the oracledbdriver, and was trying to run the example connect programgiven.

现在我只安装了oracledb驱动程序,并试图运行给出的示例连接程序

The steps that I am following are from the github INSTALLpage. What I have done till now are these :

我遵循的步骤来自 github INSTALL页面。到目前为止,我所做的是:

1) Since I have node.js already installed I skipped the step 3.1.

1) 因为我已经安装了 node.js,所以我跳过了步骤 3.1

2) I have successfully downloaded and extracted the basicand sdkas mentioned in step 3.2.

2)我已经成功下载并解压了步骤 3.2 中提到的基本sdk

3) Since I couldn't find any package named libaiobut I did found libaio1. So I installed libaio1.

3)由于我找不到任何命名的包,libaio但我确实找到了libaio1. 所以我安装了libaio1.

4) I made the environment variable LD_LIBRARY_PATHand the contents of it on my PC is /opt/oracle/instantclient.

4)我创建了环境变量LD_LIBRARY_PATH,它在我的电脑上的内容是/opt/oracle/instantclient.

5) As mentioned in step 3.3; even though it wasn't mandatory in my case; I made two environment variables: OCI_LIB_DIRwith contents /opt/oracle/instantclientand OCI_INC_DIRwith contents /opt/oracle/instantclient/sdk/include.

5) 如步骤 3.3 所述;即使在我的情况下这不是强制性的;我创建了两个环境变量:OCI_LIB_DIRwith contents/opt/oracle/instantclientOCI_INC_DIRwith contents /opt/oracle/instantclient/sdk/include

6) Installed node-oracledb.

6) 安装node-oracledb

I am trying to run the example connect program. The code that I am using is here https://github.com/ishanatmuz/oracle-test. When I run node connect.jsI am getting this error.

我正在尝试运行示例连接程序。我使用的代码在这里https://github.com/ishanatmuz/oracle-test。当我运行时,node connect.js我收到此错误。

/home/ishan/node.js/oracle-test/node_modules/oracledb/lib/oracledb.js:28
throw err;
          ^
Error: libclntsh.so.12.1: cannot open shared object file: No such file or directory
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/ishan/node.js/oracle-test/node_modules/oracledb/lib/oracledb.js:23:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (modullibclntsh.so.12.1e.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Since I haven't started the VMware guest machine yet; I was hoping of getting an error regarding no such database instance found. And then only after that run the VMWare machine and connect to the database inside it. But instead I am getting the error of cannot open shared object filefor libclntsh.so.12.1.

由于我还没有启动VMware来宾机器;我希望收到有关未找到此类数据库实例的错误。然后仅在此之后运行 VMWare 机器并连接到其中的数据库。但相反,我收到了cannot open shared object filefor的错误libclntsh.so.12.1

回答by Christopher Jones

My first suspicion would be that LD_LIBRARY_PATH is not actually set or exported correctly. Triple-check it is set and the directory is readable by the actual shell that attempts to start node.

我的第一个怀疑是 LD_LIBRARY_PATH 实际上没有正确设置或导出。三重检查它是否已设置,并且该目录可由尝试启动节点的实际 shell 读取。

export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2

You need to do this in any shell that starts Node.js.

您需要在任何启动 Node.js 的 shell 中执行此操作。

I'd also check what other Oracle libraries are installed on the machine and make sure you don't have clashes.

我还会检查机器上安装了哪些其他 Oracle 库,并确保您没有冲突。

Using ldconfig to set the path globally will almost certainly be easier than setting LD_LIBRARY_PATH. You can do something like:

使用 ldconfig 全局设置路径几乎肯定比设置 LD_LIBRARY_PATH 更容易。您可以执行以下操作:

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

See the Instant Client installinstructions for details.

有关详细信息,请参阅Instant Client 安装说明。

If you have optional Net configuration files like sqlnet.oraor tnsnames.ora, they can be put in a directory /opt/oracle/instantclient_12_2/network/adminwhich is a default location for configuration files. See Optional Oracle Net Configuration.

如果您有可选的网络配置文件,例如sqlnet.oratnsnames.ora,它们可以放在一个目录中/opt/oracle/instantclient_12_2/network/admin,该目录是配置文件的默认位置。请参阅可选的 Oracle 网络配置

Update: if you install the Instant Client 19.3 RPM packages, the ldconfigstep is automatically done. (You still need/could/should do it for a 19.3 ZIP file install)

更新:如果您安装 Instant Client 19.3 RPM 软件包,该ldconfig步骤将自动完成。(对于 19.3 ZIP 文件安装,您仍然需要/可以/应该这样做)

回答by Dmitry

export works only for one process. It seems, it doesn't present at your terminal window (it is separate process). So, you should execute following again before starting node connect.js(in the same terminal window where you going to start node):

导出仅适用于一个进程。看来,它没有出现在您的终端窗口中(它是单独的进程)。因此,您应该在启动之前再次执行以下操作node connect.js(在您要启动节点的同一终端窗口中):

export LD_LIBRARY_PATH=/opt/oracle/instantclient:$LD_LIBRARY_PATH