Sunday, September 23, 2018

How to Add and Remove database to CRS or Oracle Restart

In RAC or Oracle Restart environment we can use “srvctl” command to add resources to CRS for automatic management of the resources. In this article I would explain how we remove and add a database resource to CRS in RAC environment. Same process can be used for single instance database in Oracle Restart environment. These steps are needed to be executed as RDBMS software owner “oracle”. Starting 12c, single letter options (-d, -i, etc.) can still be used, but probably these would be made obsolete in coming releases because full length option (-db, -instance etc.) have been introduced and I will use these full length options here.

Removing a database from CRS or Oracle Restart

Currently there is a database “salman12” registered with the CRS and it has 2 instances running on 2 nodes. “-db” option refers to unique database name. Use “-d” for older releases.
[oracle@salman11 ~]$ srvctl status database -db salman12
Instance salman121 is running on node salman11
Instance salman122 is running on node salman12

To removing this database from CRS, either shutdown the database (all instances) or otherwise use “-force” (or “-f” for bellow 12c) option. Not using force option would return error PRKO-3141
[oracle@salman11 ~]$ srvctl remove database -db salman12
PRKO-3141 : Database salman12 could not be removed because it was running

[oracle@salman11 ~]$ srvctl remove database -db salman12 –f

[oracle@salman11 ~]$ srvctl status database -d salman12
PRCD-1120 : The resource for database salman12 could not be found.
PRCR-1001 : Resource ora.salman12.db does not exist

Adding a database to CRS or Oracle Restart

-- If this is oracle restart environment (single server installation), also use “–instance” (for 12c and above) or “-i” (for bellow 12c) and provide instance name to be registered. Adding instance separately is not required.

-- For bellow 12c, use options –d, -o, -c, -p, -s, -n, -a respectively in srvctl command. Last option –pwfile can not be used prior to 12c.

[oracle@salman11 ~]$ srvctl add database -db salman12 -oraclehome /u01/app/oracle/product/12.2.0/dbhome_1 -dbtype RAC -spfile '+DATA/SALMAN12/PARAMETERFILE/spfile.312.942412029'  -startoption OPEN -dbname salman12 -diskgroup 'DATA' -pwfile '+DATA/SALMAN12/PASSWORD/pwdsalman12.296.942411055'

-- Now add all instances one by one
-- For bellow 12c, use options –d, -i and –n respectively in srvctl command
[oracle@salman11 ~]$ srvctl add instance -db salman12 -instance salman121 -node salman11
[oracle@salman11 ~]$ srvctl add instance -db salman12 -instance salman122 -node salman12


If database is already open, and you check the status of the database, you will see it “down”. You can execute a dummy “srvctl start” command to start the database so that its status is updated in CRS
[oracle@salman11 ~]$ srvctl status database -d salman12
Instance salman121 is not running on node salman11
Instance salman122 is not running on node salman12

-- Execute a dummy start command to update database status
 [oracle@salman11 ~]$ srvctl start database -db salman12
[oracle@salman11 ~]$ srvctl status database -d salman12
Instance salman121 is running on node salman11
Instance salman122 is running on node salman12

Current configuration can be checked as follows
[oracle@salman11 ~]$ srvctl config database -db salman12
Database unique name: salman12
Database name: salman12
Oracle home: /u01/app/oracle/product/12.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/SALMAN12/PARAMETERFILE/spfile.312.942412029
Password file: +DATA/SALMAN12/PASSWORD/pwdsalman12.296.942411055
Domain: salman.com
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: salman121,salman122
Configured nodes: salman11,salman12
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

No comments:

Post a Comment

Popular Posts - All Times