RAC监听与tns

监听

个人理解:本来想通过scan ip来配置tns总数报12545,后来通过vip来配置tns

11g rac的监听在安装时创建,由grid用户管理监听,listener.ora文件在$ORACLE_HOME/network/admin目录中。rac中有asm实例和数据库实例。

[[email protected] ~]$ sqlplus "/as sysasm"

SQL> show parameter listen;

NAME                      TYPE             VALUE
----------------      ----------- ------------------------------
listener_networks     string
local_listener            string       (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1521))))
remote_listener        string

[[email protected] ~]$ sqlplus "/as sysasm"

SQL> show parameter listen;

NAME                      TYPE             VALUE
----------------      ----------- ------------------------------
listener_networks     string
local_listener            string       (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1521))))
remote_listener        string

查看监听状态:

节点1:

[[email protected] ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 18-JAN-2016 06:09:17

Copyright (c) 1991, 2009, 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.1.0 - Production

Start Date                18-JAN-2016 00:15:53

Uptime                    0 days 5 hr. 53 min. 23 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/11.2.0/grid/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/node1/listener/alert/log.xml

Listening Endpoints Summary...

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

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

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

Services Summary...

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

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

Service "RACDB" has 1 instance(s).

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

Service "RACDBXDB" has 1 instance(s).

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

(红色部分,如果在数据库实例中的host没有配置vip地址就不会显示)

The command completed successfully

节点2:

[[email protected] ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 18-JAN-2016 06:10:51

Copyright (c) 1991, 2009, 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.1.0 - Production

Start Date                18-JAN-2016 00:15:54

Uptime                    0 days 5 hr. 54 min. 59 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/11.2.0/grid/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/node2/listener/alert/log.xml

Listening Endpoints Summary...

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

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

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

Services Summary...

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

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

Service "RACDB" has 1 instance(s).

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

Service "RACDBXDB" has 1 instance(s).

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

The command completed successfully

查看oracle实例的listener配置:

[[email protected] ~]$ sqlplus "/as sysdba"

SQL> show parameter listen;

NAME                         TYPE              VALUE
-----------------      ----------- ------------------------------
listener_networks        string                                                                          (这个位置不能配置scan ip,试了不可行,本来想通过scan ip配置tns)
local_listener               string       (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1521))))
remote_listener           string       rac-scan:1521

[[email protected] ~]$ sqlplus "/as sysdba"

SQL> show parameter listen;

NAME                         TYPE              VALUE
-----------------      ----------- ------------------------------
listener_networks        string
local_listener               string       (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1521))))
remote_listener           string       rac-scan:1521

可通过下面语句修改参数:

alter system set local_listener = ‘(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1521))))‘ scope=both sid=‘RACDB1‘;

alter system register;

tns:

第一种:

rac =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.201)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.202)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = RACDB)

)

)

这种情况,连接的实例挂掉,会断开重新连接另一个实例。

第二种:

TAF(Transparent Application Failover):

11g文档位置:Database Administration->Network Management->Local Naming Parameters(tnsname.ora)->

搜索retries ->Oracle Database Net Services Administrator‘s Guide

  Basic:

rac=

(DESCRIPTION=

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.201)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.202)(PORT = 1521))

)

(LOAD_BALANCE = on)

(CONNECT_DATA=

(SERVICE_NAME=RACDB)

(FAILOVER_MODE=

(TYPE=select) –有session 和select (select 查询1w条,返回1k后挂掉,重新连接返回9k,session重新查询)两种

(METHOD=basic)

(RETRIES=20)

(DELAY=15)

)

)

)

--如果连接的实例挂掉,重新建立连接,不会先断开。

  Preconnect:

rac1=

(DESCRIPTION=

(ADDRESS=

(PROTOCOL=tcp)

(HOST=192.168.56.201)

(PORT=1521))

(CONNECT_DATA=

(SERVICE_NAME=RACDB)

(INSTANCE_NAME=RACDB1)

(FAILOVER_MODE=

(BACKUP=rac2)

(TYPE=select)

(METHOD=preconnect))))

rac2=

(DESCRIPTION=

(ADDRESS=

(PROTOCOL=tcp)

(HOST=192.168.56.201)

(PORT=1521))

(CONNECT_DATA=

(SERVICE_NAME=RACDB)

(INSTANCE_NAME=sales2)

(FAILOVER_MODE=

(BACKUP=RACDB2)

(TYPE=select)

(METHOD=preconnect))))

--切换快,但是浪费资源.先建立连接。

以上的方式为客户端,下面的方式为服务端。

第三种:

创建服务(oracle用户)

srvctl add service –d RACDB –s HAHA –r ‘RACDB2,RACDB1’ –P basic

启动服务

srvctl start service –d RACDB –s HAHA

show parameter service;服务名为HAHA不是RACDB.

通过函数修改

begin

dbms_service.modify_service(service_name     => ‘HAHA‘,

failover_method  => ‘dbms_service.failover_method_basic‘,

failover_type    => ‘dbms_service.failover_type_select‘,

failover_retries => 180,

failover_delay   => 5);

end;

查看服务进程:crs_stat -t 列表中有没有HAHA的进程

客户端配置tns

rac-taf =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.201)(PORT = 1521))

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.202)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = HAHA)

)

)

srvctl:

srvctl status database –d RACDB

srvctl status instance –d RACDB –i RACDB1

srvctl stop instance –d RACDB –I RACDB2

时间: 2024-11-07 09:13:36

RAC监听与tns的相关文章

oracle rac 监听配置

一.总体概述 Oracle RAC 监听器的配置与单实例稍有不同,但原理和实现方法基本上是相同的.在Oracle服务端中 tns进程用于为指定网络地址上的一个或多个Oracle 实例提供服务注册,并响应来自客户端对该服务提出的连接请求.一旦连接请求到达,并派生出一个服务器进程建立服务器与用户端之间的连接(专有服务器dedicated server)或转发服务请求(共享服务器模式shared server).如果监听器知道多于一个实例提供所请求的服务,则可能会根据客户端与服务器端相关配置将请求定位

修改oracle 10g rac监听端口号为1523的步骤

修改oracle  10g rac监听端口号为1523的步骤 一. 修改listener.ora ,将其中的1521改为1523.事先做该文件的备份,以便快速复原 二. 修改tnsnames.ora ,将remote_listener对应的值 在 tnsnames.ora中的参数改为1523,事先做该文件的备份,以便快速复原 三. 修改local_listener数据库初始化参数 alter system set local_listener = '(ADDRESS = (PROTOCOL =

oracle 11g rac 监听程序offline

oracle 11g rac 监听程序在调整过网络后出现监听进程offline,而且两台节点之间频繁切换,查看日志/var/log/message 发现有频繁的注册撤销动作. 监听日志 /u01/app/oracle/diag/tnslsnr/rac1/listener/trace/listener.log监听文件 /u01/app/11.2.0/grid/network/admin/listener.oraoracle错误日志 /u01/app/oracle/diag/rdbms/oaorcl

Oracle 11g RAC 监听日常管理

需要必须掌握的命令,上周遇到了一个小问题,就是需要重启数据库监听,有的同学竟然使用oracle用户重启监听,原理就搞错了怎么行.以下操作都需要再grid用户下进行操作. 1.查看监听状态 <roidb2:+ASM2:/home/grid>$srvctl status listener Listener LISTENER is enabled Listener LISTENER is running on node(s): roidb1,roidb2 <roidb2:+ASM2:/home

ORACLE RAC 监听配置 (listener.ora tnsnames.ora)

Oracle RAC 监听器的配置与单实例稍有不同,但原理和实现方法基本上是相同的.在Oracle中 tns进程用于为指定网络地址上的一个或多个Oracle 实例提供服务注册,并响应来自客户端对该服务提出的连接请求.一旦连接请求到达,并派生出一个服务器进程建立服务器与用户端之间的连接(专有服务器dedicated server)或转发服务请求(共享服务器模式shared server).如果监听器知道多于一个实例提供所请求的服务,则可能会根据客户端与服务器端相关配置将请求定位到较低负载的实例为其

ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)

不论是单实例还是RAC,对于非缺省端口下(1521)的监听器,pmon进程不会将service/instance注册到监听器,即不会实现动态注册.与单实例相同,RAC非缺省端口的监听器也是通过设置参数local_listener来达到目的.除此之外,还可以对实例进行远程注册,以达到负载均衡的目的.这是通过一个参数remote_listener来实现. 有关Oracle 网络配置相关基础以及概念性的问题请参考:      配置ORACLE 客户端连接到数据库   配置非默认端口的动态服务注册   

oracle 11g RAC数据库监听配置相关

oracle RAC 监听配置基本和单实例的配置相同 11g之后 安装RAC的过程中,不需要执行netca来手动创建监听,在安装集群软件的时候,会自动创建监听程序: 而在DBCA建库的时候,又会自动创建tnsname.ora文件 强烈推荐这篇: http://www.oracle.com/technetwork/cn/articles/database-performance/oracle-rac-connection-mgmt-1650424-zhs.html http://www.cnblo

Oracle监听服务无法启动或丢失的解决办法

当用可视化工具连接时,错误提示: 执行请求的操作时遇到错误: IO 错误: The Network Adapter could not establish the connection 1)使用了Cclear或鲁大师等注册表清理工具清理后导致无法启动 无法启动OracleOraDb10g_home1TNSListener服务 解决办法:①打开注册表编辑器,在HKEY_LOCAL_MACHINE/SYSTEM/ControlSet/下的Services和HKEY_LOCAL_MACHINE/SYS

11g rac grid用户来管理监听程序

Oracle 11g RAC 数据库监听默认都是grid用户通过集群工具来进行管理的,但是有些时候我们会发现数据库监听程序有oracle用户启动的,这里就存在一些问题.比如,出现的多余的监听进程我们可以kill掉 <roidb2:+ASM2:/home/grid>$ps -ef|grep tns root 10 2 0 08:11 ? 00:00:00 [netns] grid 4880 1 0 08:24 ? 00:00:00 /u01/app/11.2.0/grid/bin/tnslsnr