Oracle 11gR2 RAC监听器原理介绍

Posted lclc

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle 11gR2 RAC监听器原理介绍相关的知识,希望对你有一定的参考价值。

一、基本概念

oracle11gR2 RAC开始引入scan概念,一般通过dns服务器或gns服务器解析scan,也可以使用/etc/hosts文件解析scan,只不过oracle官方不建议这样做,hosts文件只能解析一个scan ip;另一个方面监听器前移到$GRID_HOME/network/admin/listener.ora文件,即11g rac监听器由grid用户管理,oracle用户保留文件,但已经不起作用。客户端文件tnsnames.ora依然在$ORACLE_HOME/network/admin/tnsnames.ora文件。scan的提出彻底做到了rac数据库对用户的透明管理,客户端通过scan域名直接连接数据库即可(首先客户端可以解析scan域名),具体由DNS服务器解析域名,这里如果用dns解析scan,最多可以解析3个scan vip,通过scan域名访问数据库可以实现scan vip的failover和负载均衡,即只要3个scan vip中存活一个,客户端应用既可以访问数据库。如果采用hosts文件解析scan,只能解析一个scan vip。

oracle 10g rac中监听器由oracle用户管理,每个节点上,只有一个监听器,但是这个监听器同时监听public ip和vip,即oracle 10g rac中的监听器同时承担着路由选择和建立连接的功能。10g rac客户端通过vip连接数据库。

oracle 11g rac中使用GRID_HOME下的监听器而不采用ORACLE_HOME 下的监听器,同时在oracle 11g rac中出现了多个监听器,使用名称区分。所以11g rac的监听器使用grid用户管理,而不能通过oracle用户进行管理。11g rac监听器分本地监听器(建立连接)和scan监听器(路由转发)2种,另外,每一个scan vip都会有一个scan监听器,并且运行在同一个节点上。即

rac中,每个节点上都运行一个本地监听器,这个监听器负责监听本地的vip。

rac中,会有3个节点上运行scan监听器。

rac中,scanvip和scan监听器成对出现。

二、监听器管理及故障处理

节点1 listener.ora配置:

[[email protected] admin]$ pwd

/u01/app/11.2.0/grid/network/admin

[[email protected] admin]$ cat listener.ora

# listener.ora.node1 Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora.node1

# Generated by Oracle configuration tools.

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN3 = ON

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN2 = ON

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1 = ON

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER1 = ON

LISTENER =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))

)

)

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

LISTENER_SCAN3 =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN3))

)

)

LISTENER_SCAN2 =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN2))

)

)

LISTENER_SCAN1 =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN1))

)

)

节点2 listener.ora配置:

[[email protected] admin]$ pwd

/u01/app/11.2.0/grid/network/admin

[[email protected] admin]$ cat listener.ora

# listener.ora.node2 Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora.node2

# Generated by Oracle configuration tools.

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN3 = ON

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN2 = ON

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1 = ON

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER1 = ON

SID_LIST_LISTENER1 =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = orcl)

(ORACLE_HOME = /u01/app/11.2.0/grid)

(SID_NAME = orcl2)

)

)

LISTENER =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))

)

ADR_BASE_LISTENER = /u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

LISTENER_SCAN3 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN3))

)

LISTENER_SCAN2 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN2))

)

LISTENER_SCAN1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN1))

)

ADR_BASE_LISTENER_SCAN3 = /u01/app/grid

ADR_BASE_LISTENER_SCAN2 = /u01/app/grid

ADR_BASE_LISTENER_SCAN1 = /u01/app/grid

1、查看scan vip配置

节点1:

[[email protected] admin]$ srvctl config scan

SCAN name: scan-cluster, Network: 1/192.168.100.0/255.255.255.0/eth0

SCAN VIP name: scan1, IP: /scan-cluster/192.168.100.45

SCAN VIP name: scan2, IP: /scan-cluster/192.168.100.46

SCAN VIP name: scan3, IP: /scan-cluster/192.168.100.47

节点2:

[[email protected] admin]$ srvctl config scan

SCAN name: scan-cluster, Network: 1/192.168.100.0/255.255.255.0/eth0

SCAN VIP name: scan1, IP: /scan-cluster/192.168.100.45

SCAN VIP name: scan2, IP: /scan-cluster/192.168.100.46

SCAN VIP name: scan3, IP: /scan-cluster/192.168.100.47

2、查看scan vip状态(静态)

节点1:

[grid@node1 admin]$ srvctl status scan

SCAN VIP scan1 is enabled

SCAN VIP scan1 is running on node node2

SCAN VIP scan2 is enabled

SCAN VIP scan2 is running on node node2

SCAN VIP scan3 is enabled

SCAN VIP scan3 is running on node node1

节点2:

[grid@node2 admin]$ srvctl status scan

SCAN VIP scan1 is enabled

SCAN VIP scan1 is running on node node2

SCAN VIP scan2 is enabled

SCAN VIP scan2 is running on node node2

SCAN VIP scan3 is enabled

SCAN VIP scan3 is running on node node1

3、查看scan vip状态(动态)

节点1:

[[email protected] admin]$ srvctl status scan

SCAN VIP scan1 is enabled

SCAN VIP scan1 is running on node node2

SCAN VIP scan2 is enabled

SCAN VIP scan2 is running on node node2

SCAN VIP scan3 is enabled

SCAN VIP scan3 is running on node node1

节点2:

[[email protected] admin]$ srvctl status scan

SCAN VIP scan1 is enabled

SCAN VIP scan1 is running on node node2

SCAN VIP scan2 is enabled

SCAN VIP scan2 is running on node node2

SCAN VIP scan3 is enabled

SCAN VIP scan3 is running on node node1

4、查看scan listener配置

节点1:

[[email protected] admin]$ srvctl config scan_listener

SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521

SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521

SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521

节点2:

[[email protected] admin]$ srvctl config scan_listener

SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521

SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521

SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521

5、查看scan listener状态

节点1:

[[email protected] admin]$ srvctl status scan_listener

SCAN Listener LISTENER_SCAN1 is enabled

SCAN listener LISTENER_SCAN1 is running on node node2

SCAN Listener LISTENER_SCAN2 is enabled

SCAN listener LISTENER_SCAN2 is running on node node2

SCAN Listener LISTENER_SCAN3 is enabled

SCAN listener LISTENER_SCAN3 is running on node node1

节点2:

[[email protected] admin]$ srvctl status scan_listener

SCAN Listener LISTENER_SCAN1 is enabled

SCAN listener LISTENER_SCAN1 is running on node node2

SCAN Listener LISTENER_SCAN2 is enabled

SCAN listener LISTENER_SCAN2 is running on node node2

SCAN Listener LISTENER_SCAN3 is enabled

SCAN listener LISTENER_SCAN3 is running on node node1

lsnrct命令查看scan vip状态:

节点1:

[[email protected] admin]$ lsnrctl status LISTENER_SCAN3

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 25-MAR-2016 16:09:39

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN3)))

STATUS of the LISTENER

------------------------

Alias LISTENER_SCAN3

Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date 25-MAR-2016 11:24:15

Uptime 0 days 4 hr. 45 min. 23 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/node1/listener_scan3/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN3)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.47)(PORT=1521)))

Services Summary...

Service "orcl" has 2 instance(s).

Instance "orcl1", status READY, has 1 handler(s) for this service...

Instance "orcl2", status READY, has 1 handler(s) for this service...

Service "orclXDB" has 2 instance(s).

Instance "orcl1", status READY, has 1 handler(s) for this service...

Instance "orcl2", status READY, has 1 handler(s) for this service...

The command completed successfully

6、查看本地监听器配置

节点1:

[[email protected] admin]$ srvctl config listener

Name: LISTENER

Network: 1, Owner: grid

Home: <CRS home>

End points: TCP:1521

节点2:

[[email protected] admin]$ srvctl config listener

Name: LISTENER

Network: 1, Owner: grid

Home: <CRS home>

End points: TCP:1521

7、查看本地监听器状态

节点1:

[[email protected] admin]$ srvctl status listener

Listener LISTENER is enabled

Listener LISTENER is running on node(s): node2,node1

节点2:

[[email protected] admin]$ srvctl status listener

Listener LISTENER is enabled

Listener LISTENER is running on node(s): node2,node1

lsnrctl查看本地监听器状态:

节点1:

[[email protected] admin]$ lsnrctl status listener

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 25-MAR-2016 16:08:03

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date 25-MAR-2016 11:24:17

Uptime 0 days 4 hr. 43 min. 46 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/grid/diag/tnslsnr/node1/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.41)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.100.42)(PORT=1521)))

Services Summary...

Service "+ASM" has 1 instance(s).

Instance "+ASM1", status READY, has 1 handler(s) for this service...

Service "orcl" has 1 instance(s).

Instance "orcl1", status READY, has 1 handler(s) for this service...

Service "orclXDB" has 1 instance(s).

Instance "orcl1", status READY, has 1 handler(s) for this service...

The command completed successfully

8、查看本地运行的监听器

节点1:

[[email protected] admin]$ ps -ef|grep lsnr

grid 6290 8174 0 16:12 pts/1 00:00:00 grep lsnr

grid 23796 1 0 11:24 ? 00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN3 -inherit

grid 23859 1 0 11:24 ? 00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER -inherit

节点2:

[[email protected] admin]$ ps -ef|grep lsnr

grid 8649 1 0 11:44 ? 00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN2 -inherit

grid 10591 1 0 Mar24 ? 00:00:01 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER -inherit

grid 18776 6639 0 16:13 pts/1 00:00:00 grep lsnr

grid 24334 1 0 Mar24 ? 00:00:02 /u01/app/11.2.0/grid/bin/tnslsnr LISTENER_SCAN1 -inherit

9、查看数据库服务的状态

[[email protected] admin]$ lsnrctl service

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 25-MAR-2016 16:19:54

Copyright (c) 1991, 2013, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))

Services Summary...

Service "+ASM" has 1 instance(s).

Instance "+ASM1", status READY, has 1 handler(s) for this service...

Handler(s):

"DEDICATED" established:0 refused:0 state:ready

LOCAL SERVER

Service "orcl" has 1 instance(s).

Instance "orcl1", status READY, has 1 handler(s) for this service...

Handler(s):

"DEDICATED" established:3 refused:0 state:ready

LOCAL SERVER

Service "orclXDB" has 1 instance(s).

Instance "orcl1", status READY, has 1 handler(s) for this service...

Handler(s):

"D000" established:0 refused:0 current:0 max:1022 state:ready

DISPATCHER <machine: node1, pid: 11849>

(ADDRESS=(PROTOCOL=tcp)(HOST=node1)(PORT=43836))

The command completed successfully

以上是关于Oracle 11gR2 RAC监听器原理介绍的主要内容,如果未能解决你的问题,请参考以下文章

Oracle 11gR2 RAC连接时ORA-12545错误

Oracle 11gR2 RAC集群服务启动与关闭总结

Oracle 11G R2 RAC中的scan ip 的用途和基本原理

Oracle RACLinux系统Oracle11gR2 RAC安装配置详细过程V3.1(图文并茂)

Oracle 11g RAC 监听日常管理

oper-O11gR2+ASM+RAC使用duplicate快速复制一个库到单实例