Vous êtes sur la page 1sur 11

27/04/2017 ARCHIVELOGSbastienMahieu

ARCHIVELOG
LemodeARCHIVELOG

Lorsqu'unebasededonnesOracleestenmodeARCHIVELOG,lestransactionsenregistresdanslesREDOLOGSsontarchivesdansdesfichiersARCn
(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
http://mahieus.noip.org/articles/print.php?id=158 1/11
27/04/2017 ARCHIVELOGSbastienMahieu


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

ActiverlemodeARCHIVELOGd'unebasededonnes

1resolution
Ilfauttoutd'abordarrterlabase:
Code:
sql>SHUTDOWN

OnnepeutpasmodifierlemodeARCHIVELOGenNOARCHIVELOGsilabasebesoind'unerestaurationmedia.

Ilfautensuitesauvegarderlabase.Eneffet,avantdefairedesmodificationsmajeuresdanslabase,ilfauttoujourslasauvegarderpourseprotgerpourdes
raisonsdescurit.

Editerlefichierd'initialisationpourajouterlesparamtresquispcifientladestinationdesarchives.

Dmarrerlabaseenmodemountsansl'ouvrir:
Code:
sql>STARTUPMOUNT

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

http://mahieus.noip.org/articles/print.php?id=158 2/11
27/04/2017 ARCHIVELOGSbastienMahieu

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,lesfichiersarchivesserontstocksdansla
flashrecoveryarea,danslerpertoire$SID/archivelog.
Code:
shutdownimmediate;
startupmount;
alterdatabasearchivelog;
alterdatabaseopen;

Afindevoirimmdiatementlersultat,onpeutfaire:
Code:
altersystemswitchlogfile

Afind'archiverleredologcourantetdepasserausuivant.

Dfinitionducheminoserontstocklesarchiveslogs:
Code:
http://mahieus.noip.org/articles/print.php?id=158 3/11
27/04/2017 ARCHIVELOGSbastienMahieu

LOG_ARCHIVE_DEST=C:\ORANT\DATABASE\ARCHIVE
LOG_ARCHIVE_FORMAT="ORCL%S.ARC"

Spcifieleformatdunomdesfichiersarchivs.Ici,lefichiercommenceparlemot"ORCL"pluslenumrodesquencedujournaletfiniparlemot".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
*****************************************
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;

http://mahieus.noip.org/articles/print.php?id=158 4/11
27/04/2017 ARCHIVELOGSbastienMahieu

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;

http://mahieus.noip.org/articles/print.php?id=158 5/11
27/04/2017 ARCHIVELOGSbastienMahieu

sql>shutdownimmediate;
sql>exit

c:\srvctlstartdatabasedbase

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

http://mahieus.noip.org/articles/print.php?id=158 6/11
27/04/2017 ARCHIVELOGSbastienMahieu

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'exploitationouaveclacommandesuivante,maisilfautqueRMAN
lesache:

Avantdesupprimerdesarchivelogs:
Code:
RMAN>deleteexpiredarchivelogall;

Suppressiondesarchivelogs:
Code:
RMAN>deleteforcearchivelogall;

EnmisejourRMAN:
Code:
RMAN>crosscheckarchivelogall;

Modifierlechemincibledesarchivelogs

Onpeutmodifierlerpertoireoserontstockslesarchiveslogs,pardfautl'emplacementestdfiniparleparamtredb_recovery_file_dest.
Sileparamtrearchive_log_destestdfini,ilfautsupprimerlavaleurcontenuedansdb_recovery_file_destetredmarrerlabase:
Code:
SQL>altersystemresetdb_recovery_file_destscope=spfile;
SQL>shutdownimmediate;

http://mahieus.noip.org/articles/print.php?id=158 7/11
27/04/2017 ARCHIVELOGSbastienMahieu

SQL>startup;

Code:
SQL>showparameterlog_archive_dest;

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.

http://mahieus.noip.org/articles/print.php?id=158 8/11
27/04/2017 ARCHIVELOGSbastienMahieu

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\

SQL>

Iciunseulemplacementdesfichiersarchivelogsestdfini.
Pourdfinirunsecondemplacement(multiplexage):

Code:

SQL>altersystemsetlog_archive_dest_2="LOCATION=h:\archivelogs\test\"scope=spfile;

Systmemodifi.

SQL>shutdownimmediate;

http://mahieus.noip.org/articles/print.php?id=158 9/11
27/04/2017 ARCHIVELOGSbastienMahieu

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

http://mahieus.noip.org/articles/print.php?id=158 10/11
27/04/2017 ARCHIVELOGSbastienMahieu

log_archive_dest_19string
log_archive_dest_2stringLOCATION=h:\archivelogs\test\

SQL>altersystemswitchlogfile;

Systmemodifi.

SQL>

Lesfichiersarchivelogssontdoncprsentssurles2emplacementsdfinisplushaut.
Celapermetd'avoirunescuritsupplmentairesurl'archivagedesfichiersd'unebasedeproduction.
Trssouventlesautresemplacementsd'archivelogmultiplexssontsurdessitesdistants.C'estunedespremirechosefairepourlamiseenplaced'unebase
desecours(DATAGUARD).Onpeuttoujoursrejouerlesarchiveslogsdansunebaseenstandbyouunebaserplique.

log_archive_dest_Xsontutilisspourplusde2emplacementsdiffrents.Adfautilestprfrabled'utiliserlog_archive_destetlog_archive_duplex_dest

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