Look in:

Web oracle-core-dba.blogspot.com

Wednesday, December 24, 2008

Automtic and Manually sized Components of SGA

DB_CACHE_SIZE,
SHARED_POOL_SIZE,
LARGE_POOL_SIZE and
JAVA_POOL_SIZE are automatic sized components.

The parameter SGA_TARGET specifies the total size of all SGA components.
If SGA_TARGET is set to a value greater than zero then above components are automatically sized.

On the other hand,

LOG_BUFFER,
BUFFER_POOL_KEEP,
BUFFER_POOL_RECYCLE,
DB_nK_CACHE_SIZE other than DB_CACHE_SIZE,
STREAMS_POOL_SIZE ,
Fixed SGA and
other internal components are manually sized components.

However setting the value to manually sized components automatically reduce the value from SGA_TARGET if SGA_TARGET is set to value greater than zero.

When SGA_TARGET>0 then automatic sized components of SGA are automatically allocated and this is called Automatic Shared Memory Management.

Both the automatic and manually sized components of SGA are dynamic components because they dynamically can be changed.

You can see them from V$SGA_DYNAMIC_COMPONENTS.

Simple Restore and Recovery process using RMAN on a Windows box.

C:\>set oracle_sid=SDR

C:\>sqlplus /nolog

SQL*Plus: Release 9.2.0.4.0 - Production on Wed Dec 17 05:16:07 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> conn sys/sys as sysdba
Connected to an idle instance
SQL> startup pfile=c:\oracle\database\initSDR.ora nomount
ORACLE instance started.

Total System Global Area 202448548 bytes
Fixed Size 454308 bytes
Variable Size 159383552 bytes
Database Buffers 41943040 bytes
Redo Buffers 667648 bytes
SQL>


C:\oracle\bin>rman

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

RMAN> connect target sys/sys

connected to target database: SDR (not mounted)

RMAN>


RUN
{
SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\Backup\RMAN\SDR\%F';
RESTORE CONTROLFILE FROM 'D:\Backup\RMAN\SDR\C-3180286864-20081215-00';
ALTER DATABASE MOUNT;
}


RMAN> RUN
2> {
3> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\Backup\RMAN\SDR\%F';
4> RESTORE CONTROLFILE FROM 'D:\Backup\RMAN\SDR\C-3180286864-20081215-00';
5> ALTER DATABASE MOUNT;
6> }

executing command: SET CONTROLFILE AUTOBACKUP FORMAT
using target database controlfile instead of recovery catalog

Starting restore at 17-DEC-08

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=13 devtype=DISK
channel ORA_DISK_1: restoring controlfile
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=D:\ORACLE\ORADATA\SDR\CONTROL01.CTL
output filename=D:\ORACLE\ORADATA\SDR\CONTROL02.CTL
output filename=C:\ORACLE\ORADATA\SDR\CONTROL03.CTL
Finished restore at 17-DEC-08

database mounted


RMAN> restore archivelog from time '14-DEC-08';

Starting restore at 17-DEC-08

using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=209
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\RMAN\SDR\92K28SQ3_1_1 tag=ORACLESRVR - SDR_12140803
0002 params=NULL
channel ORA_DISK_1: restore complete
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=210
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\RMAN\SDR\95K2BH5F_1_1 tag=ORACLESRVR - SDR_12150803
0005 params=NULL
channel ORA_DISK_1: restore complete
Finished restore at 17-DEC-08

RMAN> restore database;

Starting restore at 17-DEC-08

using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to D:\ORACLE\ORADATA\SDR\SYSTEM01.DBF
restoring datafile 00002 to D:\ORACLE\ORADATA\SDR\UNDOTBS01.DBF
restoring datafile 00003 to D:\ORACLE\ORADATA\SDR\CWMLITE01.DBF
restoring datafile 00004 to D:\ORACLE\ORADATA\SDR\DRSYS01.DBF
restoring datafile 00005 to D:\ORACLE\ORADATA\SDR\EXAMPLE01.DBF
restoring datafile 00006 to D:\ORACLE\ORADATA\SDR\INDX01.DBF
restoring datafile 00007 to D:\ORACLE\ORADATA\SDR\ODM01.DBF
restoring datafile 00008 to D:\ORACLE\ORADATA\SDR\TOOLS01.DBF
restoring datafile 00009 to D:\ORACLE\ORADATA\SDR\USERS01.DBF
restoring datafile 00010 to D:\ORACLE\ORADATA\SDR\XDB01.DBF
restoring datafile 00011 to D:\ORACLE\ORADATA\SDR\SDRD.ORA
restoring datafile 00012 to D:\ORACLE\ORADATA\SDR\SDRI.ORA
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\RMAN\SDR\94K2BGV8_1_1 tag=ORACLESRVR - SDR_12150803
0005 params=NULL
channel ORA_DISK_1: restore complete
Finished restore at 17-DEC-08

RMAN> recover database until logseq 0 thread 1;

Starting recover at 17-DEC-08
using channel ORA_DISK_1

starting media recovery
media recovery complete

Finished recover at 17-DEC-08


RMAN> open resetlogs database;

database opened

RMAN>exit

Restore and Recover a database using a HOT Backup and lost archivelog files.

You can say it as a Dummy Recovery.

$ pwd
/uo1/oracle/app/product/9.2.0.1.0/oradata

$ mkdir edr_arch edr_data edr_temp
$ pwd
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp
$ ls
$ mkdir adump bdump cdump create email tmpfiles udump
$
$ pwd
/uo1/oracle/app/product/9.2.0.1.0/admin/edr

ln -s /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/adump
ln -s /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/bdump
ln -s /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/cdump
ln -s /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/create
ln -s /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/email
ln -s /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/tmpfiles
ln -s /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/udump

$ pwd
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data
Restore or copy all your backup files accordingly.
--------------------------------------------------------------------------------------------------------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--------------------------------------------------------------------------------------------------------
My Controlfile Script:

CREATE CONTROLFILE SET DATABASE "edr" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 2268
LOGFILE
GROUP 1 '/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/logedr1.ora' SIZE 200M,
GROUP 2 '/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/logedr2.ora' SIZE 200M,
GROUP 3 '/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/logedr3.ora' SIZE 200M,
GROUP 4 '/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/logedr4.ora' SIZE 200M,
GROUP 5 '/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/logedr5.ora' SIZE 200M
DATAFILE
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edr_system.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edr_users.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edr_tools.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/RBS.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrDATA_D.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrDATA_I.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrMETA_D.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrMETA_.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrUSERS.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/CUSTOM_INDEX.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/DBA.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/GCMDB.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/PREFSTAT.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrcode.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrcode_I.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/RCX_OTHER.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/EXPORT_D.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrDATA_D2.dbf.dbf',
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edrDATA_D3.dbf'
CHARACTER SET WE8MSWIN1252
;

--------------------------------------------------------------------------------------------------------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--------------------------------------------------------------------------------------------------------
My Pfile:

# Instance self registration parameters
instance_name = edr
service_names = edrserver
db_name = "edr"
db_domain = oracle.com
#db_files = 1000
db_block_size = 8192
db_file_multiblock_read_count = 8

compatible = "9.2.0.1.0"

# db_cache_size replaces the earlier db_block_buffers

db_cache_size = 8m
#db_cache_size = 10485760000


# Optional additional block sizes available in Oracle 9i
# You cannot set db_Nk_cache_size for N = DB_BLOCK_SIZE
# db_2k_cache_size = m
# db_4k_cache_size = m
# db_16k_cache_size = m
# db_32k_cache_size = m

shared_pool_size = 20M
#shared_pool_size = 419430400
#log_buffer = 163840
log_buffer = 20070400

# Optional settings for dynamic SGA and PGA's
# sga_max_size =
sga_max_size = 2728640000

pga_aggregate_target = 380M
#pga_aggregate_target = 419430400

# Eliminates the need for the _area_size parameters.

# To eliminate the need for Rollback segments we set the following Automatic UNDO
# parameters, and we don't set ROLLBACK_SEGMENTS
#UNDO_RETENTION = 90 # Measured in Seconds controls undo segment size.
#UNDO_MANAGEMENT = AUTO
#UNDO_TABLESPACE = UNDOTBS
#UNDO_SUPPRESS_ERRORS = TRUE # Kills error messages for rollback segment operations

control_files = ("/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/control01.ctl",
"/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/control02.ctl")
log_archive_start = false
log_archive_dest_1 = "location=/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_arch/"
log_archive_format = edr_arch%S.arc
background_dump_dest = /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/bdump
core_dump_dest = /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/cdump
user_dump_dest = /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/udump
audit_file_dest = /uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/adump

#remote_os_authent = true
#os_authent_prefix = "OPS$"

open_cursors = 3000
max_enabled_roles = 148

#optimizer_mode = choose
#nls_language = american
#nls_date_format = DD-MON-RRRR
#nls_date_language = american

timed_statistics=TRUE
#hash_join_enabled=TRUE
#optimizer_features_enable = 9.2.0.1.0
#query_rewrite_enabled=FALSE
#star_transformation_enabled=FALSE
#java_pool_size=20M
#large_pool_size=200M
#large_pool_size= 209715200
#processes=500
#fast_start_mttr_target=300
#audit_trail=TRUE
#max_rollback_segments=50
#sort_area_size=67108864
#workarea_size_policy = AUTo
#remote_login_passwordfile=exclusive
#log_archive_start=TRUE

--------------------------------------------------------------------------------------------------------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--------------------------------------------------------------------------------------------------------

ORACLE_SID set to: edr.
ORACLE_HOME set to: /uo1/oracle/app/product/9.2.0.1.0.

startup nomount pfile=/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/pfile/initedr.ora

--------------------------------------------------------------------------------------------------------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--------------------------------------------------------------------------------------------------------

ORACLE_SID set to: edr.
ORACLE_HOME set to: /uo1/oracle/app/product/9.2.0.1.0.

$ sqlplus "/as sysdba"

SQL*Plus: Release 9.2.0.1.0 - Production on Tue Dec 23 08:20:07 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

Connected to an idle instance.

SQL> startup nomount pfile=/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/pfile/initedr.ora
ORACLE instance started.

Total System Global Area 2738868712 bytes
Fixed Size 733672 bytes
Variable Size 2701131776 bytes
Database Buffers 16777216 bytes
Redo Buffers 20226048 bytes
SQL> @cr8ctl.sql

Control file created.

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1:
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edr_system.dbf'


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 8469459547375 generated at 12/03/2008 22:00:03 needed for
thread 1
ORA-00289: suggestion :
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_arch/edr_arch0000006653.arc
ORA-00280: change 8469459547375 for thread 1 is in sequence #6653

Here Here.. I lost my archivelog files..remember...so trying my luck with the online redolog files:

Specify log: {=suggested | filename | AUTO | CANCEL}
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/log1aedr.rdo
ORA-00310: archived log contains sequence 2370; sequence 6653 required
ORA-00334: archived log:
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/log1aedr.rdo'


ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1:
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edr_system.dbf'


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 8469459547375 generated at 12/03/2008 22:00:03 needed for
thread 1
ORA-00289: suggestion :
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_arch/edr_arch0000006653.arc
ORA-00280: change 8469459547375 for thread 1 is in sequence #6653


Specify log: {=suggested | filename | AUTO | CANCEL}
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/log2aedr.rdo
ORA-00310: archived log contains sequence 2371; sequence 6653 required
ORA-00334: archived log:
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/log2aedr.rdo'


ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1:
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edr_system.dbf'


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 8469459547375 generated at 12/03/2008 22:00:03 needed for
thread 1
ORA-00289: suggestion :
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_arch/edr_arch0000006653.arc
ORA-00280: change 8469459547375 for thread 1 is in sequence #6653


Specify log: {=suggested | filename | AUTO | CANCEL}
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/log3aedr.rdo
ORA-00310: archived log contains sequence 2369; sequence 6653 required
ORA-00334: archived log:
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/log3aedr.rdo'


ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01195: online backup of file 1 needs more recovery to be consistent
ORA-01110: data file 1:
'/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/edr_system.dbf'


SQL> recover database until cancel using backup controlfile;
ORA-00279: change 8469459547375 generated at 12/03/2008 22:00:03 needed for
thread 1
ORA-00289: suggestion :
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_arch/edr_arch0000006653.arc
ORA-00280: change 8469459547375 for thread 1 is in sequence #6653


Specify log: {=suggested | filename | AUTO | CANCEL}
/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_data/logedr1.ora
Log applied.
Media recovery complete.


Hurrah..done. This redolog has the change it required.

**The redologs are also backedup along with the other files.
SQL> alter database open resetlogs;

Database altered.

And the database is up.

SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION STARTUP_T STATUS PAR THREAD# ARCHIVE LOG_SWITCH_
----------------- --------- ------------ --- ---------- ------- -----------
LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST
---------- --- ----------------- ------------------ ---------
1 edr
edrserver
9.2.0.1.0 23-DEC-08 OPEN NO 1 STOPPED
ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL


SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
JServer Release 9.2.0.1.0 - Production
--------------------------------------------------------------------------------------------------------
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
--------------------------------------------------------------------------------------------------------
Then some more things to make my restore activity complete:

SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
sQL> alter database open;

create spfile from pfile;

SQL> shutdown immediate;
SQL> startup
ORACLE instance started.

Total System Global Area 2738868712 bytes
Fixed Size 733672 bytes
Variable Size 2701131776 bytes
Database Buffers 16777216 bytes
Redo Buffers 20226048 bytes
Database mounted.
Database opened.

SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION STARTUP_T STATUS PAR THREAD# ARCHIVE LOG_SWITCH_
----------------- --------- ------------ --- ---------- ------- -----------
LOGINS SHU DATABASE_STATUS INSTANCE_ROLE ACTIVE_ST
---------- --- ----------------- ------------------ ---------
1 edr
edrserver
9.2.0.1.0 23-DEC-08 OPEN NO 1 STARTED
ALLOWED NO ACTIVE PRIMARY_INSTANCE NORMAL


My controlfile script does not contain the temp file..so I have to add it:

SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/uo1/oracle/app/product/9.2.0.1.0/oradata/edr_temp/tmpfiles/temp01.dbf'SIZE 4000M;

And one more thing needed is that I had to create a password file
#pwd
/uo1/oracle/app/product/9.2.0.1.0/dbs
orapwd file=orapwedr password=**********