网络配置的方法:
1、tnsname客户端--A 直接修改文件
B 通过客户端工具“网络配置助手”--win端直接打开调用Linux端,netca命令调出配置工具
2、监听器配置--服务器端
客户端配置监听服务室没有任何意义的,因为客户端没有oracle server
监听器配置文件:/u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
[oracle@oracle3 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1521))
)
)
服务器端配置一个监听器
[oracle@oracle3 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1522))
)
) --新的监听器,监听器监听是1522端口
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1521))
)
)
------------------------------------------------------------------------------------
一个数据库实例被多个监听器监听案例
[oracle@oracle3 admin]$ lsnrctl status --默认打开的是LISTENER
[oracle@oracle3 admin]$ lsnrctl status LISTENER1 --打开的是第二个监听器
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 06-JUN-2014 14:28:42
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle3)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER1
Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date 06-JUN-2014 14:26:15
Uptime 0 days 0 hr. 2 min. 26 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1522)))
The listener supports no services
The command completed successfully
将ORCL注册到第二个监听器:
修改监听器配置文件:
LISTENER1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1522))
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME=ORCL)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
)
)
通过监听器2访问:创建一个1522端口的连接串访问。
LISTENER1(1522) LISTENER(1521)
| |
---------------------------
|
ORCL
|
Oracle软件
并发访问:一个群组通过1521访问,一个群组通过1522访问.
-------------------------------------------------------------------------------------
一个监听器监听多个端口案例
方法1:服务器端用netmgr工具添加端口
[oracle@oracle3 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1522))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1527))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1528))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1529))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1530))
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = ORCL)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1523))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1524))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1525))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1526))
)
)
方法2:直接改这个配置文件
另外两个监听器都需要配置SID_LIST_串,监听器配置文件最终:
[oracle@oracle3 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1522))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1527))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1528))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1529))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1530))
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = ORCL)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1523))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1524))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1525))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1526))
)
)
架构图:
LISTENER1(1522、1527~1530) LISTENER(1521、1523~1526)
| |
----------------------------------------------
|
ORCL
|
Oracle软件
尝试通过不同的监听器不同的端口访问oracle server
[oracle@oracle3 admin]$ lsnrctl status LISTENER
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 06-JUN-2014 14:54:41
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date 06-JUN-2014 14:48:35
Uptime 0 days 0 hr. 6 min. 5 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1523)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1524)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1525)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1526)))
Services Summary...
Service "ORCL" has 2 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCLXDB" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCL_XPT" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle3 admin]$ lsnrctl status LISTENER1
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 06-JUN-2014 14:54:47
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle3)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER1
Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date 06-JUN-2014 14:49:08
Uptime 0 days 0 hr. 5 min. 39 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1527)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1528)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1529)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1530)))
Services Summary...
Service "ORCL" has 1 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
------------------------------------------------------------------------------------
静态注册--监听参数是手工添加的,启动监听后强制将ORCL注册到监听器。由于是强制的,只能确认监听器是正确的,但是
数据库不一定访问通,所以状态为UNKNOW。但是能否访问不是和这个状态有关系的。
动态注册--根据监听配置文件中的配置,由oracle的后台进程pmon将ORCL注册到监听器,而且是一定能访问通的,因为 PMON进程会测试。但是PMON不是时时刻刻都去注册的,有时间间隔,所以先启动数据库再启动监听不一定
马上监到, 有时间的延迟,因为pmon的工作是有时间间隔的。一旦监听到,状态为ready,即一定能访问通。
[oracle@oracle3 admin]$ ps -ef|grep ora_pmon
oracle 9190 1 0 11:07 ? 00:00:00 ora_pmon_ORCL
Oracle默认监听的注册方法是动态注册,即往默认的监听器LISTENER上注册,listener.ora文件中不需要SID_LIST_LISTENER即可。但是静态注册必须要SID_LIST_LISTENER串和LISTENER串。
LISTENER1 = --LISTENER1静态注册
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1522))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1527))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1528))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1529))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1530))
)
)
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = ORCL)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
)
)
LISTENER = --LISTENER动态注册
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1523))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1524))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1525))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1526))
)
)
可以改变默认的注册监听器:即将默认的监听器由LISTENER改为LISTENER1(LISTENER1改为动态的,LISTENER改为静态的),需要做以下几步:
step1:在oracle server的tnsname.ora文件中配置一个连接串:
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.3.3)(PORT = 1522)) --1522对应的监听器是非默认的LISTENER1
)
)
step2:修改oracle参数:
SQL> alter system set local_listener=ORCL;
系统已更改。 --这样oracle默认往1522对应的监听器上做动态注册。
step3:修改listener.ora文件
[oracle@oracle3 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER1 = --LISTENER1变为动态注册
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1522))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1527))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1528))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1529))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1530))
)
)
SID_LIST_LISTENER = --LISTENER变为静态注册
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = ORCL)
(ORACLE_HOME = /u01/oracle/product/10.2.0/db_1)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1523))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1524))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1525))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle3)(PORT = 1526))
)
)
step4:动态注册不能马上生效,要等pmon进程,有延迟,但是可以强制马上
SQL> alter system register; --不等pmon,强制注册
系统已更改。
step5:确认
[oracle@oracle3 admin]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 06-JUN-2014 16:05:49
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date 06-JUN-2014 15:46:21
Uptime 0 days 0 hr. 19 min. 28 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1523)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1524)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1525)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1526)))
Services Summary...
Service "ORCL" has 1 instance(s).
Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service... --LISTENER为静态注册
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle3 admin]$ lsnrctl status LISTENER1
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 06-JUN-2014 16:06:24
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle3)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER1
Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date 06-JUN-2014 15:46:28
Uptime 0 days 0 hr. 19 min. 56 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener1.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1527)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1528)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1529)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1530)))
Services Summary...
Service "ORCL" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service... --LISTENER1为动态注册
Service "ORCLXDB" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCL_XPT" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
The command completed successfully
注意:
1、一个实例只能有一个动态注册监听器,可以有多个静态注册的监听器。
2、动态注册监听器在某些时候是不可用的,pmon休息的时候,此时需要加一个静态注册监听,这样保证数据库可以时时刻刻对外访问。
3、多个监听器可以均衡访问的负载
4、到底用默认还是非默认的监听器做动态注册,取决于local_listener参数,默认是NULL,表示默认LISTENER是动态注册的,如果有值,根据值找到动态注册的监听器。