下面來看安裝步驟:
1、下載下傳安裝包,我這裡把所有的都下載下傳下來了
instantclient-basic-linux.x64-12.2.0.1.0.zip
instantclient-basiclite-linux.x64-12.2.0.1.0.zip
instantclient-jdbc-linux.x64-12.2.0.1.0.zip
instantclient-odbc-linux.x64-12.2.0.1.0-2.zip
instantclient-sdk-linux.x64-12.2.0.1.0.zip
instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
instantclient-tools-linux.x64-12.2.0.1.0.zip
2、unzip解壓
解壓出來一個目錄instantclient_12_2
3、配置環境變量
export ORACLE_HOME=/home/tst1/instantclient_12_2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
export PATH=$ORACLE_HOME:$PATH
4、配置tns
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>-p network</code><code>/admin</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cd</code> <code>network</code><code>/admin/</code>
<code>[tst1@rhel7 admin]$ </code><code>cat</code> <code>tnsnames.ora </code>
<code>ora11g =</code>
<code> </code><code>(DESCRIPTION = </code>
<code> </code><code>(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.22)(PORT = 1521))</code>
<code> </code><code>(CONNECT_DATA =</code>
<code> </code><code>(SERVER = DEDICATED)</code>
<code> </code><code>(SERVICE_NAME = ora11g)</code>
<code> </code><code>)</code>
<code> </code><code>)</code>
5、測試sqlplus,成功
<code>[tst1@rhel7 admin]$ sqlplus zx</code><code>/zx</code><code>@ora11g</code>
<code>SQL*Plus: Release 12.2.0.1.0 Production on Thu Nov 16 12:48:33 2017</code>
<code>Copyright (c) 1982, 2016, Oracle. All rights reserved.</code>
<code>Connected to:</code>
<code>Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production</code>
<code>With the Partitioning, OLAP, Data Mining and Real Application Testing options</code>
<code>SQL></code>
6、安裝sqlldr,我安裝的這個版本的簡易用戶端中有sqlldr,如果沒有的話需要從其他用戶端或服務端中拷貝,但是我測試執行sqlldr報錯:
<code>[tst1@rhel7 instantclient_12_2]$ sqlldr</code>
<code>Message 2100 not found; No message </code><code>file</code> <code>for</code> <code>product=RDBMS, facility=ULMessage 2100 not found; No message </code><code>file</code> <code>for</code> <code>product=RDBMS, facility=UL[tst1@rhel7 instantclient_12_2]$</code>
因為缺少mesg檔案,從服務端把rdbms/mesg下的檔案全部拷貝
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>-p rdbms</code><code>/mesg</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/rdbms/mesg/</code><code>* rdbms</code><code>/mesg/</code>
再次執行sqlldr成功
7、安裝oerr,簡易用戶端中沒有oerr指令,需要從服務端拷貝
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/oerr</code> <code>./</code>
<code>[tst1@rhel7 instantclient_12_2]$ oerr</code>
<code>/home/tst1/instantclient_12_2/oerr</code><code>: line 29: </code><code>/home/tst1/instantclient_12_2/perl/bin/perl</code><code>: No such </code><code>file</code> <code>or directory</code>
執行報錯,說明缺少檔案,從服務端拷貝
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>-r </code><code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/perl/</code><code>* ./</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>-r </code><code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/perl/</code><code>* .</code><code>/perl/</code>
<code>[tst1@rhel7 instantclient_12_2]$ oerr ora 1</code>
<code>Can't </code><code>open</code> <code>perl script </code><code>"/home/tst1/instantclient_12_2/bin/oerr.pl"</code><code>: (null)</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>bin</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>scp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/oerr</code><code>.pl .</code><code>/bin/</code>
<code>Could not </code><code>open</code> <code>facilities list </code><code>file</code><code>: </code><code>/home/tst1/instantclient_12_2/lib/facility</code><code>.lis</code>
<code>2</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>mkdir</code> <code>lib</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/lib/facility</code><code>.lis .</code><code>/lib/</code>
<code>00001, 00000, </code><code>"unique constraint (%s.%s) violated"</code>
<code>//</code> <code>*Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.</code>
<code>//</code> <code>For Trusted Oracle configured </code><code>in</code> <code>DBMS MAC mode, you may see</code>
<code>//</code> <code>this message </code><code>if</code> <code>a duplicate entry exists at a different level.</code>
<code>//</code> <code>*Action: Either remove the unique restriction or </code><code>do</code> <code>not insert the key.</code>
注意:oerr也使用到了rdbms/mesg目錄下的檔案,隻不過第6步把整個目錄都拷貝過來了,這裡就省事了。
8、安裝tnsping,簡易安裝包裡也沒有這個工具,需要從服務端拷貝
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/tnsping</code> <code>./</code>
<code>[tst1@rhel7 instantclient_12_2]$ tnsping</code>
<code>TNS Ping Utility </code><code>for</code> <code>Linux: Version 12.2.0.1.0 - Production on 16-NOV-2017 13:09:12</code>
<code>Copyright (c) 1997, 2016, Oracle. All rights reserved.</code>
<code>TNS-03502: Message 3502 not found; No message </code><code>file</code> <code>for</code> <code>product=network, facility=TNS</code>
執行報錯,因為缺少mesg檔案
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>-r </code><code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/network/mesg/</code> <code>.</code><code>/network/</code>
<code>[tst1@rhel7 instantclient_12_2]$ tnsping 192.168.56.22:1521</code><code>/ora11g</code>
<code>TNS Ping Utility </code><code>for</code> <code>Linux: Version 12.2.0.1.0 - Production on 16-NOV-2017 13:11:04</code>
<code>Used parameter files:</code>
<code>Used HOSTNAME adapter to resolve the </code><code>alias</code>
<code>Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=ora11g))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.22)(PORT=1521)))</code>
<code>OK (10 msec)</code>
安裝成功。
9、安裝exp、imp、expdp、impdp,安裝包中沒有,直接從服務端拷貝
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/imp</code> <code>./</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/exp</code> <code>./</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/impdp</code> <code>./</code>
<code>[tst1@rhel7 instantclient_12_2]$ </code><code>cp</code> <code>/u01/app/oracle/product/12</code><code>.2</code><code>/db_home1/bin/expdp</code> <code>./</code>
imp和exp測試沒有問題,但expdp和impdp報錯:
<code>[tst1@rhel7 instantclient_12_2]$ expdp</code>
<code>Segmentation fault</code>
<code>[tst1@rhel7 instantclient_12_2]$ impdp</code>
查詢MOS找到解決方法,在環境變量中添加export NLS_LANG=American_America.ZHS16GBK
問題解決。
至此,簡單用戶端安裝完成,可以把整個目錄打個包,給其他機器安裝時直接解壓,配置環境變量就可以使用了。比安裝用戶端友善的多。
備注:
如果在使用某個工具報缺少庫檔案時可以使用ldd指令檢視該指令缺少哪個庫檔案,如下所示:
<code>[root@host77 instantclient_11_2]</code><code># ldd sqlldr</code>
<code> </code><code>linux-vdso.so.1 => (0x00007fffe63fe000)</code>
<code> </code><code>libclntsh.so.11.1 => not found</code>
<code> </code><code>libnnz11.so => not found</code>
<code> </code><code>libpthread.so.0 => </code><code>/lib64/libpthread</code><code>.so.0 (0x00007f014b85c000)</code>
<code> </code><code>libdl.so.2 => </code><code>/lib64/libdl</code><code>.so.2 (0x00007f014b658000)</code>
<code> </code><code>libm.so.6 => </code><code>/lib64/libm</code><code>.so.6 (0x00007f014b355000)</code>
<code> </code><code>libnsl.so.1 => </code><code>/lib64/libnsl</code><code>.so.1 (0x00007f014b13c000)</code>
<code> </code><code>libc.so.6 => </code><code>/lib64/libc</code><code>.so.6 (0x00007f014ad7b000)</code>
<code> </code><code>/lib64/ld-linux-x86-64</code><code>.so.2 (0x00007f014ba8b000)</code>
從上面的輸出可以看出缺少libclntsh.so.11.1和libnnz11.so這兩個檔案,從服務端拷貝即可。
本文轉自hbxztc 51CTO部落格,原文連結http://blog.51cto.com/hbxztc/1982318:,如需轉載請自行聯系原作者