Thursday, February 26, 2015

Steps to create Control File during System Refresh

Steps to create Control File during System Refresh:


Creating control file is not difficult task but sometime small mistake can leads to major issues while recovering Database during System Refresh.
Below are the steps and measures should be taken while creating control file on Target system:

1. In system Refresh, once the Online/Offline backup of Source System completed, immediately.create a trace file from the control file on the Source system and move that Trace file to the Target System.
In one of the refresh we faced issues while recovering Database, it was asking for log which does not exist in the back<SID>.log this is due to someone added 6 Datafiles after backup completion and trace file created after 2 days.


On source system as ora<sid>:
sqlplus “/ as sysdba”
SQL> alter database backup controlfile to trace;
SQL> exit;

File <sid>_ora_nnnnn.trc is created in /oracle/<SID>/saptrace/diag/rdbms/<sid>/<SID>/trace. 
Copy this file to CONTROL.SQL.

ora<sid> 1> cp -p <sid>_ora_nnnnn.trc CONTROL.SQL

2.One more precaution, mostly people use Vi editor to edit and prepare control file.
I will suggest rather emphasis on Notepad. copy all the contents of the trace file and paste it on the local notepad file.

Most of the time in VI editor, small space or accidentally some punctuation mark goes wrong and control file we prepared is not right.even some are not used to VI editor commands, so Notepad is the safe and easy option.

orasid>cat <sid>_ora_nnnnn.trc
select all and copy paste it in the Notepad.

3. On Target System, save number of Online Redolog files:
    SQL> select group#, sequence#, archived, status, bytes from v$log;

    GROUP#  SEQUENCE# ARC STATUS                BYTES
---------- ---------- --- ---------------- ----------
        11       1041 YES INACTIVE         1073741824
        12       1042 YES INACTIVE         1073741824
        13       1043 YES INACTIVE         1073741824
        14       1044 YES INACTIVE         1073741824
        15       1045 YES INACTIVE         1073741824
        16       1046 YES INACTIVE         1073741824
        17       1047 NO  CURRENT          1073741824
        18       1040 YES INACTIVE         1073741824

8 rows selected.


We have taken screen-shots (before Refresh) of this Target Redolog group sequence and size because after refresh also we want to set it as it is not like source system Redolog Group Sequence and size which we will maintain in control file.

Calculate Size of one Redolog Group in MB:
1073741824/1024/1024=1024M

4. Open Controlfile Notepad to edit.
   There will be 2 sets starting from Startup to UTF8.
   Remove all lines after first occurrence of CHARACTER SET UTF8 ;

5. At the end of the tracefile you will find some comments about the TEMP files (used for PSAPTEMP). Save these entries in a TEMP.SQL in same location as CONTROL.SQL. Entries can later be used for setting up (after changing contents of TEMP.SQL) to setup TEMP files.

Example:

ALTER TABLESPACE PSAPTEMP ADD TEMPFILE '/oracle/SID/sapdata11/temp_1/temp.data1'
SIZE 6192M REUSE AUTOEXTEND OFF;

6. Remove lines from top to STARTUP NOMOUNT

7.  Change
     CREATE CONTROLFILE REUSE DATABASE "<sourceSID>" NORESETLOGS ARCHIVELOG

into

CREATE CONTROLFILE SET DATABASE "<targetSID>" RESETLOGS NOARCHIVELOG

8. Change all <sourceSID> into <targetSID> using Notepad command cntrl+h (Replace)
Replace SOURCE SID with TARGET SID  (in CAPS letters)
select Match case option.

9. Check the value for MAXLOGFILES (best to set to 255

10. Change the number and size of the online redologs to the original value (see step 4.19).

Example: source system GROUP 11-20, target system GROUP 11-18
               source system = SIZE 2048M, target system = SIZE 1024M

When deleting obsolete groups be aware to have no , (comma) after last GROUP

Change size of online redo log file using Replace option (cntrl+h)2048M with 1024M.

11. Cross check edited controlfile notepad once again whether all changes has been done or not.

12.select all content of controlfile notepad and copy.
 go to target system path: /oracle/SID/saptrace/diag/rdbms/sid/SID/trace/
 create CONTROL.SQL file using vi command.
orasid> vi CONTROL.SQL
press escape key then press key i
press keys Shift+insert (it will paste all the copied content of the controlfile saved in notepad to the CONTROL.SQL)
once done press escape then :wq! to save the file.


Edited Control file will look like below:
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "ED2" RESETLOGS FORCE LOGGING NOARCHIVELOG
    MAXLOGFILES 255
    MAXLOGMEMBERS 3
    MAXDATAFILES 508
    MAXINSTANCES 50
    MAXLOGHISTORY 19948
LOGFILE
  GROUP 11 (
    '/oracle/ED2/origlogC/log_g11m1.dbf',
    '/oracle/ED2/mirrlogC/log_g11m2.dbf'
  ) SIZE 1024M BLOCKSIZE 512,
  GROUP 12 (
    '/oracle/ED2/origlogD/log_g12m1.dbf',
    '/oracle/ED2/mirrlogD/log_g12m2.dbf'
  ) SIZE 1024M BLOCKSIZE 512,
  GROUP 13 (
    '/oracle/ED2/origlogC/log_g13m1.dbf',
    '/oracle/ED2/mirrlogC/log_g13m2.dbf'
  ) SIZE 1024M BLOCKSIZE 512,
  GROUP 14 (
    '/oracle/ED2/origlogD/log_g14m1.dbf',
    '/oracle/ED2/mirrlogD/log_g14m2.dbf'
  ) SIZE 1024M BLOCKSIZE 512,
  GROUP 15 (
    '/oracle/ED2/origlogC/log_g15m1.dbf',
    '/oracle/ED2/mirrlogC/log_g15m2.dbf'
  ) SIZE 1024M BLOCKSIZE 512,
  GROUP 16 (
    '/oracle/ED2/origlogD/log_g16m1.dbf',
    '/oracle/ED2/mirrlogD/log_g16m2.dbf'
  ) SIZE 1024M BLOCKSIZE 512,
  GROUP 17 (
    '/oracle/ED2/origlogC/log_g17m1.dbf',
    '/oracle/ED2/mirrlogC/log_g17m2.dbf'
  ) SIZE 1024M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/oracle/ED2/sapdata1/system_1/system.data1',
  '/oracle/ED2/sapdata1/sysaux_1/sysaux.data1',
  '/oracle/ED2/sapdata1/undo_1/undo.data1',
  '/oracle/ED2/sapdata2/sr3_1/sr3.data1',
  '/oracle/ED2/sapdata54/undo_18/undo.data18',
  '/oracle/ED2/sapdata1/sr3usr_1/sr3usr.data1',
  '/oracle/ED2/sapdata4/sr3_2/sr3.data2',
  '/oracle/ED2/sapdata5/sr3_3/sr3.data3',
  '/oracle/ED2/sapdata6/sr3_4/sr3.data4',
  '/oracle/ED2/sapdata7/sr3_5/sr3.data5',
  '/oracle/ED2/sapdata8/sr3_6/sr3.data6',
  '/oracle/ED2/sapdata9/sr3_7/sr3.data7',
  '/oracle/ED2/sapdata10/sr3_8/sr3.data8',
  '/oracle/ED2/sapdata11/sr3_9/sr3.data9',
  '/oracle/ED2/sapdata12/sr3_10/sr3.data10',
  '/oracle/ED2/sapdata13/sr3_11/sr3.data11',
  '/oracle/ED2/sapdata14/sr3_12/sr3.data12',
  '/oracle/ED2/sapdata15/sr3_13/sr3.data13',
  '/oracle/ED2/sapdata16/sr3_14/sr3.data14',
  '/oracle/ED2/sapdata17/sr3_15/sr3.data15',
  '/oracle/ED2/sapdata18/sr3_16/sr3.data16',
  '/oracle/ED2/sapdata19/sr3_17/sr3.data17',
  '/oracle/ED2/sapdata20/sr3_18/sr3.data18',
  '/oracle/ED2/sapdata21/sr3_19/sr3.data19',
  '/oracle/ED2/sapdata22/sr3_20/sr3.data20',
  '/oracle/ED2/sapdata2/undo_2/undo.data2',
  '/oracle/ED2/sapdata3/undo_3/undo.data3',
  '/oracle/ED2/sapdata5/undo_5/undo.data5',
  '/oracle/ED2/sapdata4/undo_4/undo.data4',
  '/oracle/ED2/sapdata6/undo_6/undo.data6',
  '/oracle/ED2/sapdata26/undo_7/undo.data7',
  '/oracle/ED2/sapdata27/undo_8/undo.data8',
  '/oracle/ED2/sapdata28/undo_9/undo.data9',
  '/oracle/ED2/sapdata29/undo_10/undo.data10',
  '/oracle/ED2/sapdata10/sr3usr_4/sr3usr.data4'
CHARACTER SET UTF8

;

13. Create control file at the Target system:
sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production on Wed Dec 12 19:30:38 2012


Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> @/oracle/ED2/saptrace/diag/rdbms/ed2/ED2/trace/CONTROL.SQL
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE instance started.

Total System Global Area 3206836224 bytes
Fixed Size                  2223904 bytes
Variable Size            1174405344 bytes
Database Buffers         2013265920 bytes
Redo Buffers               16941056 bytes

Control file created.

Thursday, February 20, 2014

Oracle Parameter Changes



Oracle Parameter changes:

Scenario:

Oracle Parameters            Current        Proposed
db_cache_size                   10048M        17920M
sga_target                                 21G               29G
sga_max_size                            22G               30G
 
you want to change above oracle parameters to its proposed value.

There are 2 ways of changing Oracle Parameters:
  1. By editing an initialization parameter file (init<SID>.ora)
  2. By issuing an ALTER SYSTEM SET ... SCOPE=SPFILE statement to update a server parameter file (spfile).
  
First Take a backup of an existing pfile & spfile.

1. Editing Pfile:

   Steps:
  • Create Pfile from SPFILE. 
          SQL> create pfile from spfile;
          It  creates a  file init<SID>.ora inside /$ORACLE_HOME/dbs  directory.
  • Login as ora<SID > user & edit Pfile in vi editor.
          vi init<SID>.ora
          Change parameters as per your requirement.
          Save & close it. (:wq!)
  • Login in to SQL plus & shutdown the database.
  • Start database using Pfile.
         SQL> startup pfile='$ORACLE_HOME/dbs/init<SID>.ora';
  • Now  create SPfile from Pfile.
          SQL> create spfile from pfile;
  • Shutdown database.
          SQL> shutdown immediate;
  • Start database with SPFILE.
          SQL> startup;


2. Using ALTER  SYSTEM SET commands:
Steps:
  • First check Parameter and its actual value:
           SQL> show parameter <parameter name>;
           
  • Change parameter value using ALTER SYSTEM set command (SPfile):
          SQL> ALTER SYSTEM SET <Parameter name> = <value> scope = <spfile/Memory/Both> sid = ‘*’; 
  • Shutdown database.
          SQL> shutdown immediate;
  • Start database with SPFILE.
          SQL> startup;


Whereas,
Scope:
MEMORY: 
The change is immediate but will not be available after next startup or reboot  of the instance.

SPFILE: 
The change will be effective in SPFILE only and will be available after next startup or reboot

BOTH: 
The change is effective for both MEMORY and SPFILE and will be available after next startup also.
 
Default is BOTH

Sid:
Applicable for RAC database.
This is to specify the instance where you want to make that change.
Sid=’*’ means change in the parameter will takes place for all instances after restart.
Default is ‘*’


SAPPFPAR:
  • Run sappfpar to see how the pools should be set (ipc/shm_psize_40 and ipc/shm_psize_10)
  • Login as <SID>adm
          sappfpar check pf=< profile path>:
          
Output will be a report containing error with solution.
 e.g:

<SID>adm > sappfpar check pf=/sapmnt/<SID>/profile
================================================================================
==   Checking profile:     /sapmnt/<SID>/profile
================================================================================
***ERROR: Size of shared memory pool 40 too small
================================================================
SOLUTIONS: (1) Locate shared memory segments outside of pool 40
               with parameters like: ipc/shm_psize_<key> =0

SOLUTION: Increase size of shared memory pool 40
          with parameter: ipc/shm_psize_40 =486000000

Shared memory disposition overview
================================================================ 

  • As per adviced solution adjust the parameter value.
  • Restart the system