一、環境介紹
數據庫服務器 |
|
主機IP |
10.1.1.1 |
主機名 |
oradb01.heima.cn |
實例名 |
ora11g |
服務名 |
ora11g |
系統版本 |
Centos6.9 |
客戶端 |
|
主機IP |
10.1.1.9 |
主機名 |
heima.yunwei.cn |
系統版本 |
Centos7.6 |
二、創建oracle相應的用戶組
[root@heima ~]#groupadd oinstall
[root@heima ~]#useradd -g oinstall oracle
[root@heima ~]#passwd oracle
三、安裝客戶端軟件
1、官方網站下載相應軟件
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
- 選擇Linux下客戶端工具
- 選擇基礎軟件包和PL/SQL工具包
2、上傳到客戶端服務器並解壓
[oracle@heima ~]$ pwd
/home/oracle
[oracle@Heima ~]$ unzip instantclient-basic-linux.x64-19.5.0.0.0dbru.zip
[oracle@heima ~]$ unzip instantclient-sqlplus-linux.x64-19.5.0.0.0dbru.zip
說明:
1、使用oracle用戶解壓,解壓到安裝路徑(此處爲oracle用戶家目錄)
2、解壓完畢後會多出一個目錄:instantclient_19_5,所有的軟件都在裏面
3、配置環境變量
[root@heima ~]# su - oracle
[oracle@heima ~]$ vim .bash_profile
修改profile文件,增加以下內容
export ORACLE_HOME=/home/oracle/instantclient_19_5/
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME
export PATH=$ORACLE_HOME:$PATH
四、配置tnsnames.ora文件
[oracle@heima admin]$ pwd
/home/oracle/instantclient_19_5/network/admin
創建tnsnames.ora文件
vim tnsnames.ora
ora11g =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.1.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ora11g)
)
)
五、測試是否可以遠程訪問數據庫服務器
在客戶端10.1.1.9上,使用scott/tiger用戶訪問
[oracle@heima ~]$ sqlplus scott/tiger@ora11g
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Dec 21 12:19:37 2019
Version 19.5.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
以上說明遠程訪問成功。
六、總結
遠程訪問oracle數據庫的工具有很多,圖形化的,命令行的,安裝方式也不盡相同,關注傳智播客*黑馬程序員,運維學科會陸續推出oracle數據庫管理的系列技術文章,敬請關注。