Get the App
SLTechnology News&Howtos  ›  Database  › 

How Service uses referred and avileable to fix sessions to one node and switch to another node after downtime

Shulou Source: shulou.com Published: 2022-05-31 15:04:54 11月15日 Update

This article is about how Service uses referred and avileable to fix sessions to one node and switch to another node after a downtime. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Service uses referred and avileable fixed session to connect to a database server, which will switch to another database server when it goes down

In the DB managed by the administrator, service is divided into:

-preferred instance: when the service is started, the instance on which it is started is preferred instance.

-available instance: the instance where the service resides crashes, and Clusterware starts the service in another available instance.

Must be executed under oracle user

[root@node1] # srvctl add service-d orcl-s srv1-r orcl1-an 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

Add a service:srv1,orcl1 is prefer,orcl2 is available:

Srvctl add service-d orcl-s srv1-r orcl1-an 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

Turn off orcl1 abnormally, and after a while, you will see that srv1 is started on 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

You can add multiple preferred instances to the service so that you do not need available instances:

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 can define only preferred instances, not available instances. But then there is no HA.

In this way, when the instance in which the service resides crashes, the service will not failover to another instance.

Run srv1 from orcl1 to orcl2:

Srvctl relocate service-d orcl-s srv1-I orcl1-t orcl2

Thank you for reading! This is the end of the article on "how to use referred and avileable to fix a session to one node and switch to another node after downtime". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Instance service node switch data database server content location more article management run good practical multiple that is article time user Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Xiaomi NVidia Linux MariaDB