oracle查询报错clb,Oracle RAC 负载均衡与故障转移(三)

 2023-09-11 阅读 18 评论 0

摘要:Server Service TAFhttps://www.cndba.cn/Breath/article/2324数据库负载均衡、服务端 service TAF1.服务器端透明故障转移,通过配置service来实现,客户端无须任何Failover的配置。2.之前提到的应用层负载也是基于创建多个service 指定 不同的 “首选实例”

Server Service TAF

https://www.cndba.cn/Breath/article/2324

数据库负载均衡、服务端 service TAF

1.服务器端透明故障转移,通过配置service来实现,客户端无须任何Failover的配置。

2.之前提到的应用层负载也是基于创建多个service 指定 不同的 “首选实例”,然后不同的应用程序去分散连接service,来达到分散负载的功能。且通过这种的”业务隔离”能减少Cache Fusion的流量,减少实例间的相互依赖https://www.cndba.cn/Breath/article/2324

负载均衡怎么做?配置

service创建有多种方式,dbca,oem,srvctl命令行。下面是srvctl配置方式:

不能用gird用户创建service,报错如下:

负载均衡socket集群?[grid@breath01 ~]$ srvctl add service -d breath -s breath_TAF1 -r “breath1” -a “breath2” -P basic -m basic -e select -w 3 -z 100

PRCD-1026 : Failed to create service breath_TAF1 for database breath

PRKH-1014 : Current user “grid” is not the oracle owner user “oracle” of oracle home “/u01/app/oracle/product/11.2.0/dbhome_1”

切换oracle用户下:

[grid@breath01 ~]$ su - oracle

Password:

创建两个服务(实现业务隔离分散负载的作用):

breath_TAF1——-首选实例breath1,备选实例breath2

breath_TAF2——-首选实例breath2,备选实例breath1

[oracle@breath01 ~]$ srvctl add service -d breath -s breath_TAF1 -r “breath1” -a “breath2” -P basic -m basic -e select -w 3 -z 100

[oracle@breath01 ~]$ srvctl add service -d breath -s breath_TAF2 -r “breath2” -a “breath1” -P basic -m basic -e select -w 3 -z 100

-d Unique name for the database —数据库名称

-s Service name —自定义服务名

-r ““ Comma separated list of preferred instances —首选实例名称

-a ““ Comma separated list of available instances —备选实例

-P {NONE | BASIC | PRECONNECT} TAF policy specification —TAF策略

-m Failover method (NONE or BASIC)

-e Failover type (NONE, SESSION, or SELECT)

-w Failover delay

-z Failover retries

启动服务和查看服务的配置

[grid@breath01 ~]$ srvctl start service -d breath -s breath_TAF1,breath_TAF2

[grid@breath01 ~]$ srvctl config service -d breath

Service name: breath_TAF1

Service is enabled

Server pool: breath_breath_TAF1

Cardinality: 1

Disconnect: false

Service role: PRIMARY

Management policy: AUTOMATIC

DTP transaction: false

AQ HA notifications: false

Failover type: SELECT

Failover method: BASIC

TAF failover retries: 100

TAF failover delay: 3

Connection Load Balancing Goal: LONG

Runtime Load Balancing Goal: NONE

TAF policy specification: BASIC

Edition:

Preferred instances: breath1

Available instances: breath2

Service name: breath_TAF2

Service is enabled

Server pool: breath_breath_TAF2

Cardinality: 1

Disconnect: false

Service role: PRIMARY

Management policy: AUTOMATIC

DTP transaction: false

AQ HA notifications: false

Failover type: SELECT

Failover method: BASIC

TAF failover retries: 100

TAF failover delay: 3

Connection Load Balancing Goal: LONG

Runtime Load Balancing Goal: NONE

TAF policy specification: BASIC

Edition:

Preferred instances: breath2

Available instances: breath1https://www.cndba.cn/Breath/article/2324https://www.cndba.cn/Breath/article/2324

修改service_name 参数,默认只会添加到一个节点上https://www.cndba.cn/Breath/article/2324https://www.cndba.cn/Breath/article/2324

如节点二上:

SYS@breath2>show parameter service

NAME TYPE VALUE

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

service_names string breath_TAF2

SYS@breath2>ALTER SYSTEM SET service_names='breath_TAF1,breath_TAF2' sid='*';

SYS@breath2>show parameter service

NAME TYPE VALUE

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

service_names string breath_TAF1,breath_TAF2

[grid@breath01 ~]$ lsnrctl status

Service “breath_TAF1” has 2 instance(s).

Instance “breath1”, status READY, has 1 handler(s) for this service…

Instance “breath2”, status READY, has 2 handler(s) for this service…

Service “breath_TAF2” has 2 instance(s).

Instance “breath1”, status READY, has 1 handler(s) for this service…

Instance “breath2”, status READY, has 2 handler(s) for this service…

The command completed successfully

[root@breath01 ~]# crsctl stat res -t

……….

ora.breath.breath_taf1.svc1 ONLINE ONLINE breath01

ora.breath.breath_taf2.svc1 ONLINE ONLINE breath02

https://www.cndba.cn/Breath/article/2324

查看service TAF 策略 ,视图 dba_services:

https://www.cndba.cn/Breath/article/2324

set line 300

col name format a15

col failover_method format a11 heading 'METHOD'

col failover_type format a10 heading 'TYPE'

col failover_retries format 9999999 heading 'RETRIES'

col FAILOVER_DELAY for 999999 heading 'DELAY'

col goal format a10

col clb_goal format a8

select name, failover_method, failover_type, failover_retries,FAILOVER_DELAY,goal, clb_goal from dba_services where name in ('breath_TAF1','breath_TAF2');

NAME METHOD TYPE RETRIES DELAY GOAL CLB_GOAL

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

breath_TAF2 BASIC SELECT 100 3 NONE LONG

breath_TAF1 BASIC SELECT 100 3 NONE LONG

修改service TAF 策略 方法两种:

①.srvctl modify service

修改 breath_TAF2:

[oracle@breath01 ~]$ srvctl modify service -d breath -s breath_TAF2 -P basic -m basic -e session -w 10 -z 50

SYS@breath1>select name, failover_method, failover_type, failover_retries,FAILOVER_DELAY,goal, clb_goal from dba_services where name in ('breath_TAF1','breath_TAF2');

NAME METHOD TYPE RETRIES DELAY GOAL CLB_GOAL

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

breath_TAF2 BASIC SESSION 50 10 NONE LONG

breath_TAF1 BASIC SELECT 100 3 NONE LONG

②通过dbms_service包

修改breath_TAF1:

Begin

Dbms_service.modify_service(

Service_name=>'breath_TAF1',

Failover_method=>dbms_service.failover_method_basic,

Failover_type=>dbms_service.failover_type_session,

Failover_retries=>180,

Failover_delay=>5

);

End;

SYS@breath1>select name, failover_method, failover_type, failover_retries,FAILOVER_DELAY,goal, clb_goal from dba_services where name in ('breath_TAF1','breath_TAF2');

NAME METHOD TYPE RETRIES DELAY GOAL CLB_GOAL

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

breath_TAF2 BASIC SESSION 50 10 NONE LONG

breath_TAF1 BASIC SESSION 180 5 NONE LONG

客户端测试service TAF

客户端配置

breath_TAF1 =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = breath01-vip)(PORT = 1522))

(ADDRESS = (PROTOCOL = TCP)(HOST = breath02-vip)(PORT = 1522))

(LOAD_BALANCE = OFF)

(FAILOVER=OFF) ----禁用客户端FAILOVER功能,方便测试

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = breath_TAF1) ---注意服务名

)

)

[oracle@breath admin]$ sqlplus system/oracle@breath_taf1

SYSTEM@breath_taf1>select INSTANCE_NAME,VERSION from v$instance;

INSTANCE_NAME VERSION

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

breath1 11.2.0.3.0

SYSTEM@breath_taf1>select sid,failover_type,failover_method,failed_over from v$session where sid=(select sid from v$mystat where rownum=1);

SID FAILOVER_TYPE FAILOVER_M FAI

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

27 SESSION BASIC NO

服务端关闭breath1实例

[grid@breath01 ~]$ srvctl stop instance -d breath -i breath1https://www.cndba.cn/Breath/article/2324

SYSTEM@breath_taf1>select INSTANCE_NAME,VERSION from v$instance;

INSTANCE_NAME VERSION

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

breath2 11.2.0.3.0

SYSTEM@breath_taf1>select sid,failover_type,failover_method,failed_over from v$session where sid=(select sid from v$mystat where rownum=1);

SID FAILOVER_TYPE FAILOVER_M FAI

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

28 SELECT BASIC YES

这里变成yes 证明是经过了failover

版权声明:本文为博主原创文章,未经博主允许不得转载。

RAC 故障转移

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/2/49674.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息