oracle单实例、RAC监听配置

WBOY
Release: 2016-06-07 15:50:44
Original
1678 people have browsed it

11g rac监听参考: http://www.luocs.com/archives/281.html http://www.oracledatabase12g.com/archives/11gr2-rac-add-listener-static-register.html 1.什么是注册 注册就是将数据库作为一个服务注册到监听程序。 客户端不需要知道数据库名和实例名,只需

11g rac监听参考:
http://www.luocs.com/archives/281.html

http://www.oracledatabase12g.com/archives/11gr2-rac-add-listener-static-register.html

1.什么是注册
注册就是将数据库作为一个服务注册到监听程序。
客户端不需要知道数据库名和实例名,只需要知道该数据库对外提供的服务名就可以申请连接到数据库。这个服务名可能与实例名一样,也有可能不一样。在数据库服务器启动过程中,数据库服务器会向监听程序注册相应的服务(无论何时启动一个数据库,默认地都有两条信息注册到监听器中:数据库服务器对应的实例和服务)相当于是这样:在数据库服务器和客户端之间有一监听程序(Listener),在监听程序中,会记录相应数据库对应的服务名(一个数据库可能对应有多个服务名),当客户端需要连接数据库时,只需要提供服务名,就可以建立客户端和服务器之间的连接.
2.如何查询某服务是静态监听注册还是动态监听注册
可以使用命令lsnrctl status来查看某服务是静态注册还是动态注册。实例状态为UNKNOWN值时表明此服务是静态注册的设置。这时监听器用来表明它不知道关于该实例的任何信息,只有当客户发出连接请求时,它才检查该实例是否存在。动态监听的状态是READY。
3.动态监听
动态注册不需要显示的配置listener.ora文件,实例MOUNT时,PMON进程就会根据instance_name,service_name参数将实例和服务动态注册到listerer中。
不同的参数注册到监听中的服务名、实例名有以下情况:
1.如果没有设定instance_name(10G后等于ORACLE_SID),将使用db_name初始化参数值。
2.如果service_names值为空,将拼接db_unique_name和db_domain参数值来注册监听。
3.如果选择设置service_names值,可以使用指定的名称(比如 orcl.oracle.com)或缩写的名称(比如orcl)。
4.如果选择缩写的名称并设置了db_domain参数,注册到监听器中的服务将是 service_name值和db_domain值的拼接。

动态监听的优点:
(1)不需要人工干预,在lsnrctl start后,会自动注册数据库的instance_name,service_name,然后tns不论使用SID和SERVICE_NAME均可以连接上来
(2)修改了SERVICE_NAME或者SID不用修改listener.ora文件
(3)动态注册的数据库通过状态信息中的状态READY或状态BLOCKED(对于一个备用数据库)来指明。
不管关闭何时数据库,动态注册的数据库都会动态地从 监听器注销,而与之相关的信息将从状态列表中消失。这样,不管数据库是在运行还是已经关闭,监听器总是知道它的状态。该信息将被用于连接请求的回退(fallback)和负载平衡。动态监听由PMON进程会向监听进行动态注册,也可以手动注册:ALTER SYSTEM REGISTER;
4.静态监听
静态注册指实例启动时读取listener.ora配置文件,将实例和服务注册到监听程序。
优点:
无论何时启动一个数据库,默认都有两条信息注册到监听器中:实例和服务。在数据库未open状态中,就可以远程连接到数据库,对数据库进行操作--当然了要配置密码文件。

如何配置监听--单实例:
默认端口动态监听

PROD = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lx01)(PORT = 1521)) ) ) TNS配置--(TNS名可以随意起) PROD = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = lx01)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = prod) ) )
Copy after login
非默认端口动态监听
PROD= (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lx01)(PORT = 1529)) ) ) TNS配置 PROD = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lx01)(PORT = 1529)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prod) ) ) 动态注册默认只注册到默认的监听器上(名称是LISTENER、端口是1521、协议是TCP),因为pmon只会动态注册port等于1521的监听,否则pmon不能动态注册listener,如果需要向非默认监听注册,则需要配置local_listener参数! SYS@ prod>show parameter local NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ local_listener string PROD =服务器端TNS名,或者写TNS串 ---非默认动态端口必须配置 log_archive_local_first boolean TRUE parallel_force_local boolean FALSE
Copy after login
非默认端口静态监听-----(多个实例,红色字体追加)
prod = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lx01)(PORT = 1527)) ) ) SID_LIST_LISTENER= (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = prod) (ORACLE_HOME =/u01/app/oracle/product/11.2.0/db_1) (SID_NAME = prod) ) ) TNS配置 test = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = lx01)(PORT = 1527)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = prod) ) )
Copy after login
11g RAC后查看监听文件有如下变化
[grid@rac1 admin]$ more listener.ora LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent [grid@rac1 admin]$ more endpoints_listener.ora LISTENER_RAC1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1-vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.21)(PORT=1521)(IP=FIRST)))) # line added by Agent 以上listener.ora配置文件中的信息是Grid Infrastructure安装过程中Agent自行添加的(During the Grid Infrastructure installation, the (default) node VIP listener is always created referencing the public network),11.2 GI的LISTENER 监听器配置默认受到11.2新引入的endpoints_listener.ora配置文件的管理。
Copy after login
如何在11R2 新建一个监听(非scan监听)呢?下面是一个快捷的方法(红色字体)
[grid@rac1 admin]$ srvctl config scan SCAN name: rac-scan, Network: 1/192.168.6.0/255.255.255.0/eth0 SCAN VIP name: scan1, IP: /rac-scan/192.168.6.41 [grid@rac1 admin]$ srvctl add listener -h Adds a listener configuration to the Oracle Clusterware. Usage: srvctl add listener [-l ] [-s] [-p "[TCP:][, ...][/IPC:][/NMP:][/TCPS:] [/SDP:]"] [-o ] [-k ] -l  Listener name (default name is LISTENER) -o  ORACLE_HOME path (default value is CRS_HOME) -k  VIP network number (default number is 1) -s Skip the checking of ports -p "[TCP:][, ...][/IPC:][/NMP:][/TCPS:] [/SDP:]" Comma separated tcp ports or listener endpoints -h Print usage -k 填入方才获得的network number,-p填入端口号,-l填入监听名,-o 填入GI HOME路径 [grid@rac1 admin]$ srvctl add listener -l rac-fyl -o $ORACLE_HOME -p 1522 -k 1 [grid@rac1 admin]$ srvctl start listener -l rac-fyl srvctl start listener启动新添加的监听后listener.ora和endpoints_listener.ora会出现新的记录: [grid@rac1 admin]$ more listener.ora RAC-FYL=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=RAC-FYL)))) # line added by Agent ENABLE_GLOBAL_DYNAMIC_ENDPOINT_RAC-FYL=ON # line added by Agent [grid@rac1 admin]$ more endpoints_listener.ora RAC-FYL_RAC1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1-vip)(PORT=1522))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.6.21)(PORT=1522)(IP=FIRST)))) # line added by Agent 之后仅需要在listener.ora中加入静态注册信息即可,如: SID_LIST_RAC-FYL = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = fyl) (ORACLE_HOME =/u01/app/oracle/product/11.2.0/db_1 ) (SID_NAME = fyl1) ) )
Copy after login
[grid@rac1 admin]$ srvctl stop listener -l rac-fyl [grid@rac1 admin]$ srvctl start listener -l rac-fyl 客户端TNS如下配置 RAC-VIP = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.32)(PORT = 1521)) ----rac2-vip (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.22)(PORT = 1521)) ----rac1-vip (LOAD_BALANCE = ON) (FAILOVER = ON) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = fyl) ) )
Copy after login
11g rac可以使用 LISTENER_SCAN1
[grid@rac1 admin]$ lsnrctl status LISTENER_SCAN1 LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 15-SEP-2014 22:19:10 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))) STATUS of the LISTENER ------------------------ Alias LISTENER_SCAN1 Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 15-SEP-2014 18:48:44 Uptime 0 days 3 hr. 30 min. 26 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora Listener Log File /u01/app/11.2.0/grid/log/diag/tnslsnr/rac1/listener_scan1/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.6.41)(PORT=1526))) ----rac-scan IP Services Summary... Service "fyl" has 1 instance(s). Instance "fyl1", status READY, has 1 handler(s) for this service... Instance "fyl2", status READY, has 1 handler(s) for this service... Service "fylXDB" has 1 instance(s). Instance "fyl1", status READY, has 1 handler(s) for this service... Instance "fyl2", status READY, has 1 handler(s) for this service... The command completed successfully 这是利用ORACLE的remote_listener参数 SQL> show parameter list NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ listener_networks string local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD DRESS=(PROTOCOL=TCP)(HOST=rac1 -vip)(PORT=1521)))) remote_listener string rac-scan:1526
Copy after login





Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!