Anda di halaman 1dari 16

AdministracinBsicadeOracle10g

PRACTICASTEMA5.
TABLESPACES.
5.1.ConsultarlostablespacesquecomponenlaBD.Comprobarlosficherosquetienecada

unodeellos.Culesson'locales'yculesno?VerqucontieneeltablespaceSYSAUXy
eltamaodecadaunodesusocupantes.

5.2. Crea el tablespace DATACURSOxy, NO manejado localmente, con el fichero

/u02/oradata/CURSOxy/datacursoXY01.dbf, con un tamao de 1M. Cralo de nuevo,


manejadolocalmente.Crea3tablas(TABLA01,TABLA02,TABLA03)de256Ksobredicho
tablespace.BorralatablaTABLA02ycreaunatablaTABLA04de352K.Quocurreypor
qu?.

5.3.PoneltablespaceDATACURSOxyenmodoREADONLY.Insertaunafilaenalgunade

sustablas,quocurreyporqu?.BorralatablaTABLA01,porqusepuedeborrar?.
Deja el tablespace DATACURSOxy en modo READWRITE. Repite el insert sobre
TABLA02.

5.4.CreaunatablaTABLA04de256KeneltablespaceDATACURSOxy,quocurreypor

qu?.Activaelautoextenddesufichero,ajustandonext256Kymaxsize2M.Vuelveacrear
latablaTABLA04.

5.5.

Crea el tablespace INDCURSOxy de 1M con el fichero


'/u02/oradata/CURSOxy/indcursoXY01.dbf'.Muveloaldirectorio'/u03/oradata/CURSOxy'.

5.6. Redimensionar el tablespace DATACURSOxy a 1M qu ocurre y por qu?.

RedimensionareltablespaceINDCURSOxya512K,yaadirleotroficherode512K.

5.7.CrearuntablespacedeundoUNDO_CURSOxy.Convertirloeneltablespacedeundo

activo.CrearunatablaTABLA05enelnuevotablespace,quocurre?Consultarlavista
V$UNDOSTAT.

5.8. CrearuntablespacetemporalTEMP_CURSOxyde1M.Quocurrealponerloread

only?yalmoverlo?Hazqueseaeltablespacetemporalpordefectodelabasededatos
quepasaalponerlooffline?ysiloborramos?

5.9.Comprobareltablespacepordefectoytbeltemporalquetienedefinidocadausuarioque

existeenlaBD.ModificareltablespacepordefectodelaBDporDATACURSOxyyvolvera
hacerlacomprobacinanterior.

5.10. Crear los tablespaces TEMP01CURSOxy Y TEMP02CURSOxy de 4M cada uno y

asignarlosalgrupoGTEMP.AsignaralusuarioscotteltablespacetemporalGTEMP.

5.11. ConsultarlaestadsticaDBtimeenV$SYS_TIME_MODEL.Generaruninformede

ADDM(AutomaticDatabaseDiagnosticMonitor).GenerartbuninformedeAWR.

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g

5.1. ConsultarlostablespacesquecomponenlaBD.Comprobarlosficheros
que tiene cada uno. Cuales son 'locales' y cuales no? Ver qu contiene el
tablespaceSYSAUXyeltamaodecadaunodesusocupantes.
En el DD disponemos de vistas para consultar informacin sobre tablespaces
(DBA_TABLESPACES, V$TABLESPACE) y los ficheros que los componen (DBA_DATA_FILES,
DBA_TEMP_FILES,V$DATAFILE,V$TEMPFILE)
SQL>selecttablespace_name,extent_managementfromdba_tablespaces;
TABLESPACE_NAMEEXTENT_MAN

SYSTEMLOCAL
UNDO_RBSLOCAL
SYSAUXLOCAL
TEMPLOCAL
USERSLOCAL
(Todoslostablespacessonlocales.Enestecasonopuedehaberningunomanejadopor
diccionariopqelSYSTEMeslocal.)

SQL>SELECTrpad(a.TABLESPACE_NAME,10)tablespace,rpad(a.FILE_NAME,40)fichero,
to_char(a.BYTES/1024/1024,'999.99')MB,
to_char(a.increment_by*b.value/1024/1024,'99.99')nextmb,
to_char(a.MAXBYTES/1024/1024,'9999.99')maxmb
FROMDBA_DATA_FILESa,v$parameterb
whereb.name='db_block_size';
TABLESPACEFICHEROMBNEXTMBMAXMB

USERS/u02/oradata/CURSOxy/users01.dbf1.001.0020.00
SYSAUX/u03/oradata/CURSOxy/sysaux01.dbf140.0010.00400.00
UNDO_RBS/u03/oradata/CURSOxy/undo_rbs01.dbf20.001.0020.00
SYSTEM/u02/oradata/CURSOxy/system01.dbf260.0010.00400.00
(Enlasentenciaanteriorsemuestranlosficherosqformanpartedecadatablespace,con
sustamaosactuales,ascomolosparmetrosdecrecimientodinmico.)
SQL>selectrpad(name,40)name,CHECKPOINT_CHANGE#,
to_char(CHECKPOINT_TIME,'dd/mm/yyyyhh24:mi')CHECKPOINT_TIME
fromv$datafile;
NAMECHECKPOINT_CHANGE#CHECKPOINT_TIME

/u02/oradata/CURSOxy/system01.dbf117275307/11/200609:51
/u03/oradata/CURSOxy/undo_rbs01.dbf117275307/11/200609:51
/u03/oradata/CURSOxy/sysaux01.dbf117275307/11/200609:51
/u02/oradata/CURSOxy/users01.dbf117275307/11/200609:51

ParaverlosocupantesdeltablespaceSYSAUX,ycuntoocupacadaunoconsultaremosV$
SQL>selectrpad(occupant_name,30),space_usage_kbytesfromv$sysaux_occupants;
RPAD(OCCUPANT_NAME,30)SPACE_USAGE_KBYTES

LOGMNR6080
LOGSTDBY896
STREAMS512
XDB0

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g
AO768
XSOQHIST768
XSAMD0
SM/AWR52672
SM/ADVISOR8000
SM/OPTSTAT14784
SM/OTHER4864
...
EM_MONITORING_USER1600
TSM256
JOB_SCHEDULER384
26filasseleccionadas.

5.2. Crea el tablespace DATACURSOxy, NO manejado localmente, con el


fichero/u02/oradata/datacursoXY01.dbf,conuntamaode1M.Cralodenuevo,
manejadolocalmente.Crea3tablas (TABLA01,TABLA02,TABLA03)de256K
sobredichotablespace.BorralastablaTABLA02ycreaunatablaTABLA04de
352K.Quocurreyporqu?.
Los tablespaces 'manejados localmente' gestionan mejor los huecos libres, eliminando la
fragmentacin que, en el caso de tablespaces tradicionales, provoca el borrado de objetos. El
espaciolibreinicialenlos'tablespaceslocales'esalgomenorqueenlos'tradicionales',yaquese
pierdeespacioparaelbitmap.
Si el tablespace SYSTEM ha sido creado como LOCAL, ya no se podr crear ningn
tablespacemanejadoporDICCIONARIOenlaBD.
(OJO!!!sustituyexyporelnmerodetuusuariodeprcticas)
SQL>createtablespaceDATACURSOxy
datafile'/u02/oradata/CURSOxy/datacursoXY01.dbf'size1Mreuse
extentmanagementdictionary;
ORA12913:Nosepuedecrearuntablespacegestionadoporeldiccionario
SQL>CreatetablespaceDATACURSOxy

datafile'/u02/oradata/CURSOxy/datacursoXY01.dbf'size1Mreuse
extentmanagementlocaluniformsize128K;

Tablespacecreado.
SQL>selecttablespace_name,extent_managementfromdba_tablespaces
wheretablespace_name='DATACURSOxy';
TABLESPACE_NAMEEXTENT_MAN

DATACURSOxyLOCAL
SQL>createtableTABLA01(C1VARCHAR2(4000))

tablespaceDATACURSOxystorage(initial256Kminextents1);

Tablacreada.
SQL>createtableTABLA02(C1VARCHAR2(4000))

tablespaceDATACURSOxystorage(initial256Kminextents1);

Tablacreada.

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g
SQL>createtableTABLA03(C1VARCHAR2(4000))

tablespaceDATACURSOxystorage(initial256Kminextents1);

Tablacreada.
SQL>droptabletabla02purge;
Tablaborrada.
SQL>selectbytesfromdba_free_spacewheretablespace_name='DATACURSOxy';
BYTES

262144
131072
SQL>createtableTABLA02(C1VARCHAR2(4000))
tablespaceDATACURSOxystorage(initial352Kminextents1);
Tablacreada.
SQL>selectbytesfromdba_free_spacewheretablespace_name='DATACURSOxy';
ningunafilaseleccionada

Comoseobserva,siendoeltablespacelocal,seaprovechanloshuecosquesegeneranconel
borradodetablas.Lacuestinclave,enestecaso,esencontraruntamaoadecuadoparauniform
size.Unaposibilidadestenervariostablespaces:pequeo,medianoygrandeconuniformsize,por
ejemplo,de8K,256Ky8M:

DATOS8K:paraguardartablasdemenosde1Mdetamao.

DATOS256K:paratablasdeentre1Mhasta32M.

DATOS8M:paraaquellasmayoresde32M.

5.3.PoneltablespaceDATACURSOxyenmodoREADONLY.Insertaunafilaen
algunadesustablas,quocurre?.BorralatablaTABLA01,porqusepuede
borrar?. Deja el tablespace DATACURSOxy en modo READWRITE. Repite el
insert,ahorasobreTABLA03.
Enuntablespacereadonlynosepuedenactualizardatos(insert,update,delete),perossepueden
borrarobjetos(droptable),yaqueelborradodeobjetossloafectaalDD(ynoaltablespace).
SQL>altertablespaceDATACURSOxyreadonly;
Tablespacemodificado.
SQL>insertintotabla01values('PRIMERAFILA');
ORA00372:elfichero5nopuedesermodificadoenestemomento
ORA01110:ficherodedatos5:'/u02/oradata/CURSOxy/datacursoXY01.dbf'
SQL>DROPTABLETABLA01purge;
Tablaborrada.
SQL>altertablespaceDATACURSOxyreadwrite;
Tablespacemodificado.
SQL>insertintotabla03values('PRIMERAFILA');
1filacreada.

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g
SQL>commit;
Validacinterminada.

5.4. CreaunatablaTABLA04de512KeneltablespaceDATACURSOxy,qu
ocurreyporqu?.Activael autoextenddesufichero,ajustandonext256Ky
maxsize2M.VuelveacrearlatablaTABLA06.
Cuandoeltablespacesellenanoserposiblecrearmsobjetos,anoserqueestactivadoel
'autoextend',deformaquepermitalaampliacindeltablespacelosuficienteparaalbergarelnuevo
objeto.
SQL>selectbytesfromdba_free_spacewheretablespace_name='DATACURSOxy';
BYTES

262144
SQL>createtableTABLA04(C1VARCHAR2(4000))
tablespaceDATACURSOxystorage(initial512Kminextents1);
ORA01659:nosehanpodidoasignarMINEXTENTSmasallade2eneltablespace
DATACURSOxy
(Nosepuedecrearunatablade512Kpqsloquedan256Klibreeneltablespace)
SQL>alterdatabasedatafile'/u02/oradata/CURSOxy/datacursoXY01.dbf'
autoextendonnext256Kmaxsize2M;
Basededatosmodificada.
SQL>createtableTABLA04(C1VARCHAR2(4000))
tablespaceDATACURSOxystorage(initial512Kminextents1);
Tablacreada.
SQL>selectbytesfromdba_free_spacewheretablespace_name='DATACURSOxy';
ningunafilaseleccionada
SQL>SELECTrpad(segment_name,20)segmento,segment_typetipo,bytesfromdba_extents
wheretablespace_name='DATACURSOxy';
SEGMENTOTIPOBYTES

TABLA02TABLE131072
TABLA02TABLE131072
TABLA02TABLE131072
TABLA03TABLE131072
TABLA03TABLE131072
TABLA04TABLE131072
TABLA04TABLE131072
TABLA04TABLE131072
TABLA04TABLE131072
9filasseleccionadas.
(Comoseobserva,alsereltablespacemanejadolocalmenteyconuniformsize128K,el
tamaodelaextensinmanejadoparaasignarespacioalastablasesde128K)

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g

5.5. Crea el tablespace INDCURSOxy de 1M con el fichero


'/u02/oradata/CURSOxy/indcursoXY01.dbf'. Muvelo al directorio
'/u03/oradata/CURSOxy'.
Paramoverorenombrarunficherodeuntablespace,steltimodebeestarOFFLINE.
SQL>createtablespaceINDCURSOxy
datafile'/u02/oradata/CURSOxy/indcursoXY01.dbf'size1Mreuse
extentmanagementlocaluniformsize64K;
Tablespacecreado.
SQL>altertablespaceindcursoXYoffline;
Tablespacemodificado.
SQL>!mv/u02/oradata/CURSOxy/indcursoXY01.dbf/u03/oradata/CURSOxy/indcursoXY01.dbf
SQL>altertablespaceindcursoXY
renamedatafile'/u02/oradata/CURSOxy/indcursoXY01.dbf'to
'/u03/oradata/CURSOxy/indcursoXY01.dbf';
Tablespacemodificado.
SQL>altertablespaceindcursoXYonline;
Tablespacemodificado.
SQL>selectfile_namefromdba_data_files;
FILE_NAME

/u02/oradata/CURSOxy/datacursoXY01.dbf
/u03/oradata/CURSOxy/indcursoXY01.dbf
/u02/oradata/CURSOxy/system01.dbf
/u03/oradata/CURSOxy/undo_rbs01.dbf
/u03/oradata/CURSOxy/sysaux01.dbf
/u02/oradata/CURSOxy/users01.dbf

5.6.RedimensionareltablespaceDATACURSOxya1Mquocurreyporqu?
RedimensionareltablespaceINDCURSOxya512K,yaadirleotroficherode
512K.
Sepuederedimensionarunficheroreduciendosutamaoslosielespaciorecortadoestlibre.En
elcasodeDATACURSOxynoesposiblereducirloa1Mporquetieneespacioocupadoenelespacio
recortado.Sinembargo,INDCURSOxysquepuedeserreducidoa512Kporqueestvaco.
SQL>alterdatabasedatafile'/u02/oradata/CURSOxy/datacursoXY01.dbf'resize1M;
ORA03297:elarchivocontienedatosutilizadosmasalladelvalorRESIZE
solicitado
SQL>alterdatabasedatafile'/u03/oradata/CURSOxy/indcursoXY01.dbf'resize512K;
Databasealtered.
SQL>altertablespaceINDCURSOxyadddatafile'/u03/oradata/CURSOxy/indcursoXY02.dbf'
size512K;
Tablespacealtered.

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g
SQL>selectrpad(file_name,50),bytesfromdba_data_fileswhere
tablespace_name='INDCURSOxy';
RPAD(FILE_NAME,50)BYTES

/u03/oradata/CURSOxy/indcursoXY01.dbf524288
/u03/oradata/CURSOxy/indcursoXY02.dbf524288

5.7.CrearuntablespacedeundoUNDO_CURSOxy.Convertirloenel
tablespacedeundoactivo.CrearunatablaTABLA05enelnuevotablespace,
quocurre?ConsultarlavistaV$UNDOSTAT.
Podemostenervariostablespacesdeundo,peroslounodeellosestaractivoenunmomento
dado (el indicado en el parmetro undo_tablespace). No se pueden crear objetos sobre un
tablespacedeundo(comopuedeserunatabla).
Al cambiar de tablespace undo activo (con undo_tablespace), los segmentos de rollback que
contieneelnuevotablespacepasanaestaronline,mientrasquelosdeltablespaceanteriorse
ponenoffline.
SQL>createundotablespaceundo_cursoXYdatafile
'/u03/oradata/CURSOxy/undo_cursoXY01.dbf'size1M;
Tablespacecreated.
SQL>select*fromdba_tablespaceswheretablespace_name='UNDO_CURSOxy';
TABLESPACE_NAMEBLOCK_SIZEINITIAL_EXTENTNEXT_EXTENTMIN_EXTENTS

MAX_EXTENTSPCT_INCREASEMIN_EXTLENSTATUSCONTENTSLOGGINGFOREXTENT_MAN

ALLOCATIOPLUSEGMENDEF_TAB_RETENTIONBIG

UNDO_CURSOxy2048655361
214748364565536ONLINEUNDOLOGGINGNOLOCAL
SYSTEMNOMANUALDISABLEDNOGUARANTEENO
SQL>CREATETABLETABLA05(C1VARCHAR2(2))TABLESPACEUNDO_CURSOxy;
ORA30022:Nosepuedencrearsegmentosenuntablespacededeshacer
SQL>SHOWPARAMETERUNDO_TABLESPACE
NAMETYPEVALUE

undo_tablespacestringUNDO_RBS
SQL>SELECTSEGMENT_NAME,TABLESPACE_NAME,STATUSFROMDBA_ROLLBACK_SEGS;
SEGMENT_NAMETABLESPACE_NAMESTATUS

SYSTEMSYSTEMONLINE
_SYSSMU1$UNDO_RBSONLINE
_SYSSMU2$UNDO_RBSONLINE
_SYSSMU3$UNDO_RBSONLINE
_SYSSMU4$UNDO_RBSONLINE
_SYSSMU5$UNDO_RBSONLINE
_SYSSMU6$UNDO_RBSONLINE
_SYSSMU7$UNDO_RBSONLINE
_SYSSMU8$UNDO_RBSONLINE
_SYSSMU9$UNDO_CURSOxyOFFLINE
_SYSSMU10$UNDO_CURSOxyOFFLINE

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g
_SYSSMU11$UNDO_CURSOxyOFFLINE
_SYSSMU12$UNDO_CURSOxyOFFLINE
_SYSSMU13$UNDO_CURSOxyOFFLINE
_SYSSMU14$UNDO_CURSOxyOFFLINE
_SYSSMU15$UNDO_CURSOxyOFFLINE
16filasseleccionadas.
SQL>ALTERSYSTEMSETUNDO_TABLESPACE=UNDO_CURSOxy;
Systemaltered.
SQL>SELECTSEGMENT_NAME,TABLESPACE_NAME,STATUSFROMDBA_ROLLBACK_SEGS;
SEGMENT_NAMETABLESPACE_NAMESTATUS

SYSTEMSYSTEMONLINE
_SYSSMU1$UNDO_RBSOFFLINE
_SYSSMU2$UNDO_RBSOFFLINE
_SYSSMU3$UNDO_RBSOFFLINE
_SYSSMU4$UNDO_RBSOFFLINE
_SYSSMU5$UNDO_RBSOFFLINE
_SYSSMU6$UNDO_RBSOFFLINE
_SYSSMU7$UNDO_RBSOFFLINE
_SYSSMU8$UNDO_RBSOFFLINE
_SYSSMU9$UNDO_CURSOxyONLINE
_SYSSMU10$UNDO_CURSOxyONLINE
_SYSSMU11$UNDO_CURSOxyONLINE
_SYSSMU12$UNDO_CURSOxyONLINE
_SYSSMU13$UNDO_CURSOxyONLINE
_SYSSMU14$UNDO_CURSOxyONLINE
_SYSSMU15$UNDO_CURSOxyONLINE
16filasseleccionadas.
SQL>selectto_char(BEGIN_TIME,'dd/mm/yyyyhh24:mi')BEGIN_TIME,b.nameTABLESPACE,
UNDOBLKS,TXNCOUNT
fromV$UNDOSTATa,v$tablespaceb
WHEREA.UNDOTSN=B.TS#
ORDERBYBEGIN_TIME;
BEGIN_TIMENAMEUNDOBLKSTXNCOUNT

...
20/03/200710:25UNDO_RBS16
20/03/200710:35UNDO_RBS37
20/03/200710:45UNDO_RBS40146
20/03/200710:55UNDO_CURSOXY237159

EnlavistaV$UNDOSTATseguardainformacinvaliosacuandoseusaundoautomtico,pues
podemosverestadsticas(cada10minutos)deltablespacedeundousado(UNDOTSN),bloquesde
rollbackconsumidos(UNDOBLKS)yelntotaldetransaccionesdedichoperiodo(TXNCOUNT).

5.8. Crear un tablespace temporal TEMP_CURSOxy de 1M. Qu ocurre al


ponerloreadonly?Hazqueseaeltablespacetemporalpordefectodelabase
dedatosquepasaalponerlooffline?ysiloborramos?
Untablespacetemporalnopuedeponerseenmodoreadonly,ytampocosepuedeponeroffline.
EltablespacetemporalpordefectodelaBD,adems,nopuedeserborrado.
SQL>showparametersort_area_size

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g
NAMETYPEVALUE

sort_area_sizeinteger65536
SQL>createtemporarytablespacetemp_cursoXYtempfile
'/u03/oradata/CURSOxy/temp_cursoXY01.dbf'size1Mextentmanagementlocaluniformsize
64K;
Tablespacecreated.
SQL>altertablespacetemp_cursoXYreadonly;
ORA03217:opcionnovalidaparaALTERdeTEMPORARYTABLESPACE
SQL>altertablespacetemp_cursoXYoffline;
ORA03217:opcionnovalidaparaALTERdeTEMPORARYTABLESPACE
SQL>alterdatabasedefaulttemporarytablespacetemp_cursoXY;
Databasealtered.
SQL>droptablespacetemp_cursoXY;
ORA12906:nosepuedeborrareltablespacetemporalpordefecto
SQL>alterdatabasedefaulttemporarytablespacetemp;
Databasealtered.
SQL>droptablespacetemp_cursoXY;
Tablespaceborrado.

5.9. Comprobarel tablespace por defecto y tb el temporal quetienedefinido


cadausuarioqueexisteenlaBD.ModificareltablespacepordefectodelaBD
por DATACURSOxy y volver a hacer la comprobacin anterior. Renombrar el
tablespace DATACURSOxy por DATOSCURSO y hacer de nuevo la
comprobacin.
Podemosvereltablespacepordefecto(yeltemporal)decadausuarioenDBA_USERS.
SQL>SELECTUSERNAME,rpad(DEFAULT_TABLESPACE,20),rpad(TEMPORARY_TABLESPACE,20)
FROMDBA_USERS;
USERNAMERPAD(DEFAULT_TABLESPRPAD(TEMPORARY_TABLE

OUTLNSYSTEMTEMP
SYSSYSTEMTEMP
SYSTEMSYSTEMTEMP
SCOTTUSERSTEMP
DBSNMPSYSAUXTEMP
TSMSYSUSERSTEMP
DIPUSERSTEMP
7filasseleccionadas.
SQL>alterdatabasedefaulttablespacedatacursoXY;
Basededatosmodificada.
SQL>SELECTUSERNAME,rpad(DEFAULT_TABLESPACE,20),rpad(TEMPORARY_TABLESPACE,20)
FROMDBA_USERS;
USERNAMERPAD(DEFAULT_TABLESPRPAD(TEMPORARY_TABLE

OUTLNSYSTEMTEMP

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

AdministracinBsicadeOracle10g
SYSSYSTEMTEMP
SYSTEMSYSTEMTEMP
SCOTTDATACURSOXYTEMP
DBSNMPSYSAUXTEMP
TSMSYSDATACURSOXYTEMP
DIPDATACURSOXYTEMP
7filasseleccionadas.
(Comoseobserva,paralosusuariosOUTLN,SYS,SYSTEMyDBSNMPnocambiaeltablespace
pordefecto.)
SQL>altertablespacedatacursoXYrenametodatoscurso;
Tablespacemodificado.
SQL>SELECTUSERNAME,rpad(DEFAULT_TABLESPACE,20),rpad(TEMPORARY_TABLESPACE,20)
FROMDBA_USERS;
USERNAMERPAD(DEFAULT_TABLESPRPAD(TEMPORARY_TABLE

OUTLNSYSTEMTEMP
SYSSYSTEMTEMP
SYSTEMSYSTEMTEMP
BORRAMEDATOSCURSOTEMP
SCOTTDATOSCURSOTEMP
DBSNMPSYSAUXTEMP
TSMSYSDATOSCURSOTEMP
DIPDATOSCURSOTEMP
8filasseleccionadas.

5.10.CrearlostablespacesTEMP01CURSOxyYTEMP02CURSOxyde4Mcada
uno y asignarlos al grupo GTEMP. Asignar al usuario scott el tablespace
temporalGTEMP.
ConOracle10g podemosagrupartablespacestemporales.Se tratadeunnuevoconcepto, con
interesante aplicacin en la gestin de tablespaces temporales, de modo q por ejemplo; si una
consultallenauntablespacetemporalperohaymstablespacesenelgrupo,podraseguirconotro
tablespace.Adems,encasodeejecucinparaleladeconsultas(parallelquery),siseusaun
grupodetablespacescomotablespacetemporal,Oracleescapazdeusarlostablespacesqforman
partedelgrupoenparalelo.
SQL>createtemporarytablespacetemp01cursoXY
tempfile'/u03/oradata/CURSOxy/temp01cursoXY01.dbf'size4M
extentmanagementlocaluniformsize64K;
Tablespacecreado.
SQL>createtemporarytablespacetemp02cursoXY
tempfile'/u03/oradata/CURSOxy/temp02cursoXY01.dbf'size4M
extentmanagementlocaluniformsize64K;
Tablespacecreado.
SQL>ALTERTABLESPACEtemp02cursoXYTABLESPACEGROUPGTEMP;
Tablespacemodificado.
SQL>ALTERTABLESPACEtemp01cursoXYTABLESPACEGROUPGTEMP;
Tablespacemodificado.
SQL>ALTERUSERSCOTTTEMPORARYTABLESPACEGTEMP;

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

10

AdministracinBsicadeOracle10g
Usuariomodificado.
SQL>SELECTUSERNAME,rpad(DEFAULT_TABLESPACE,20),rpad(TEMPORARY_TABLESPACE,20)
FROMDBA_USERSWHEREUSERNAME='SCOTT';
USERNAMERPAD(DEFAULT_TABLESPRPAD(TEMPORARY_TABLE

SCOTTDATOSCURSOGTEMP

5.11. Consultar la estadstica DB time en V$SYS_TIME_MODEL. Generar un


informe de ADDM (Automatic Database Diagnostic Monitor). Generar tb un
informedeAWR.
PodemosgenerarelinfomedeADDMcon$ORACLE_HOME/rdbms/admin/addmrpt.sql.Elobjetivo
es reducir DB time, q no es ms q el tiempo acumulado invertido por la BD en atender las
peticionesdelosusuarios.ADDM,ensusinformes,nosdarecomendacionesdeajustedelaBD.
Por otro lado, los informes de AWR se pueden generar con
$ORACLE_HOME/rdbms/admin/awrrpt.sql,yvienenasustituiralautilidadSTATSPACKde8i/9i.
SQL>selectrpad(stat_name,50),valuefromV$SYS_TIME_MODEL;
RPAD(STAT_NAME,50)VALUE

DBtime1,8988E+10
DBCPU95918787
backgroundelapsedtime8847949066
backgroundcputime161639105
sequenceloadelapsedtime2219464
parsetimeelapsed1596431308
hardparseelapsedtime1572791362
sqlexecuteelapsedtime1,8966E+10
connectionmanagementcallelapsedtime1973855
failedparseelapsedtime21172
failedparse(outofsharedmemory)elapsedtime0
hardparse(sharingcriteria)elapsedtime25824975
hardparse(bindmismatch)elapsedtime76402
PL/SQLexecutionelapsedtime231504796
inboundPL/SQLrpcelapsedtime0
PL/SQLcompilationelapsedtime66051840
Javaexecutionelapsedtime0
repeatedbindelapsedtime1240320
RMANcputime(backup/restore)0
(AntesdegenerarelinformedeADDMmeasegurodeqeltablespacedeUNDOesel
correcto)
SQL>altersystemsetundo_tablespace=undo_rbs;
Sistemamodificado.
(VamosageneraruninformedeADDM)
SQL>@$ORACLE_HOME/rdbms/admin/addmrpt.sql
CurrentInstance
~~~~~~~~~~~~~~~~
DBIdDBNameInstNumInstance

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

11

AdministracinBsicadeOracle10g

1571846067CURSOxy1CURSOxy
InstancesinthisWorkloadRepositoryschema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DBIdInstNumDBNameInstanceHost

*15718460671CURSOxyCURSOxycursos.atica
.um.es
Using1571846067fordatabaseId
Using1forinstancenumber
Specifythenumberofdaysofsnapshotstochoosefrom
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enteringthenumberofdays(n)willresultinthemostrecent
(n)daysofsnapshotsbeinglisted.Pressing<return>without
specifyinganumberlistsallcompletedsnapshots.
Listingthelast3daysofCompletedSnapshots
Snap
InstanceDBNameSnapIdSnapStartedLevel

CURSOxyCURSOxy38506Nov200610:341
...
40707Nov200609:001
40807Nov200610:001
40907Nov200611:001
41107Nov200613:001
SpecifytheBeginandEndSnapshotIds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Introduzcaunvalorparabegin_snap:385
Introduzcaunvalorparaend_snap:407
SpecifytheReportName
~~~~~~~~~~~~~~~~~~~~~~~
Thedefaultreportfilenameisaddmrpt_1_385_407.txt.Tousethisname,
press<return>tocontinue,otherwiseenteranalternative.
...
DETAILEDADDMREPORTFORTASK'TAREA_1515'WITHID1515

AnalysisPeriod:from06NOV200610:34to07NOV200609:00
DatabaseID/Instance:1571846067/1
Database/InstanceNames:CURSOxy/CURSOxy
HostName:cursos.atica.um.es
DatabaseVersion:10.2.0.2.0
SnapshotRange:from385to407
DatabaseTime:5090seconds
AverageDatabaseLoad:,1activesessions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FINDING1:31%impact(1576seconds)

ElrendimientoglobaldelsubsistemadeE/Shasidosignificativamente
inferioralesperado.
RECOMMENDATION1:HostConfiguration,31%benefit(1576seconds)
ACTION:PuedeaumentarelrendimientoglobaldelsubsistemadeE/S.La
solucinrecomendadadeOracleesdividirtodoslosarchivosdedatos

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

12

AdministracinBsicadeOracle10g
conlaMISMAmetodologa.Tambinpuedequenecesiteaumentarel
nmerodediscosparamejorarelrendimiento.Comoalternativa,puede
utilizarlasolucinGestinAutomticadeAlmacenamientodeOracle.
RATIONALE:Duranteelperododeanlisis,elrendimientoglobalmedio
deE/Sdelosarchivosdedatoshasido2Kporsegundoparalecturas
y0.81Kporsegundoparaescrituras.Eltiempomedioderespuesta
paralecturasdeunnicobloquehasido83milisegundos.
SYMPTOMSTHATLEDTOTHEFINDING:
SYMPTOM:Laclasedeespera"E/SdelUsuario"haconsumidomuchotiempo
delabasededatos.(46%impact[2328seconds])
FINDING2:7,1%impact(360seconds)

EltamaodeSGAnoescorrectoporloquehaymsE/Sadicionalesoanlisis
deobjetosnoenconjuntocompartido.
RECOMMENDATION1:DBConfiguration,3,9%benefit(198seconds)
ACTION:AumenteeltamaodeSGAdefiniendoelparmetro"sga_target"en
125M.
ADDITIONALINFORMATION:
Elvalordelparmetro"sga_target"hasido"100M"duranteelperodo
deanlisis.
SYMPTOMSTHATLEDTOTHEFINDING:
SYMPTOM:Laclasedeespera"E/SdelUsuario"haconsumidomuchotiempo
delabasededatos.(46%impact[2328seconds])
SYMPTOM:Elanlisisdeobjetosnoenconjuntocompartidodesentencias
SQLhaconsumidomuchotiempodelabasededatos.(9,6%impact
[488seconds])
FINDING3:5,8%impact(293seconds)

Lasoperacionesdecambiodearchivologhanconsumidomuchotiempodelabase
dedatosmientrasseesperabalaterminacindelpuntodecontrol.
RECOMMENDATION1:DBConfiguration,5,8%benefit(293seconds)
ACTION:Verifiquesisehautilizadoelenvoincrementalparalasbases
dedatosenespera.
ADDITIONALINFORMATION:
Esteproblemasepuedeproducirporelusodelmododecopiade
seguridaddelabasededatosactivaenlostablespaces.ElDMLenlos
tablespacesenmododecopiadeseguridadconlabasededatosactiva
provocalageneracinderedoadicional.
SYMPTOMSTHATLEDTOTHEFINDING:
SYMPTOM:Laclasedeespera"Configuracin"haconsumidomuchotiempode
labasededatos.(5,8%impact[293seconds])
...
ADDITIONALINFORMATION

WARNING:Nosehapodidodeterminareltama?ooptimodeSGAdebidoa
instantaneasAWRincompletas.
Laclasedeespera"Aplicacion"nohaconsumidomuchotiempodelabasede

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

13

AdministracinBsicadeOracle10g
datos.
Laclasedeespera"Confirmar"nohaconsumidomuchotiempodelabasede
datos.
Laclasedeespera"Simultaneidad"nohaconsumidomuchotiempodelabasede
datos.
Laclasedeespera"Configuracion"nohaconsumidomuchotiempodelabasede
datos.
LaCPUnohasidouncuellodebotellaparalainstancia.
Laclasedeespera"Red"nohaconsumidomuchotiempodelabasededatos.
Lasllamadasdeconexionydesconexiondesesionesnohanconsumidomucho
tiempodelabasededatos.
Lasventanasdemantenimientodelabasededatosestabanactivasdurante100%
delperiododeanalisis.
TheanalysisofI/Operformanceisbasedonthedefaultassumptionthatthe
averagereadtimeforonedatabaseblockis10000microseconds.
Anexplanationoftheterminologyusedinthisreportisavailablewhenyou
runthereportwiththe'ALL'levelofdetail.
(AhoratocauninformedeAWR)
SQL>@$ORACLE_HOME/rdbms/admin/awrrpt.sql
CurrentInstance
~~~~~~~~~~~~~~~~
DBIdDBNameInstNumInstance

1571846067CURSOxy1CURSOxy
SpecifytheReportType
~~~~~~~~~~~~~~~~~~~~~~~
WouldyoulikeanHTMLreport,oraplaintextreport?
Enter'html'foranHTMLreport,or'text'forplaintext
Defaultsto'html'
Introduzcaunvalorparareport_type:text
TypeSpecified:text
InstancesinthisWorkloadRepositoryschema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DBIdInstNumDBNameInstanceHost

*15718460671CURSOxyCURSOxycursos.atica
.um.es
Using1571846067fordatabaseId
Using1forinstancenumber
Specifythenumberofdaysofsnapshotstochoosefrom
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enteringthenumberofdays(n)willresultinthemostrecent
(n)daysofsnapshotsbeinglisted.Pressing<return>without
specifyinganumberlistsallcompletedsnapshots.
Introduzcaunvalorparanum_days:3
Listingthelast3daysofCompletedSnapshots

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

14

AdministracinBsicadeOracle10g
Snap
InstanceDBNameSnapIdSnapStartedLevel

CURSOxyCURSOxy38506Nov200610:341
...
40707Nov200609:001
40807Nov200610:001
40907Nov200611:001
41107Nov200613:001
41207Nov200614:001
SpecifytheBeginandEndSnapshotIds
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Introduzcaunvalorparabegin_snap:385
BeginSnapshotIdspecified:385
Introduzcaunvalorparaend_snap:407
EndSnapshotIdspecified:407
SpecifytheReportName
~~~~~~~~~~~~~~~~~~~~~~~
Thedefaultreportfilenameisawrrpt_1_385_407.txt.Tousethisname,
press<return>tocontinue,otherwiseenteranalternative.
Introduzcaunvalorparareport_name:
Usingthereportnameawrrpt_1_385_407.txt
WORKLOADREPOSITORYreportfor
DBNameDBIdInstanceInstNumReleaseRACHost

CURSOxy1571846067CURSOxy110.2.0.2.0NOcursos.atica
SnapIdSnapTimeSessionsCurs/Sess

BeginSnap:38506Nov0610:34:40161.9
EndSnap:40707Nov0609:00:25155.1
Elapsed:1,345.75(mins)
DBTime:37.87(mins)
CacheSizes
~~~~~~~~~~~BeginEnd

BufferCache:12M12MStdBlockSize:2K
SharedPoolSize:48M48MLogBuffer:2,864K
LoadProfile
~~~~~~~~~~~~PerSecondPerTransaction

Redosize:548.875,564.88
Logicalreads:33.47339.38
Blockchanges:3.3433.88
Physicalreads:2.0220.46
Physicalwrites:0.333.39
Usercalls:0.000.02
Parses:1.0210.34
Hardparses:0.414.14
Sorts:1.7918.12

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

15

AdministracinBsicadeOracle10g
Logons:0.000.01
Executes:5.1051.74
Transactions:0.10
InstanceEfficiencyPercentages(Target100%)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BufferNowait%:100.00RedoNoWait%:99.82
BufferHit%:96.59InmemorySort%:99.99
LibraryHit%:91.09SoftParse%:90.80
ExecutetoParse%:68.12LatchHit%:100.00
ParseCPUtoParseElapsd%:3.12%NonParseCPU:89.07
SharedPoolStatisticsBeginEnd

MemoryUsage%:82.9883.40
%SQLwithexecutions>1:72.9573.48
%MemoryforSQLw/exec>1:66.9866.18
Top5TimedEventsAvg%Total
~~~~~~~~~~~~~~~~~~waitCall
EventWaitsTime(s)(ms)TimeWaitClass

dbfilesequentialread18,1091,5028329.5UserI/O
dbfilescatteredread3,13975824114.9UserI/O
controlfileparallelwrite29,1165892011.6SystemI/O
logfileparallelwrite3,148244784.8SystemI/O
logfileswitch(checkpointin2532419534.7Configurat
...
ParameterNameBeginvalue(ifdifferent)

background_dump_dest/u01/app/oracle/admin/CURSOxy/bdu
compatible10.2.0
control_files/u02/oradata/CURSOxy/control1.ctl
core_dump_dest/u01/app/oracle/admin/CURSOxy/cdu
db_block_size2048
db_cache_size0
db_nameCURSOxy
disk_asynch_ioTRUE
filesystemio_optionssetall
java_pool_size0
large_pool_size0
log_buffer2886656
log_checkpoint_interval0
log_checkpoint_timeout1800
max_dump_file_size10240
nls_languagespanish
nls_territoryspain
pga_aggregate_target10485760
processes30
remote_login_passwordfileEXCLUSIVE
sga_max_size83886080
sga_target75497472
shared_pool_size0
streams_pool_size0
undo_managementAUTO
undo_tablespaceundo_rbs
user_dump_dest/u01/app/oracle/admin/CURSOxy/udu

EndofReport

JuanLuisSerradillaAmarillayFranciscoFernndezMartnez

16

Anda mungkin juga menyukai