jueves, 13 de marzo de 2014

SGA TARGET


SGA target

SGA_TARGET is a database initialization parameter (introduced in Oracle 10g) that can be used for automatic SGA memory sizing.
Parameter description:
SGA_TARGET
Property          Description
Parameter type    Big integer
Syntax            SGA_TARGET = integer [K | M | G]
Default value     0 (SGA autotuning is disabled)
Modifiable        ALTER SYSTEM
Range of values   64 to operating system-dependent
Basic             Yes
SGA_TARGET provides the following:
  • Single parameter for total SGA size 
  • Automatically sizes SGA components
  • Memory is transferred to where most needed
  • Uses workload information 
  • Uses internal advisory predictions 
  • STATISTICS_LEVEL must be set to TYPICAL 
By using one parameter we don't need to use all other SGA parameters like.
  • DB_CACHE_SIZE (DEFAULT buffer pool)
  • SHARED_POOL_SIZE (Shared Pool)
  • LARGE_POOL_SIZE (Large Pool)
  • JAVA_POOL_SIZE (Java Pool)

[edit]Enable SGA_TARGET

SQL> show parameter sga_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_target                           big integer 0
SQL> show parameter sga_max_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
sga_max_size                         big integer 600M
As we can see our automatic SGA tuning is not enabled so we can enable it by setting the SGA_TARGET parameter value.
SQL> alter system set sga_target=500m;
System altered.

SQL> show parameter sga_target

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------
sga_target                           big integer  500M

[edit]Resize SGA_TARGET

  • SGA_TARGET is dynamic 
  • Can be increased till SGA_MAX_SIZE
  • Can be reduced till some component reaches minimum size
  • Change in value of SGA_TARGET affects only automatically sized components
SQL> show parameter sga_max_size
NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------
sga_max_size                         big integer 600M
SQL> show parameter sga_target
NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------
sga_target                           big integer 500M
We can resize it to only 600m if we will try to increase it from 600m we will get error.
SQL> alter system set sga_target=605m;
alter system set sga_target=605m
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-00823: Specified value of sga_target greater than sga_max_size
For that we must first increase our SGA_MAX_SIZE parameter value. But we must restart out instance because its STATIC parameter.
SQL> alter system set sga_max_size=956m scope=spfile;
System altered.

SQL> startup force
ORACLE instance started.
Total System Global Area 1000189952 bytes
Fixed Size                  1337492 bytes
Variable Size             624953196 bytes
Database Buffers          369098752 bytes
Redo Buffers                4800512 bytes
Database mounted.
Database opened.

SQL> show parameter sga_max_size
NAME                                 TYPE        VALUE
------------------------------------ ----------- --------
sga_max_size                         big integer 956M
 
SQL> alter system set sga_target=900m;
System altered.
Be careful when you are using 32 bit system, sga_max_size should be less than 4GB otherwise Oracle instance will fail to startup. Also in 32 bit system, it is observed that total sga+total pga should be less than the actual physical memory available.

It appear that on Windows 32 bits, maximum size for (SGA + PGA + Oracle memory for connection) must be < 2000 MO

On Windows 32 bits with Windows "/3GB" and "/PAE" options (Windows 2003 Server and later), maximum size for (SGA + PGA + Oracle memory for connection) must be < 3000 MO

[edit]Disable SGA_TARGET

We can Disable our automatic SGA tuning by setting the parameter SGA_TARGET to value digit 0.
SQL> alter system set sga_target=0;

System altered.


from: http://www.orafaq.com/wiki/SGA_target 

viernes, 7 de marzo de 2014

RESTAURACIONES ORACLE 10G

1. Vemos informacion de los spfile y asm

1.1. Verificamos la direccion de los spfile en la bd.

sql> show parameter spfile



1.2. ingresamos a asm
# . ./.bash_profile_grid
# asmcmd
--verificamos el diskgroup para los cambio de parametros



3. Creamos o duplicamos la instancia en el servidor receptor.

3.1.--Vamos a:

cd /oracle/product/10.2.4/db/dbs

cp initCOLC.ora initCOOX.ora

-- la manera mas sencilla es copiar una que ya se encuentre hecha y reemplazar valores.
--clonamos las instancias y renombramos
---se deben crear los parametros y directorios que se reemplazaran en el archivo.
vi initCOOX.ora

-- cambiamos parametros y creamos las carpetas a las que se direcciona los disgroup
(se debe colocar la direccion del los spfile y/o asm)

3.2. iniciamos la instancia creada

#export ORACLE_SID=nuevainstancia
#sqlplus /nolog
SQL> connect / as sysdba
SQL> startup nomount pfile=C:\location_to_file\init.ora;


4. verificamos los backups realizado en el servidor principal o en cinta en este caso estan ubicados en:
(verificamos el ultimo backup realizado en el servidor origen para la fecha y hora)
#cd oracle/scripts/RMAN/logs


5. buscamos la carpet scripts
en este caso:  /oracle/scripts/RMAN/scripts



5.1.) cp y Modificamos el script restore_db_nombreinstancia
ejemplo: cp restore_controlfile_colc.rcv restore_controlfile_copg.rcv


5.1.1.) Editamos el archivo restore_controlfile_copg.rcv

-- modificamos dos lineas el Numero del dbid, la linea del SEND. (La informacion la tomamos del ultimo backup en cinta realizado)
-- El ultimo backup del servidor origen lo podemos ver en EJEMPLO: vi /oracle/scripts/RMAN/logs/backup_diario_COPG2014030622\:58\:03.log

vi restore_controlfile_copg.rcv
 ----------------------------------------------------------------------------------------------------------------------
connect catalog CAT_OXIGENOS/OXIGENOS123*@cat10g
connect target /
set dbid 1383649134;
RUN {
ALLOCATE CHANNEL ch00  TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch01  TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch02  TYPE 'SBT_TAPE';
SEND 'NB_ORA_CLIENT=colbogdb6.oxigenos.co,NB_ORA_SERV=nbmaster,NB_ORA_POLICY=Oxigenos-colbogdb6-Oracle-copg';
restore controlfile until time "to_date ('07.03.2014 8:00:00', 'dd.mm.yyyy hh24:mi:ss')";
 }

 ----------------------------------------------------------------------------------------------------------------------



5.2.) cp y modificamos el script restore_db_nombreinstancia.rcv
ejemplo: cp restore_db_colc.rcv restore_db_copg.rcv

5.2.1.) Modificamos el archivo restore_db_copg.rcv
--se debe modificar la linea de SEND (esta informacion debe ser sacada de el backup en cinta a restaurar)
------------------------------------------------------------------------------------------------------------------------
connect catalog CAT_OXIGENOS/OXIGENOS123*@cat10g
connect target /
run {
ALLOCATE CHANNEL ch00  TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch01  TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch02  TYPE 'SBT_TAPE';
SEND 'NB_ORA_CLIENT=colbogdb6.oxigenos.co,NB_ORA_SERV=nbmaster,NB_ORA_POLICY=Oxigenos-colbogdb6-Oracle-colc';
set until time "to_date ('06.03.2014 8:00:00', 'dd.mm.yyyy hh24:mi:ss')";
restore database;
recover database;
}
------------------------------------------------------------------------------------------------------------------------



5.3. cp y modificamos el script restore_controlfile_instanceold.sh restore_controlfile_instancenew.sh
ejemplo restore_controlfile_instanceold.sh restore_controlfile_instancenew.sh

#vi restore_controlfile_instancenew.sh

-- modificamos parametros del fichero
-----------------------------------------------------------------------------------------------------------------------
export ORACLE_SID=COPG
rman cmdfile=restore_controlfile_copg.rcv log=restore_control_copg.log
-----------------------------------------------------------------------------------------------------------------------




6. ejecutamos el script sh
6.1. buscamos la carpet scripts en este caso:  /oracle/scripts/RMAN/scripts

#nohup sh restore_db_nombreinstancenwe.sh &



6.2. Verificar el estado de la restauracion:

tail -f restore_db_nombreinstancia.sh


8. Cuando terminamos, Ingresamos la instacia creada ps -fea|grep pmon // export ORACLE_SID=nombreinstancia

SQL> alter database open reset log