How to configure services in Oracle RAC

Configure service for switch the service between instances in Oracle RAC

For configure the Services in RAC environment, we need to identify the instances to run the particular services for which particular are in the Oracle Database. Suppose, we have 4 note configuration RAC and we are having two application sales and hr department. HR is our internal only one node is sufficient and sales requires 3 instance then we configure the services according to our need. In this example, we need to create two separate service one from HR and one for Sales.

Check the services configured in Oracle RAC

[oracle@host01 ~]$ srvctl status service -d orcl 
Service srvtest is running on instance(s) orcl1,orcl2
Service testsrv is running on instance(s) orcl1

Remove the Services from Oracle RAC

-- First stop the service if running
srvctl stop service -d orcl testsrv

-- remove the service after stop
srvctl remove service -d orcl -service testsrv

Create a new service for Oracle RAC

srvctl add service -d orcl -service srvhr -preferred orcl1 -available orcl2

-- Create and verify the service running
[oracle@host01 ~]$ srvctl add service -d orcl -service srvhr -preferred orcl1 -available orcl2

[oracle@host01 ~]$ srvctl status service -d orcl -service srvhr
Service srvhr is not running.

[oracle@host01 ~]$ srvctl start service -d orcl -service srvhr

[oracle@host01 ~]$ srvctl status service -d orcl -service srvhr
Service srvhr is running on instance(s) orcl1

Start and Stop the RAC Services for Oracle

-- Check status 
[oracle@host01 ~]$ srvctl status service -d orcl -service srvhr
Service srvhr is running on instance(s) orcl1

-- Stop the Service
[oracle@host01 ~]$ srvctl stop service -d orcl -service srvhr

[oracle@host01 ~]$ srvctl status service -d orcl -service srvhr
Service srvhr is not running.

-- Start the Service
[oracle@host01 ~]$ srvctl start service -d orcl -service srvhr

[oracle@host01 ~]$ srvctl status service -d orcl -service srvhr
Service srvhr is running on instance(s) orcl1

Show the Switch of Oracle Service from one instance to another automatic

Example: Configure the SRVHR service on ORCL1 as available and ORCL2 instance as preferred. We will show the SRVHR service shift from one instance to another on close of instance1.

Instance 1: Service SRVHR is running on host01

[oracle@host01 ~]$ srvctl status service -d orcl -service srvhr
Service srvhr is running on instance(s) orcl1
[oracle@host01 ~]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 11-JAN-2024 17:25:18
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 08-JAN-2024 13:52:16
Uptime 3 days 3 hr. 33 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/19.3.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/host01/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.101)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.201)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=host01.example.com)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_FRA" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_MGMT" 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 "srvhr" has 1 instance(s).
Instance "orcl1", status READY, has 1 handler(s) for this service...
The command completed successfully

Instance 2 : No Service is running on host02

[oracle@host02 ~]$
[oracle@host02 ~]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 11-JAN-2024 17:24:59
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 08-JAN-2024 13:59:18
Uptime 3 days 3 hr. 25 min. 41 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/19.3.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/host02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.102)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.202)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=host02.example.com)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/19.3.0/dbhome_1/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_FRA" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_MGMT" 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 "srvtest" has 1 instance(s).
Instance "orcl2", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@host02 ~]$

Instance 1: stop the orcl1 instance

[oracle@host01 ~]$
[oracle@host01 ~]$ ps -ef|grep smon
root 6570 1 1 Jan08 ? 01:23:57 /u01/app/19.3.0/grid/bin/osysmond.bin
grid 7149 1 0 Jan08 ? 00:00:04 asm_smon_+ASM1
oracle 10166 1 0 Jan10 ? 00:00:02 ora_smon_orcl1
oracle 21898 10489 0 17:30 pts/10 00:00:00 grep --color=auto smon
grid 26940 1 0 Jan08 ? 00:00:06 mdb_smon_-MGMTDB
[oracle@host01 ~]$
[oracle@host01 ~]$
[oracle@host01 ~]$ kill -9 10166

Instance 2: as shown below the service started on another instance

[oracle@host02 ~]$ srvctl status service -d orcl
Service srvhr is running on instance(s) orcl2
[oracle@host02 ~]$
[oracle@host02 ~]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 11-JAN-2024 17:30:40
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 08-JAN-2024 13:59:18
Uptime 3 days 3 hr. 31 min. 22 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/19.3.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/host02/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.102)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.0.2.202)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=host02.example.com)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/19.3.0/dbhome_1/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_FRA" has 1 instance(s).
Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_MGMT" 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 "srvhr" has 1 instance(s).
Instance "orcl2", status READY, has 1 handler(s) for this service...
The command completed successfully

Leave a Reply