Service如何使用referred和avileable固定会话到一个节点并且宕机后会切换到另一个节点

68次阅读
没有评论

共计 7198 个字符,预计需要花费 18 分钟才能阅读完成。

行业资讯    
数据库    
关系型数据库    
Service 如何使用 referred 和 avileable 固定会话到一个节点并且宕机后会切换到另一个节点

这篇文章给大家分享的是有关 Service 如何使用 referred 和 avileable 固定会话到一个节点并且宕机后会切换到另一个节点的内容。丸趣 TV 小编觉得挺实用的,因此分享给大家做个参考,一起跟随丸趣 TV 小编过来看看吧。

Service 使用 referred 和 avileable 固定 session 连接到一台数据库服务器上,这台数据库服务器宕机后会切换到另一台数据库服务器上

管理员管理的 DB 里,service 分为:
– preferred instance:服务启动的时候,在哪个实例上启动,该实例就是 preferred instance。
– available instance:服务所在的实例崩溃,集群件会在另外一个 available instance 里启动该服务。

必须在 oracle 用户下执行
[root@node1 ~]# srvctl add service -d orcl  -s srv1 -r orcl1 -a orcl2
PRCD-1026 : Failed to create service srv1 for database orcl
PRKH-1014 : Current user root is not the oracle owner user oracle of oracle home /u01/app/oracle/product/11.2.0/dbhome_1

[oracle@node1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 24-AUG-2017 19:56:25
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date                24-AUG-2017 19:19:59
Uptime                    0 days 0 hr. 36 min. 49 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.92.20)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.22)(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

[oracle@node2 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 24-AUG-2017 19:55:48
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date                24-AUG-2017 19:24:29
Uptime                    0 days 0 hr. 31 min. 29 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/node2/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.24)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.23)(PORT=1521)))
Services Summary…
Service +ASM has 1 instance(s).
  Instance +ASM2 , status READY, has 1 handler(s) for this service…
Service orcl has 1 instance(s).
  Instance orcl2 , status READY, has 1 handler(s) for this service…
Service orclXDB has 1 instance(s).
  Instance orcl2 , status READY, has 1 handler(s) for this service…
The command completed successfully

添加一个 service:srv1,orcl1 是 prefer,orcl2 是 available:
srvctl add service -d orcl -s srv1 -r orcl1 -a orcl2
srvctl start service -d orcl -s srv1 

[oracle@node1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 24-AUG-2017 20:09:06
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date                24-AUG-2017 19:19:59
Uptime                    0 days 0 hr. 49 min. 12 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.92.20)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.22)(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…
Service srv1 has 1 instance(s).
  Instance orcl1 , status READY, has 1 handler(s) for this service…
The command completed successfully

[oracle@node2 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 24-AUG-2017 20:09:10
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date                24-AUG-2017 19:24:29
Uptime                    0 days 0 hr. 44 min. 44 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/node2/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.24)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.23)(PORT=1521)))
Services Summary…
Service +ASM has 1 instance(s).
  Instance +ASM2 , status READY, has 1 handler(s) for this service…
Service orcl has 1 instance(s).
  Instance orcl2 , status READY, has 1 handler(s) for this service…
Service orclXDB has 1 instance(s).
  Instance orcl2 , status READY, has 1 handler(s) for this service…
The command completed successfully

异常关闭 orcl1,再过一会,会看到 srv1 在 orcl2 上启动了。

[root@node1 ~]# crsctl stop crs

[oracle@node2 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.3.0 – Production on 24-AUG-2017 21:11:40
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.3.0 – Production
Start Date                24-AUG-2017 19:24:29
Uptime                    0 days 1 hr. 47 min. 28 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/node2/listener/alert/log.xml
Listening Endpoints Summary…
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.24)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.92.23)(PORT=1521)))
Services Summary…
Service +ASM has 1 instance(s).
  Instance +ASM2 , status READY, has 1 handler(s) for this service…
Service orcl has 1 instance(s).
  Instance orcl2 , status READY, has 1 handler(s) for this service…
Service orclXDB has 1 instance(s).
  Instance orcl2 , status READY, has 1 handler(s) for this service…
Service srv1 has 1 instance(s).
  Instance orcl2 , status READY, has 1 handler(s) for this service…
The command completed successfully

可以为服务添加多个 preferred 实例,这样可以不需要 available 实例:
srvctl add service -d orcl -s srv2 -r orcl1,orcl2
srvctl start service -d orcl -s srv2
[oracle@node1 ~]$ srvctl status service -d orcl -s srv2
Service srv2 is running on instance(s) orcl1,orcl2

service 可以只定义 preferred 实例,而不定义 available 实例。但是这样就没有 HA 了。
这样当 service 所在的实例崩溃以后,该 service 不会 failover 到另外一个实例上去。

把 srv1 从 orcl1 上运行,转移到 orcl2 上运行:
srvctl relocate service -d orcl -s srv1 -i orcl1 -t orcl2

感谢各位的阅读!关于“Service 如何使用 referred 和 avileable 固定会话到一个节点并且宕机后会切换到另一个节点”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-24发表,共计7198字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)