典型的监听配置模板:
创建监听有多重方式:(1)netca (2)netmgr (3)手工编辑listener.ora文件等;
下面是一个监听配置的标准模板:
配置文件中的关键之解析:
(1) PROTOCOL指的是监听接收链接的协议;
(2) HOST是指的监听运行的主机或者IP地址;
(3) PORT指的是监听运行的端口。
(4) SID_NAME指的是监听服务的实例名。
(5) GLOBAL_NAME指的是监听服务的服务名;
(6) ORACLE_HOME指的是监听服务的$ORACLE_HOME;
监听支持的协议参数:
注意:为增加系统的可用性,在HA环境下,建议将listener.oora关键字HOST配置成主机名;
其中的SID_NAME等于数据库参数INSTANCE_NAME的;
然后再看一下tnsnames的文件内容:
我们需要关注的是tns的service name是等于listener文件中的global_dbname的;
注意tnsping:tnsping只是发送链接包(NSPTCN)至服务端监听上,所以即使tnsping监听正常,客户端也不一定能连接到数据库库服务器;tnsping主要检查的是远程监听是否启动在相应的ip地址和端口上,并不检查监听中的实力服务和句柄(handle);
静态配置内容:
在静态注册环境下,在listener.ora文件中主要配置一下内容
(1) SID_NAME:数据库实例名,其值需和数据库参数INSTANCE_NAME保持一致。
(2) GLOBAL_DBNAME:数据库服务名,可以省略,默认和SID_NAME保持一致。
(3) ORACLE_HOME:实力运行的ORACLE_HOME目录,在unix和linux环境下,该参数可以省略,默认和环境变量¥ORACLE_HOME保持一致;
以下为实例名为felix和pyf静态注册配置:(注意:在监听静态注册的情况下,即使数据库实例已关闭,具有sysdba权限的业务用户仍然可以通过监听远程连接到数据库中进行维护);
[oracle@felix admin]$ vi listener.ora
# listener.ora Network Configuration File:/u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION =
(ADDRESS= (PROTOCOL = TCP)(HOST = felix)(PORT = 1521))
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = develop)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = felix )
)
(SID_DESC =
(GLOBAL_DBNAME = pyfeng)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_2)
(SID_NAME = pyf )
)
)
ADR_BASE_LISTENER = /u01/app/oracle
11:36:53 SQL>show parameter service
NAME TYPE VALUE
---------------------------------------------------------- ------------------------------
service_names string felix
[oracle@felix admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File:/u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
DEVELOP_p =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.17)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = develop)
)
)
[oracle@felix admin]$
特别注意:如果listener.ora设置了GLOBAL_DBNAME参数,呢么在RAC环境下,TAF和connect-time failover特性将失效;
注意监听状态:
[oracle@felixadmin]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 - Productionon 12-AUG-2014 14:01:58
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Connecting to(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=felix)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 -Production
Start Date 12-AUG-2014 11:25:44
Uptime 0 days 2 hr. 36 min. 13 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/felix/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=felix)(PORT=1521)))
Services Summary...
Service "develop" has 1 instance(s).
Instance"felix", status UNKNOWN, has 1 handler(s) for this service...
Service "felix" has 1 instance(s).
Instance"felix", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully
[oracle@felix admin]$
原文:http://blog.csdn.net/panfelix/article/details/38515243