instantclient-basic-linux32-10.2.0.3-20061115.zip
instantclient-sdk-linux32-10.2.0.3-20061115.zip
instantclient-sqlplus-linux32-10.2.0.3-20061115.zip
sqlplus是用來檢驗是否安裝成功的。依次解壓,得到一個統一的文件夾,instantclient_10_2。如我前面的文章DBArtisan無法加載OCI,配置好TNS_ADMIN、LD_LIBRARY_PATH等,複製.bashrc文件部分內容如下:
export ORACLE_HOME=/usr/local/oracle
export TNS_ADMIN=$ORACLE_HOME/NETWORK/ADMIN
export LD_LIBRARY_PATH=$ORACLE_HOME
export SQLPATH=$ORACLE_HOME
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
PATH=$PATH:$ORACLE_HOME
export PATH
找一個配置好的tnsnames.ora文件放到TNS_ADMIN變量設置的位置,也就是/usr/local/oracle/NETWORK/ADMIN目錄下。接下來就可以使用sqlplus驗證是否安裝成功。當我使用如下命令:sqlplus username/password@<連接字符串>測試時,系統提示段錯誤 (segmentation fault)。有提示解決方法如下:
1. cd /usr/bin (as root)
2. mv gcc gcc.script
3. mv g++ g++.script
4. ln -s gcc32 gcc
5. ln -s g++32 g++
6. login as oracle software owner (make sure environment is correct)
7. cd $ORACLE_HOME/bin
8. relink all
首先,這個是64位系統的解決方法,其次,我在當前linux系統中找不到relink命令。後來,傳說中的高人又出現了,一頓檢查以後,得出結論如下,這個linux的內核版本太高了,instant client這個版本可能還不支持,於是建議安裝instant client 11。
下載如下文件:
instantclient-basic-linux32-11.2.0.1.zip
instantclient-sdk-linux32-11.2.0.1.zip
instantclient-sqlplus-linux32-11.2.0.1.zip
操作步驟與上面一樣,其實配置已經做好了,只需將原來instant client 的文件都刪除,替換成instant client 11的文件就行。再使用sqlplus測試,連接成功。
以下是討論不設置環境變量安裝Oracle instant client的內容,先記錄下來,有空再嘗試。
Oracle's instructions specify setting LD_LIBRARY_PATH. This makes my application dependent on random users' configuration and is very troublesome to set up.
How can I avoid having to set any environment variables?
http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxx86_64soft.html
related note for OS/X: http://stackoverflow.com/questions/684352
answer:
/etc/ld.so.conf
, then run /sbin/ldconfig
. You don't need to set
LD_LIBRARY_PATH
for libraries installed in standard locations like
/usr/lib
because these locations are already configured in /etc/ld.so.conf
.------------------------------------------------------- 昏哥線 -------------------------------------------------------------------
Oracle's instantclient installation instructions specify that the user set LD_LIBRARY_PATH. This is very troublesome to manage for multiple users.
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):
instantclient-basic-linux-x86_64-10.2.0.4.0.zip
instantclient-sdk-linux-x86_64-10.2.0.4.0.zip
instantclient-sqlplus-linux-x86_64-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.
sudo cp instantclient_10_2/sdk/include/*.h /usr/include
sudo cp instantclient_10_2/sqlplus /usr/bin
sudo cp instantclient_10_2/*.so* /usr/lib
If you use tnsnames.ora, copy it to /etc, which is the default global place the oracle runtime searches.
sudo cp tnsnames.ora /etc
Test with
/usr/bin/sqlplus scott/tiger@myoracle
------------------------------------------------------- 昏哥線 -------------------------------------------------------------------
You could of course rename sqlplus to sqlplus.real and make a wrapper script:
#!/bin/sh
if [ "$LD_LIBRARY_PATH" = "" ]
then
LD_LIBRARY_PATH=/what/ever
else
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/what/ever
fi
export LD_LIBRARY_PATH
exec sqlplus.real ${1+"$@"}
------------------------------------------------------- 昏哥線 -------------------------------------------------------------------
For anyone playing with Solaris (like me!) coming from a Linux background, I found that @David Phillips solution worked well using the Solaris command
crle -u -l /opt/instantclient
Thanks to post http://chrismiles.info/systemsadmin/solaris/articles/ld-path-customisation-on-solaris/