在 Mac OS/X 上安装 Oracle Instantclient 而不设置环境变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/684352/
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-10 01:47:00  来源:igfitidea点击:

installing Oracle Instantclient on Mac OS/X without setting environment variables?

oraclemacosinstallinstantclient

提问by Mark Harrison

Oracle's instructions specify setting DYLD_LIBRARY_PATH. This makes my application dependent on random users' configuration and is very troublesome to set up.

Oracle 的说明指定了设置 DYLD_LIBRARY_PATH。这使得我的应用程序依赖于随机用户的配置,并且设置起来非常麻烦。

How can I avoid having to set any environment variables?

如何避免必须设置任何环境变量?

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html

http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/intel_macsoft.html

related note for linux: installing Oracle Instantclient on Linux without setting environment variables?

linux 相关说明:在 Linux 上安装 Oracle Instantclient 而不设置环境变量?

回答by Mark Harrison

Oracle's instantclient installation instructions specify that the user set DYLD_LIBRARY_PATH. This is very troublesome to manage for multiple users.

Oracle 的 Instantclient 安装说明指定用户设置 DYLD_LIBRARY_PATH。这对于多个用户的管理非常麻烦。

To use the instantclient without setting any environment variables:

要在不设置任何环境变量的情况下使用即时客户端:

Download the instantclient distribution from oracle.com. For doing non-java software development, you will need (assuming Oracle 10.2):

从 oracle.com 下载 Instantclient 分发版。要进行非 Java 软件开发,您将需要(假设为 Oracle 10.2):

instantclient-basic-macosx-10.2.0.4.0.zip
instantclient-sdk-macosx-10.2.0.4.0.zip
instantclient-sqlplus-macosx-10.2.0.4.0.zip

Unzip the three files. This will give you a directory

解压三个文件。这会给你一个目录

instantclient_10_2/

Copy the files to /usr, which is one of the default places the dynamic loader searches.

将文件复制到 /usr,这是动态加载程序搜索的默认位置之一。

sudo cp instantclient_10_2/sdk/include/*.h /usr/include
sudo cp instantclient_10_2/sqlplus         /usr/bin
sudo cp instantclient_10_2/*.dylib         /usr/lib

If you use tnsnames.ora, copy it to /etc, which is the default global place the oracle runtime searches.

如果您使用 tnsnames.ora,请将其复制到 /etc,这是 oracle 运行时搜索的默认全局位置。

sudo cp tnsnames.ora /etc

Test with

测试

/usr/bin/sqlplus scott/tiger@myoracle

回答by Jeff Taylor

If your goal is simply to run sqlplus on your MacBook, this might work for you. Remove the DYLD_LIBRARY_PATH environment variable from ~/.bashrc and replace it with an alias:

如果您的目标只是在 MacBook 上运行 sqlplus,这可能对您有用。从 ~/.bashrc 中删除 DYLD_LIBRARY_PATH 环境变量并将其替换为别名:

alias sqlplus="DYLD_LIBRARY_PATH=/Applications/instantclient_11_2 sqlplus"

alias sqlplus="DYLD_LIBRARY_PATH=/Applications/instantclient_11_2 sqlplus"

Blog entry: sqlplus and DYLD_LIBRARY_PATH on Mac OS/X

博客条目:Mac OS/X 上的 sqlplus 和 DYLD_LIBRARY_PATH

回答by bluebinary

After much research I found an sustainable solution to this error, that involves editing Apache's launchdconfiguration .plistfile to specify the required DYLD_LIBRARY_PATH, ORACLE_HOME, and LD_LIBRARY_PATHenvironment variables.

经过大量的研究,我发现一个可持续的解决了这个错误,这涉及编辑Apache的launchd配置.plist文件来指定需要的DYLD_LIBRARY_PATHORACLE_HOME以及LD_LIBRARY_PATH环境变量。

You can view the full answer here: https://stackoverflow.com/a/20670810/1914455

您可以在此处查看完整答案:https: //stackoverflow.com/a/20670810/1914455