從以下網站下載安裝包,選擇適合自己的版本
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
從oracle官方網站上下載用戶端和sqlplus程式。
以11g為例
以root使用者安裝
rpm -ivh oracle-instantclient-basic-11.1.0.1-1.x86_64.rpm
rpm -ivh oracle-instantclient-sqlplus-11.1.0.1-1.x86_64.rpm
安裝完後可以使用 rpm -qpl oracle-instantclient-sqlplus-11.1.0.1-1.x86_64.rpm查看安裝路徑
預設在/usr/lib/oracle目錄
配置
vim /etc/profile 添加
export ORACLE_HOME=/usr/lib/oracle/11.1.0.1/client64
export ORACLE_BASE=/usr/lib/oracle/11.1.0.1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
設定好環境變數需要重啟機器或者source /etc/profile 讓配置生效
建立設定檔
在ORACLE_HOME目錄下建立以下目錄network/admin,並建立檔案tnsnames.ora,內容如下:
vim /usr/lib/oracle/11.1.0.1/client64/network/admin/tnsnames.ora
ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = host)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )
測試
到ORACLE_HOME/bin目錄下,執行命令:
[yleesun@centos bin]$ ./sqlplus zxd/zxd@111
SQL*Plus: Release 11.2.0.3.0 Production on Mon Jul 9 19:14:25 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
測試成功。
註:
如果出現以下錯誤:
sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory
說明環境變數沒有生效或者需要安裝一下軟體包
yum install libaio* 大功告成