標籤:
伺服器端 配置:oracle11g R2 x64
1.設定監聽
a.啟動欄 -> 開始 -> 程式 -> Oracle-OraDb11g_home1 -> 配置和移植工具 -> Net Manager
b.Oracle Net 配置 -> 本地 -> 監聽程式 -> LISTENER ,查看是否有本地地址在監聽,沒有則添加,主機:"localhost",連接埠:1521,協議:TCP/IP
2.關閉所有防火牆(包括Window防火牆)
3.啟動TNS監聽服務:lsnrctl start (此程式LSNRCTL.exe位於oracle_path/product/11.2.0/dbhome_1/BIN目錄下
用戶端(Windows)
1.下載Instant Client for Microsoft Windows (32bit) 並安裝,地址: instant client下載
2.將instant client的安裝目錄加入path環境變數中
3.建立tnsnames.ora設定檔,內容格式如下:
[plain] view plaincopy
- # tnsnames.ora Network Configuration File: C:\e\orcldb\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora
- # Generated by Oracle configuration tools.
-
- WSR =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.112)(PORT = 1521))
- )
- (CONNECT_DATA =
- (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))
-
- ORCL =
- (DESCRIPTION =
- (ADDRESS_LIST =
- (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
- )
- (CONNECT_DATA =
- (SERVER = DEDICATED)
- (SERVICE_NAME = orcl)
- )
- )
比如此檔案,我建立的TNS服務名為WRS,Oracle伺服器位址為192.168.1.112,Oracle伺服器監聽連接埠為1521,串連的Oracle資料庫名為orcl,可以按此格式進行替換。
4.添加TNS_ADMIN環境變數,指向建立的tnsnames.ora設定檔。
至此,配置已經完成,可以用pl/sql developer之類的工具串連遠程oracle資料庫,database即為添加的tns服務名(這裡為WSR)
如果要用odbc串連資料庫,還要添加odbc資料來源,64位系統用C:\Windows\SysWOW64\odbcad32.exe,32位系統用C:\Windows\System32\odbcad32.exe
Oracle11g遠端連線配置 visual studio 2003