服务器端 配置: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配置文件,内容格式如下:
- # tnsnames.ora Network Configuration File: C:eorcldbproduct11.2.0dbhome_1NETWORKADMIN nsnames.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:WindowsSysWOW64odbcad32.exe,32位系统用C:WindowsSystem32odbcad32.exe