Sie sind auf Seite 1von 7

5/1/2015

ARCHIVELOGSbastienMahieu

ARCHIVELOG
LemodeARCHIVELOG
Lorsqu'unebasededonnesOracleestenmodeARCHIVELOG,lestransactionsenregistresdanslesREDOLOGSsont
archivesdansdesfichiersARCn(Archivelog)chaquefoisquelefichiersREDOLOGencoursestplein.
LemodeARCHIVELOGpermetunerestaurationplussredelabasededonnes.
SavoirsiunebasededonnesestenmodeARCHIVELOG
Code:
connectsysassysdba
SQL>ARCHIVELOGLIST
modeDatabaselogmodeNoArchive
ArchivageautomatiqueDsactiv
Destinationdel'archiveUSE_DB_RECOVERY_FILE_DEST
Squencedejournalenlignelaplusancienne82
Squencedejournalcourante84

Code:
SELECTLOG_MODEFROMSYS.V$DATABASE;
LOG_MODE

NOARCHIVELOG

Connatrelevolumed'archiveloggnrparuneinstance
IlestimportantdemonitorerlesuividesarchiveLog,afindedtecterdesarchivestropimportantesparrapportl'activit.
Code:
SQL>SELECTTO_DATE(TO_CHAR(next_time,'dd/mm/yyyy'),'dd/mm/yyyy')Jour,ROUND(SUM(blocks*block_size/1024/1024))Mo
2FROMv$archived_log
3GROUPBYTO_DATE(TO_CHAR(next_time,'dd/mm/yyyy'),'dd/mm/yyyy')
4ORDERBY1DESC;
JOURMO

26SEP0648226
25SEP0625258
24SEP0620438
23SEP0631261
22SEP0617450
21SEP0618811
20SEP0630778
19SEP0636108
18SEP0690508
17SEP0631568
16SEP0650283

ActiverlemodeARCHIVELOGd'unebasededonnes
1resolution
Ilfauttoutd'abordarrterlabase:
Code:
sql>SHUTDOWN

OnnepeutpasmodifierlemodeARCHIVELOGenNOARCHIVELOGsilabasebesoind'unerestaurationmedia.
Ilfautensuitesauvegarderlabase.Eneffet,avantdefairedesmodificationsmajeuresdanslabase,ilfauttoujoursla
sauvegarderpourseprotgerpourdesraisonsdescurit.
Editerlefichierd'initialisationpourajouterlesparamtresquispcifientladestinationdesarchives.
http://mahieus.noip.org/articles/print.php?id=158

1/7

5/1/2015

ARCHIVELOGSbastienMahieu

Dmarrerlabaseenmodemountsansl'ouvrir:
Code:
sql>STARTUPMOUNT

Modifierlemoded'archivageetouvrirlabase.
Code:
sql>ALTERSYSTEMSETLOG_ARCHIVE_DEST='LOCATION=f:\archivelogs\'scope=spfile;
sql>ALTERDATABASEARCHIVELOG;
sql>ALTERDATABASEOPEN;

Lechangementdumoded'archivagemettrajourslefichierdecontrleetrendralesanciennessauvegardesinutilisables.
Arrterlabase:
Code:
sql>SHUTDOWNIMMEDIATE

Sauvegardelabase.Enversion10g,iln'estpasncessairederenseignerleparamtred'initialisation:
Code:
LOG_ARCHIVE_START=TRUE

2mesolution
LemodeARCHIVELOGpermet,entreautres,lamiseenplacedebackupsRMANchaud(baseouverte).
Cemodepeuttreactivlorsdelacrationdelabase(dbca).
Danscetexemple,onprendlecasd'unebasecreenmodeNOARCHIVELOGqu'onmodifieensuite.
Depuislaversion10,lemodeARCHIVELOGdmarreautomatiquement2processusd'archivage:
arc0
arc1
Etapes
Dfiniruneflashrecoveryarea,sicen'estpasdjfait:Dfinird'abordlatailleetladestination
Onpeutdfinirlesparamtres:log_archive_formatetlog_archive_dest.Cen'estpasobligatoire.Sicen'estpasfait,les
fichiersarchivesserontstocksdanslaflashrecoveryarea,danslerpertoire$SID/archivelog.
Code:
shutdownimmediate;
startupmount;
alterdatabasearchivelog;
alterdatabaseopen;

Afindevoirimmdiatementlersultat,onpeutfaire:
Code:
altersystemswitchlogfile

Afind'archiverleredologcourantetdepasserausuivant.
Dfinitionducheminoserontstocklesarchiveslogs:
Code:
LOG_ARCHIVE_DEST=C:\ORANT\DATABASE\ARCHIVE
LOG_ARCHIVE_FORMAT="ORCL%S.ARC"

Spcifieleformatdunomdesfichiersarchivs.Ici,lefichiercommenceparlemot"ORCL"pluslenumrodesquencedu
journaletfiniparlemot".ARC".
Lesautresoptionssont:
%sou%S:lenumrodelasquenceenformatsimpleoulongueurfixe,rempliavecdeszros
%tou%T:lenumrodel'instancedanslecasd'unenvironnementOracleRAC,sinonest1
%d:l'identifiantdelabasededonnesilestutilisesilerpertoirestockelesarchivelogsdeplusieursbasededonns
%r:l'identifiantuniqued'unfichierdejournauxarchivspourdesincarnationsmultiplesdebasededonnes.
Exempledemanipulation
Code:
oracle@neeecleto:~>sourceenviron_es22_10203EE
*****************************************
http://mahieus.noip.org/articles/print.php?id=158

2/7

5/1/2015

ARCHIVELOGSbastienMahieu

ORACLE_HOME=/u01/app/oracle/product/10203EE
ORACLE_SID=es22
*****************************************
oracle@neeecleto:~>sqlplus"/assysdba"
SQL*Plus:Release10.2.0.3.0ProductiononLun.Aot2015:32:492007
Copyright(c)1982,2006,Oracle.AllRightsReserved.
Connect:
OracleDatabase10gEnterpriseEditionRelease10.2.0.3.0Production
WiththePartitioning,OLAPandDataMiningoptions
SQL>altersystemsetdb_recovery_file_dest_size=2Gscope=both;
Systmemodifi.
SQL>altersystemsetdb_recovery_file_dest='/safe/oraflash'scope=both;
Systmemodifi.
SQL>shutdownimmediate;
Basededonnesferme.
Basededonnesdmonte.
InstanceORACLEarrte.
SQL>startupmount;
InstanceORACLElance.
TotalSystemGlobalArea377487360bytes
FixedSize1261876bytes
VariableSize301993676bytes
DatabaseBuffers67108864bytes
RedoBuffers7122944bytes
Basededonnesmonte.
SQL>alterdatabasearchivelog;
Basededonnesmodifie.
SQL>alterdatabaseopen;
Basededonnesmodifie.

Casd'unebasededonnesencluster
Code:
c:\srvctlstopdatabasedbase
sqlplus/assysdba
sql>startupnomount;
sql>altersystemsetcluster_database=falsescope=spfile;
sql>shutdownimmediate;
sql>exit
c:\sqlplus/assysdba
sql>startupmount
sql>alterdatabasearchivelog;
sql>altersystemsetcluster_database=truescope=spfile;
sql>shutdownimmediate;
sql>exit
c:\srvctlstartdatabasedbase

http://mahieus.noip.org/articles/print.php?id=158

3/7

5/1/2015

ARCHIVELOGSbastienMahieu

PurgerdesarchivelogavecRMAN
Danslescriptsuivant,nousallonssupprimersurdisqueslesarchivelogsuprieure7jours.
FichierPurge.bat
Code:
RMANtargetsys/mdp@dbtestCMDFILE=F:\Script\purge.txtLOG"F:\Script\log\purge.log"
EXIT

FichierPurge.txt
Code:
deletenopromptforcearchiveloguntiltime='sysdate7';

FichierPurge.log
Code:
RecoveryManager:Release10.2.0.1.0ProductiononFriSep1001:00:002010
Copyright(c)1982,2005,Oracle.Allrightsreserved.
connectedtotargetdatabase:DBTEST(DBID=884319214)
RMAN>deletenopromptforcearchiveloguntiltime='sysdate7';
usingtargetdatabasecontrolfileinsteadofrecoverycatalog
allocatedchannel:ORA_DISK_1
channelORA_DISK_1:sid=304devtype=DISK
deletedarchivelog
archivelogfilename=F:\FLASH_RECOVERY_AREA\DBTEST\ARC23220_0688751409.001
deletedarchivelog
archivelogfilename=F:\FLASH_RECOVERY_AREA\DBTEST\ARC23221_0688751409.001
deletedarchivelog
archivelogfilename=F:\FLASH_RECOVERY_AREA\DBTEST\ARC23222_0688751409.001
deletedarchivelog
archivelogfilename=F:\FLASH_RECOVERY_AREA\DBTEST\ARC23223_0688751409.001
deletedarchivelog
archivelogfilename=F:\FLASH_RECOVERY_AREA\DBTEST\ARC23224_0688751409.001
deletedarchivelog
archivelogfilename=F:\FLASH_RECOVERY_AREA\DBTEST\ARC23225_0688751409.001
deletedarchivelog
archivelogfilename=F:\FLASH_RECOVERY_AREA\DBTEST\ARC23226_0688751409.001
Deleted7objects
RecoveryManagercomplete.

Onpeutfairedumnageenpassantparlasuppressiondesarchivelogsdepuislesystmed'exploitation,maisilfautqueRMAN
lesache:
Avantdesupprimerdesarchivelogs:
Code:
RMAN>deleteexpiredarchivelogall;

Suppressiondesarchivelogs,etensuite:
Code:
RMAN>crosscheckarchivelogall;

Modifierlechemincibledesarchivelogs
Onpeutmodifierlerpertoireoserontstockslesarchiveslogs:
Code:
SQL>showparameterlog_archive_dest;
http://mahieus.noip.org/articles/print.php?id=158

4/7

5/1/2015

ARCHIVELOGSbastienMahieu

NAMETYPEVALUE

db_recovery_file_deststringG:\archivelogs
db_recovery_file_dest_sizebiginteger4G
SQL>
SQL>altersystemsetlog_archive_dest_1="LOCATION=g:\archivelogs\test\"scope=spfile;
Systmemodifi.
SQL>shutdownimmediate;
Basededonnesferme.
Basededonnesdmonte.
InstanceORACLEarrte.
SQL>quit
c:\setoracle_sid=TEST
c:\sqlplus/assysdba
SQL*Plus:Release11.2.0.1.0ProductiononMer.Mars2021:50:072013
Copyright(c)1982,2010,Oracle.Allrightsreserved.
Connectuneinstanceinactive.
SQL>startup
InstanceORACLElance.
TotalSystemGlobalArea1737031680bytes
FixedSize2176488bytes
VariableSize1073744408bytes
DatabaseBuffers654311424bytes
RedoBuffers6799360bytes
Basededonnesmonte.
Basededonnesouverte.
SQL>
SQL>showparameterdb_recovery_file_dest;
NAMETYPEVALUE

db_recovery_file_deststringG:\archivelogs\test\
db_recovery_file_dest_sizebiginteger4G
SQL>
Lecheminabientmodifi.

MultiplexagedesfichiersARCHIVELOGS
Onpeutmultiplexerlesfichiersd'archivelogssurdiffrentsemplacementsdisques.
Leparamtremodifierestlog_archive_dest_X.
Code:
SQL>showparameterlog_archive_dest_1;
NAMETYPEVALUE

log_archive_dest_1stringLOCATION=g:\archivelogs\test\
log_archive_dest_10string
log_archive_dest_11string
log_archive_dest_12string
log_archive_dest_13string
log_archive_dest_14string
log_archive_dest_15string
log_archive_dest_16string
http://mahieus.noip.org/articles/print.php?id=158

5/7

5/1/2015

ARCHIVELOGSbastienMahieu

log_archive_dest_17string
log_archive_dest_18string
log_archive_dest_19string
SQL>

Iciunseulemplacementdesfichiersarchivelogsestdfini.
Pourdfinirunsecondemplacement(multiplexage):
Code:
SQL>altersystemsetlog_archive_dest_2="LOCATION=h:\archivelogs\test\"scope=spfile;
Systmemodifi.
SQL>shutdownimmediate;
Basededonnesferme.
Basededonnesdmonte.
InstanceORACLEarrte.
SQL>quit
c:\setoracle_sid=TEST
c:\sqlplus/assysdba
SQL*Plus:Release11.2.0.1.0ProductiononMer.Mars2021:50:072013
Copyright(c)1982,2010,Oracle.Allrightsreserved.
Connectuneinstanceinactive.
SQL>startup
InstanceORACLElance.
TotalSystemGlobalArea1737031680bytes
FixedSize2176488bytes
VariableSize1073744408bytes
DatabaseBuffers654311424bytes
RedoBuffers6799360bytes
Basededonnesmonte.
Basededonnesouverte.
SQL>
SQL>showparameterlog_archive_dest_;
NAMETYPEVALUE

log_archive_dest_1stringLOCATION=g:\archivelogs\test\
log_archive_dest_10string
log_archive_dest_11string
log_archive_dest_12string
log_archive_dest_13string
log_archive_dest_14string
log_archive_dest_15string
log_archive_dest_16string
log_archive_dest_17string
log_archive_dest_18string
log_archive_dest_19string
log_archive_dest_2stringLOCATION=h:\archivelogs\test\
SQL>altersystemswitchlogfile;
Systmemodifi.
SQL>

Lesfichiersarchivelogssontdoncprsentssurles2emplacementsdfinisplushaut.
Celapermetd'avoirunescuritsupplmentairesurl'archivagedesfichiersd'unebasedeproduction.
Trssouventlesautresemplacementsd'archivelogmultiplexssontsurdessitesdistants.C'estunedespremirechosefaire
pourlamiseenplaced'unebasedesecours(DATAGUARD).Onpeuttoujoursrejouerlesarchiveslogsdansunebaseen
http://mahieus.noip.org/articles/print.php?id=158

6/7

5/1/2015

ARCHIVELOGSbastienMahieu

standbyouunebaserplique.

http://mahieus.noip.org/articles/print.php?id=158

7/7