码迷,mamicode.com
首页 > 数据库 > 详细

Oracle 11gR2 RAC监听器原理介绍

时间:2018-01-08 14:53:43      阅读:343      评论:0      收藏:0      [点我收藏+]

标签:ddr   oracle   command   file   建议   key   负载   isp   不能   

一、基本概念

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配置:

[grid@node1 admin]$ pwd

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

[grid@node1 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配置:

[grid@node2 admin]$ pwd

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

[grid@node2 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:

[grid@node1 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:

[grid@node2 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:

[oracle@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:

[oracle@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

4、查看scan listener配置

节点1:

[grid@node1 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:

[grid@node2 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:

[grid@node1 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:

[grid@node2 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:

[grid@node1 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:

[grid@node1 admin]$ srvctl config listener

Name: LISTENER

Network: 1, Owner: grid

Home: <CRS home>

End points: TCP:1521

节点2:

[grid@node2 admin]$ srvctl config listener

Name: LISTENER

Network: 1, Owner: grid

Home: <CRS home>

End points: TCP:1521

7、查看本地监听器状态

节点1:

[grid@node1 admin]$ srvctl status listener

Listener LISTENER is enabled

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

节点2:

[grid@node2 admin]$ srvctl status listener

Listener LISTENER is enabled

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

lsnrctl查看本地监听器状态:

节点1:

[grid@node1 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:

[grid@node1 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:

[grid@node2 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、查看数据库服务的状态

[grid@node1 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监听器原理介绍

标签:ddr   oracle   command   file   建议   key   负载   isp   不能   

原文地址:https://www.cnblogs.com/lcword/p/8242202.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!