1.下載oracle sqlplus,選擇下載 .rpm檔案(以12.2版本為例)
https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
2. 下載兩個 .rpm檔案
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
3. 安裝 rpm
rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
4. 編輯sqlplus配置檔案
成功安裝rpm包後,oracle客戶端的預設路徑為: /usr/lib/oracle/12.2/client64
編輯配置檔案ld.so.conf
$ sudo vim /etc/ld.so.conf
#在檔案尾部新增--根據自己實際情況
/usr/lib/oracle/12.2/client64/lib
5. 配置oracle環境變數
編輯配置檔案.bashrc, .bashrc檔案在 ~ 路徑下,在檔案末尾加上:
#sqlplus remote configure
export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/loacl/lib:$LD_LIBRARY_PATH
#export SQLPATH=$ORACLE_HOME
#export NLS_LANG=AMERICAN_CHINA.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin
儲存,使生效: source .bashrc
6. 配置oracle連線檔案tnsnames.ora
在 /usr/lib/oracle/12.2/client64/路徑下新建資料夾 network/admin/,再新建檔案 tnsnames.ora
編輯 tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/12c/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.122.133)(PORT = 1521))
轉接名 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.122.133)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = serviceName)
)
)
7. 測試
sqlplus username/userpwd@轉接名
查詢當前使用者下的表
select table_name from user_tables;
Centos7下安裝Sql*Plus並連線遠端Oralce伺服器 - 孤舟蓑笠翁· - 部落格園 (cnblogs.com)