服務(wù)端配置
如果不想自己寫,可以通過 Net Manager 來配置.
以下配置文件中的 localhost
改為 ip
地址,否則,遠(yuǎn)程不能訪問.
- 網(wǎng)絡(luò)監(jiān)聽配置
# 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
多個(gè)IP時(shí),如下:
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))
)
)
- 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))
多個(gè)IP時(shí),如下:
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)
)
)
- 停止和啟動(dòng)服務(wù)
先停止以下服務(wù),然后再啟動(dòng).
- OracleOraDb11g_homeTNSListener
- OracleService*
客戶端配置
下載
ODAC
壓縮包.解壓下載的
ODAC
壓縮包.執(zhí)行安裝命令
示例:
install.bat all D:\Program\ODAC\112040x64 OracleHome true
- 添加環(huán)境變量
-
ORACLE_HOME : 是
ODAC
安裝的目錄. -
TNS_ADMIN : 是文件
tnsnames.ora
所在的目錄,一般為ODAC
安裝目錄下的network\admin
中.
注: TNS_ADMIN 可以不用添加,直接將 tnsnames.ora
文件復(fù)制到 ODAC
安裝目錄下即可
將 %ORACLE_HOME%
添加到 PATH
環(huán)境變量中.
- 配置 TNS
在配置文件 tnsnames.ora
中加入
DBORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <db-host>)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <db-name>)
)
)
說明:
- <db-host> : 數(shù)據(jù)庫(kù)電腦的IP或者是計(jì)算機(jī)名
- <db-name> : 數(shù)據(jù)庫(kù)TNS配置的名稱