Oracle 配置遠端訪問教程
阿新 • • 發佈:2020-01-09
服務端配置
如果不想自己寫,可以通過 Net Manager 來配置.
以下配置檔案中的 localhost 改為 ip 地址,否則,遠端不能訪問.
1.網路監聽配置
# listener.ora Network Configuration File: C:\app\Administrator\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = CLRExtProc) (ORACLE_HOME = C:\app\Administrator\product\11.2.0\dbhome_1) (PROGRAM = extproc) (ENVS = "EXTPROC_DLLS=ONLY:C:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll") ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) ) ADR_BASE_LISTENER = C:\app\Administrator
多個IP時,如下:
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.24.226.2)(PORT = 1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.24.226.3)(PORT = 1521)) ) )
2.TNS 配置
# tnsnames.ora Network Configuration File: C:\app\Administrator\product\11.2.0\dbhome_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. ORCL= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) ORACLR_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) (CONNECT_DATA = (SID = CLRExtProc) (PRESENTATION = RO) ) ) LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
多個IP時,如下:
ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.24.226.2)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 172.24.226.3)(PORT = 1521)) ) (SOURCE_ROUTE = yes) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
3.停止和啟動服務
先停止以下服務,然後再啟動.
OracleOraDb11g_homeTNSListener OracleService*
客戶端配置
1.下載 ODAC 壓縮包.
2.解壓下載的 ODAC 壓縮包.
3.執行安裝命令
示例:
install.bat all D:\Program\ODAC\12040x64 OracleHome true
4.新增環境變數
ORACLE_HOME : 是 ODAC 安裝的目錄.
TNS_ADMIN : 是檔案 tnsnames.ora 所在的目錄,一般為 ODAC 安裝目錄下的 network\admin 中.
注: TNS_ADMIN 可以不用新增,直接將 tnsnames.ora 檔案複製到 ODAC 安裝目錄下即可
將 %ORACLE_HOME% 新增到 PATH 環境變數中.
5.配置 TNS
在配置檔案 tnsnames.ora 中加入
DBORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = <db-host>)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = <db-name>) ) )
說明:
<db-host> : 資料庫電腦的IP或者是計算機名
<db-name> : 資料庫TNS配置的名稱
總結
以上所述是小編給大家介紹的Oracle 配置遠端訪問教程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回覆大家的。在此也非常感謝大家對我們網站的支援!