Saturday, September 17, 2016

Clusterware failure scenarios a study note


Today I have gone through a very interesting video that demonstrate different clusterware failure scenarios with practical example. Here is the link https://www.youtube.com/watch?v=20qgRJEFC7w

Here is the abstract of this video 

1.  Node failure :-

CRS Resource will go to offline mode.

Instance recovery fill be performed by surviving node.

Node VIP and SCAN VIP will fail over to surviving node.

SCAN Listener will fail over to surviving node.

Client connection will move to surviving node If you used TAF at   client side.

Resource like node listner ,ASM , database etc will be in offline mode for failed node.
    
When you bring up the failed node all resource that were failed over to the surviving node will relocate back to the original node.

CRS Resources that were in offline mode might get started automatically based on the AUTO_START setting.

Possible values of AUTO_START are,
      
always— Causes the resource to restart when the node restarts regardless of the resource's state when the node stopped.

restore— Does not start the resource at restart time if it was in an offline state, such as STATE=OFFLINE, TARGET=OFFLINE, when the node stopped. The resource is restored to its state when the node went down. The resource is started only if it was online before and not otherwise.

never— Oracle Clusterware never restarts the resource regardless of the resource's state when the node stopped.
      
2. Instance failure:-

Instance recovery will be performed by surviving instance.
Surviving instance reads the online redo log files of the failed instance and ensure that committed transaction are recorded to the database.

If all nodes fail, one instance will performe the recovery of all instances.

Services will be moved to available instance.

Clients connection will be moved to surviving instance if TAF is in place.

Failed instance may be restarted by the clusterware automatically.
    
You could see something like following in alertlog file from the survining node.

     
3. ASM instance failure:-

ASM instance will be OFFLINE and will be automatically restarted by the clusterware.

Instance recovery will be performed.

Client connection will be moved to surviving instance if TAF is in place.

Services will be moved to available instance.
    
4. Local and SCAN Listener failure:-

Listener failure will be detected by CRSD and restarted.
    
5. Public network failure:-

Node VIP and SCAN VIP will fail over to surviving node.
DB instance will be up and DB service will fail to surviving node.
    
6. Private network failure.

Up-to 11g R2 CSSD will detects a split-brain situation and will survive the node with the lowest node number. For example In case of two node cluster,Second node will be evicted.

However, starting from Oracle Database 12.1.0.2c, the node with higher weight will survive during split brain resolution. If you want to know about this, visit http://allthingsoracle.com/split-brain-whats-new-in-oracle-database-12-1-0-2c/

Clusterware will try to perform a reboot-less node fencing by cleaning-up CRSD resources ,if not possible a node reboot will happen.
    
OHAS will be up and running on the affected node , but CRSD,CSSD,EVMD,HAIP etc will be in OFFLINE mode.

As soon as private network is started, CSSD, CRSD and EVMD services start immediately on second node and joins the cluster.
    
Consider you have a two node 11gr2 cluster and you removed private interconnect cable from the first node. Whic node will get evicted i?
obviously the second node as oracle will survive the node with loweset node number in 11gr2.
    
Ie, in 11g it doesnt matter private network of first or second node fails it always evict the second node.

7. OCR and Voting disk failure:-

OCR

As best practice make sure you set two different disk groups to store OCR- one for main storage and second for OCR mirror.
  
Lets suppose you have two disk group (DATA & OCR) for storing OCR and both have two failgroup.
  
 
If you lose entire OCR disk grop and one failgroup within the DATA disk group, Clusterware will works as normal,but what happen if you lose the surviving failgroup in the main disk group too?

  You have two option
  - Restore OCR  from backup.
  - Restore OCR without backup.
 
How to create a OCR mirror ?

     1. create the disk group with sufficinet failgroup ,Set diskgroup compatible etc from first node..
     2. mount the disk from the second node.
     3. make a mirror copy of OCR in newly created disk group by - ocrconfig -add '+NEWOCR' (as root)
     4. verify the OCR mirror copy by - ocrcheck
     
 
Voting Disk

EXTERNAL REDUNDANCY - CSSD choose one ASM DISK and  create one (1) voting disk.

NORMAL REDUNCANCY - CSSD choose 3 ASM DISK from different FAILGROUP and create 3 VOTING DISK, one in each ASM DISK/FAILGROUP

HIGH REDUNDANCY - CSSD choose 5 ASM DISK from different FAILGROUP and create 5 VOTING DISK, one in each ASM DISK/FAILGROUP.
 
In order to be able to tolerate a failure of n voting disk files , one must have at least 2n+1 configured. 
 
 Move/put voting disk in a new disk group

 1. create the disk group with sufficinet failgroup ,Set diskgroup compatible etc from first node..
2. mount the disk from the second node.
3. Put the voting diks in newly created diskgroup - crsctl replace votedisk +NEWDG
4. Verify the new locaton of voting disk by - crsctl query css votedisk
      
You drop an ASM Disk that contains a Voting Disk, what will happen ? Oracle will silently move the Voting Disk to another ASM Disk of that Diskgroup (if exists),otherwise the command will ignored.
      
Reference:- https://www.youtube.com/watch?v=20qgRJEFC7w
    

Thursday, September 15, 2016

ORA-01207: file is more recent than control file - old control file - How you will approach this error ?


You are facing following error while starting up your database. ORA-01207: file is more recent than control file - old control file.
What you can do in this case ?
If you google this error, you may come across many article recommending recovery from backup controlfile and opening database with resetlogs.

Do we really want to open our database in resetlogs mode by using a backup controlfile- Is there any alternative to recover without resetlogs ? Yes there is one method to do that provided that you have a trace copy of your controlfile. 


In order to maintain data consistency, the SCN must be the same across all datafiles, the controlfile & current REDO file.
By definition when you use "backup controlfile" it has an out of date SCN in it.RESETLOG forces the SCN back to 1 in order to obtain consistency across all the files in the database.CREATE CONTROLFILE populates this new file with the most recent SCN that exists in the datafiles. So it’s a good idea to opt second option if you have a trace file copy of your controlfile.

Lets demonstrate this with an example-

[oracle@mydb01]:[TTREC1] $ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 15 19:51:36 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics and Real Application Testing options

Create a trace file copy of your controlfile.

SQL> alter database backup controlfile to trace as '/tmp/ttrecctl.sql';

Database altered.

Lets do some activit,to make sure none of the database operation are affected by this activity. 

SQL> create table test1 as select * from dba_tables;

Table created.

SQL> @switch
SQL> alter system switch logfile;

System altered.

SQL>
SQL> select name from v$controlfile;

NAME
--------------------
/data1/control1.ctl
/data2/control2.ctl

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics  and Real Application Testing options

Lets remove your controlfile-

[oracle@mydb01]:[TTREC1] $ rm -f /data1/control1.ctl /data2/control2.ctl
[oracle@mydb01]:[TTREC1] $ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 15 19:53:16 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics and Real Application Testing options

SQL> create table test2 as select * from dba_tables;

Table created.

SQL>
Database is still working as normal even when we don’t have a controlfile.

SQL> @switch
SQL> alter system switch logfile;

System altered.

SQL>
SQL> /

System altered.
SQL>

I will crash my database-

SQL> shut abort ;
ORACLE instance shut down.
SQL>
SQL> startup;
ORACLE instance started.
Total System Global Area 2147483648 bytes
Fixed Size                  3712904 bytes
Variable Size            1996490872 bytes
Database Buffers          134217728 bytes
Redo Buffers               13062144 bytes
ORA-00205: error in identifying control file, check alert log for more info
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics and Real Application Testing options

Edit the controlfile trace that we made prior to this exercise.After edit the file should look like-

[oracle@mydb01]:[TTREC1] $ cat /tmp/ttrecctl.sql
CREATE CONTROLFILE REUSE DATABASE "TTREC" NORESETLOGS FORCE LOGGING ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 (
    '/data1/TTREC/onlinelog/o1_mf_1_cwzoob3m_.log',
    '/data2/TTREC/onlinelog/o1_mf_1_cwzoobdr_.log'
  ) SIZE 100M BLOCKSIZE 512,
  GROUP 2 (
    '/data1/TTREC/onlinelog/o1_mf_2_cwzoobs8_.log',
    '/data2/TTREC/onlinelog/o1_mf_2_cwzooc2y_.log'
  ) SIZE 100M BLOCKSIZE 512,
  GROUP 3 (
    '/data1/TTREC/onlinelog/o1_mf_3_cwzoock3_.log',
    '/data2/TTREC/onlinelog/o1_mf_3_cwzoocvl_.log'
  ) SIZE 100M BLOCKSIZE 512
DATAFILE
  '/data1/TTREC/datafile/o1_mf_system_cvf5lom7_.dbf',
  '/data1/TTREC/datafile/o1_mf_sysaux_cvf5jnh9_.dbf',
  '/data1/TTREC/datafile/o1_mf_undotbs1_cvf5npon_.dbf',
  '/data1/TTREC/datafile/o1_mf_users_cvf5oss4_.dbf',
  '/data1/TTREC/datafile/o1_mf_orinon_t_cvf5lomr_.dbf',
  '/data1/TTREC/datafile/o1_mf_oraion_t_cvf5jnjb_.dbf',
  '/data1/TTREC/datafile/o1_mf_tbs_test_cvf5ostw_.dbf',
  '/data1/TTREC/datafile/o1_mf_orion_da_cvf5npp4_.dbf',
  '/data1/TTREC/datafile/o1_mf_testa_cxf1h6kw_.dbf',
  '/data1/TTREC/datafile/o1_mf_testb_cxnhzbbf_.dbf'
CHARACTER SET AL32UTF8
;

[oracle@mydb01]:[TTREC1] $ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Sep 15 19:56:58 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics and Real Application Testing options

SQL> @/tmp/ttrecctl.sql

Control file created.

SQL> select name ,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
TTREC     MOUNTED

SQL> recover database ;
Media recovery complete.
SQL> alter database open;

Database altered.

SQL> select count(1) from test1;

  COUNT(1)
----------
      2508

SQL> select count(1) from test2;

  COUNT(1)
----------
      2509

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Advanced Analytics and Real Application Testing options.

Simply we opened our database without using open resetlogs.