1. 服务器端主机A环境:
Windows Server 2008 64bit
Oracle 11gR2(11.2.0.1.0) 64bit服务器版。
IP:192.168.1.2
——Database Configuration Assistant数据库助手创建两个数据库。
——配置监听方案1:通过Net manager配置。一个监听程序,监听(本机的2个端口1521和1522,2个数据库Orcl和Demo),配置2个服务Orcl和Demo。
具体参考:http://wenku.baidu.com/view/e5e469233169a4517723a3c1.html
方案1生成的listener.ora文件:
1 # listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora 2 # Generated by Oracle configuration tools. 3 4 SID_LIST_LISTENER = 5 (SID_LIST = 6 (SID_DESC = 7 (SID_NAME = CLRExtProc) 8 (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1) 9 (PROGRAM = extproc) 10 (ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll") 11 ) 12 (SID_DESC = 13 (GLOBAL_DBNAME = Orcl) 14 (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1) 15 (SID_NAME = Orcl) 16 ) 17 (SID_DESC = 18 (GLOBAL_DBNAME = Demo) 19 (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1) 20 (SID_NAME = Demo) 21 ) 22 ) 23 24 LISTENER = 25 (DESCRIPTION_LIST = 26 (DESCRIPTION = 27 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 28 ) 29 (DESCRIPTION = 30 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521)) 31 ) 32 (DESCRIPTION = 33 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522)) 34 ) 35 ) 36 37 ADR_BASE_LISTENER = D:\app\Administrator
——配置监听方案2,通过Net manager配置。一个监听程序,监听(1个端口1521,2个数据库Orcl和Demo),配置2个服务Orcl和Demo。
方案2生成的listener.ora文件:
1 # listener.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora 2 # Generated by Oracle configuration tools. 3 4 SID_LIST_LISTENER = 5 (SID_LIST = 6 (SID_DESC = 7 (SID_NAME = CLRExtProc) 8 (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1) 9 (PROGRAM = extproc) 10 (ENVS = "EXTPROC_DLLS=ONLY:D:\app\Administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll") 11 ) 12 (SID_DESC = 13 (GLOBAL_DBNAME = Orcl) 14 (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1) 15 (SID_NAME = Orcl) 16 ) 17 (SID_DESC = 18 (GLOBAL_DBNAME = Demo) 19 (ORACLE_HOME = D:\app\Administrator\product\11.2.0\dbhome_1) 20 (SID_NAME = Demo) 21 ) 22 ) 23 24 LISTENER = 25 (DESCRIPTION_LIST = 26 (DESCRIPTION = 27 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 28 ) 29 (DESCRIPTION = 30 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521)) 31 ) 32 ) 33 34 ADR_BASE_LISTENER = D:\app\Administrator
方案2服务配置文件tnsnames.ora:
1 # tnsnames.ora Network Configuration File: D:\app\Administrator\product\11.2.0\dbhome_1\NETWORK\ADMIN\tnsnames.ora 2 # Generated by Oracle configuration tools. 3 4 Orcl = 5 (DESCRIPTION = 6 (ADDRESS_LIST = 7 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521)) 8 ) 9 (CONNECT_DATA = 10 (SERVER = DEDICATED) 11 (SERVICE_NAME = Orcl) 12 ) 13 ) 14 15 Demo = 16 (DESCRIPTION = 17 (ADDRESS_LIST = 18 (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521)) 19 ) 20 (CONNECT_DATA = 21 (SERVER = DEDICATED) 22 (SERVICE_NAME = Demo) 23 ) 24 ) 25 26 LISTENER_Orcl = 27 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) 28 29 30 ORACLR_CONNECTION_DATA = 31 (DESCRIPTION = 32 (ADDRESS_LIST = 33 (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) 34 ) 35 (CONNECT_DATA = 36 (SID = CLRExtProc) 37 (PRESENTATION = RO) 38 ) 39 ) 40 41 LISTENER_Demo = 42 (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
服务器端测试连接成功。
2. 客户端PC机B环境:
Win7 64bit
Oracle 11gR2(11.2.0.1.0) 64bit服务器版(当作客户端来用)
PL/Sql Developer 9.0,PC端设置保证了PL/Sql Developer可访问。Net Manager默认的路径一般为E:\app\yang-PC\product\11.2.0\dbhome_1\NETWORK\ADMIN,此时的TNS_ADMIN环境变量已经改变,再通过Net Manager配置服务。
http://www.cnblogs.com/donetbaoxj320/archive/2011/11/24/2262412.html
http://www.cnblogs.com/yhlx125/archive/2013/04/19/3030189.html
——Net Manager配置服务,新建服务Server,主机名192.168.1.2,端口1521,服务名Orcl,测试连接。
——老是报“连接超时”错误:吐血,服务器端防火墙没有关闭。关闭防火墙后,连接测试成功。保存配置。
——PL/Sql Developer 可以访问服务器数据库。
3.配置监听和服务的相关知识:
监听程序和数据库配套,运行在服务器上。