前言
本篇文章用最簡單和快速的方法介紹如何在Red Hat Enterprise Linux安裝Oracle Instant Client,該方法同樣適用於Windows,RHEL5/6/7,OEL,CentOS。Oracle Instant Client是官方免費授權的一種比Oracle Client還要簡單的資料庫管理工具,通過SQL*Plus或者其它工具比如Navicat等用於快速連線和管理Oracle資料庫伺服器。
Install Oracle instantclient basic and instantclient sqlplus on Linux and Windows.
更新記錄
2017年08月10日 – 初稿
閱讀原文 – https://wsgzao.github.io/post…
擴充套件閱讀
Oracle Instant Client Downloads – http://www.oracle.com/technet…
Oracle Instant Client Downloads
文章內容均已64位版本為例,如果客戶端有特殊需求請使用32位版本相容
- Linux Oracle Instant Client推薦使用RPM方式安裝,如果需要定製具體路徑可以使用zip包手動配置
- Windows和Linux類似但需要主要PATH環境變數的配置
- 實測12版本客戶端可以向下相容11版本的資料庫伺服器,Oracle Instant Client 12.2.0.1.0,Oracle Database 11.2.0.3.0
下載地址
http://www.oracle.com/technet…
百度網盤分流
http://pan.baidu.com/s/1slhoZEH
Linux
以RPM最簡方式為例
Preparation
Download all the required RPM from the official site and put them on the target system.
Current RPMs for 64bit are:
oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
Install RPMs
# install as root
rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
# create oracle group and user
groupadd dba
useradd -g dba oracle
echo oracle:oracle | chpasswd
# configure profile
su - oracle
vi ~/.bash_profile
export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
export TNS_ADMIN=/usr/lib/oracle/12.2/client64/
export PATH=/usr/lib/oracle/12.2/client64/bin:$PATH
# Connect to Your database with:
sqlplus system/oracle@oracapdb
# create new tnsnames.ora
# ORA-12154: TNS:could not resolve the connect identifier specified
vim /usr/lib/oracle/12.2/client64/tnsnames.ora
oracapdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.70.244)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracapdb)
)
)
# You can also use the Easy Connect connection string format (does not use TNSNAMES):
sqlplus system/oracle@//172.28.70.244:1521/oracapdb
Windows
Windows的配置相比Linux差不多簡單,注意環境變數尤其是TNS_ADMIN
Preparation
國外一篇圖文並茂的文章寫的也很詳細,有需要可以參考下
Installing Oracle instantclient basic and instantclient sqlplus on win32
http://www.dbatoolz.com/t/ins…
Go to Instant Client Downloads for Microsoft Windows download page:
http://www.oracle.com/technol…
unzip files
# 下載解壓以下兩個包至目錄,比如C:instantclient_12_2
instantclient-basic-windows.x64-12.2.0.1.0.zip
instantclient-sqlplus-windows.x64-12.2.0.1.0.zip
# 設定環境變數
計算機右鍵【屬性】----【高階系統設定】----【環境變數】----【系統變數】----【Path】
# Setup your system %PATH% and %TNS_ADMIN% variables
C:instantclient_12_2
# Connect to Your database with:
sqlplus system/oracle@oracapdb
# TNS_ADMIN
# ORA-12154: TNS:could not resolve the connect identifier specified
Variable Name: TNS_ADMIN
Variable Value: C:instantclient_12_2
# create new tnsnames.ora
C:instantclient_12_2 nsnames.ora
oracapdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.28.70.244)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracapdb)
)
)
# You can also use the Easy Connect connection string format (does not use TNSNAMES):
sqlplus system/oracle@//172.28.70.244:1521/oracapdb