Vous êtes sur la page 1sur 5

RenamingorMovingOracleFiles

ThisarticlepresentsabriefexplanationofhowassortedOraclefilescanberenamedormovedtoanewlocation.TheexamplesarebasedonadefaultOracle10g
installationonWindows,butthemethodisthesamefordifferentversionsofOracleonanyplatform,withtheexceptionofthehostcommandusedtorenamethe
file.
Controlfiles
Logfiles
Datafiles
OnlineMove(12c)
Manual
RMAN
RecreatingtheControlfile
DataGuardEnvironments
Relatedarticles.
OnlineDatafileMoveinOracleDatabase12cRelease1(12.1)

Controlfiles
ThecurrentlocationofthecontrolfilescanbequeriedfromtheV$CONTROLFILEview,asshownbelow.
SQL>selectnamefromv$controlfile;
NAME

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL01.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL02.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL03.CTL
3rowsselected.
SQL>
Inordertorenameormovethesefileswemustalterthevalueofthecontrol_filesinstanceparameter.
SQL>showparametercontrol_files
NAMETYPEVALUE

control_filesstringC:\ORACLE\ORADATA\DB10G\CONTRO
L01.CTL,C:\ORACLE\ORADATA\DB1
0G\CONTROL02.CTL,C:\ORACLE\OR
ADATA\DB10G\CONTROL03.CTL
SQL>
Tomoveorrenameacontrolfiledothefollowing.
Alterthecontrol_filesparameterusingtheALTERSYSTEMcomamnd.
Shutdownthedatabase.
RenamethephysicalfileontheOS.
Startthedatabase.
ThefollowingSQL*Plusoutputshowshowthisisdoneforaninstanceusinganspfile.Forinstancesusingapfilereplacethespfilemanipulationstepswithan
amendmentoftheparameterintheinit.orafile.
SQL>ALTERSYSTEMSETcontrol_files='C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_CONTROL01.CTL',
>'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL02.CTL',
>'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL03.CTL'SCOPE=SPFILE;
Systemaltered.
SQL>SHUTDOWNIMMEDIATE
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>HOSTMOVEC:\ORACLE\ORADATA\DB10G\CONTROL01.CTLC:\ORACLE\ORADATA\DB10G\RENAME_CONTROL01.CTL
SQL>STARTUP
ORACLEinstancestarted.
TotalSystemGlobalArea167772160bytes
FixedSize787968bytes
VariableSize61864448bytes
DatabaseBuffers104857600bytes
RedoBuffers262144bytes

Databasemounted.
SQL>
Repeatingtheinitialqueryshowsthatthethecontrolfilehasbeenrenamedinthedatadictionary.
SQL>selectnamefromv$controlfile;
NAME

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_CONTROL01.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL02.CTL
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\CONTROL03.CTL
3rowsselected.
SQL>

Logfiles
ThecurrentlocationofthelogfilescanbequeriedfromtheV$LOGFILEview,asshownbelow.
SQL>SELECTmemberFROMv$logfile;
MEMBER

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO03.LOG
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO02.LOG
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO01.LOG
3rowsselected.
SQL>
Tomoveorrenamealogfiledothefollowing.
Shutdownthedatabase.
RenamethephysicalfileontheOS.
Startthedatabaseinmountmode.
IssuetheALTERDATABASERENAMEFILEcommandtorenamethefilewithintheOracledictionary.
Openthedatabase.
ThefollowingSQL*Plusoutputshowshowthisisdone.
SQL>SHUTDOWNIMMEDIATE
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>HOSTMOVEC:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO01.LOGC:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_REDO01.LOG
SQL>STARTUPMOUNT
ORACLEinstancestarted.
TotalSystemGlobalArea167772160bytes
FixedSize787968bytes
VariableSize61864448bytes
DatabaseBuffers104857600bytes
RedoBuffers262144bytes
Databasemounted.
SQL>ALTERDATABASERENAMEFILE'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO01.LOG'
>TO'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_REDO01.LOG';
Databasealtered.
SQL>ALTERDATABASEOPEN;
Databasealtered.
SQL>
Repeatingtheinitialqueryshowsthatthethelogfilehasbeenrenamedinthedatadictionary.
SQL>SELECTmemberFROMv$logfile;
MEMBER

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO03.LOG

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\REDO02.LOG
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_REDO01.LOG
3rowsselected.
SQL>

Datafiles
OnlineMove(12c)
Oracle12cincludestheALTERDATABASEMOVEDATAFILEcommand,whichperformsanonlinemoveofadatafile.
SQL>ALTERDATABASEMOVEDATAFILE'/u01/app/oracle/oradata/cdb1/system01.dbf'TO'/tmp/system01.dbf';
Databasealtered.
SQL>

Manual
Theprocessformanuallyrenamingadatafileisthesameasrenamingalogfile,butforthesameofclarityitisrepeatedbelow.Thecurrentlocationofthedatafiles
canbequeriedfromtheV$DATAFILEview,asshownbelow.
SQL>SELECTnameFROMv$datafile;
NAME

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSTEM01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\UNDOTBS01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSAUX01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\USERS01.DBF
4rowsselected.
SQL>
Tomoveorrenameadatafiledothefollowing.
Shutdownthedatabase.
RenamethephysicalfileontheOS.
Startthedatabaseinmountmode.
IssuetheALTERDATABASERENAMEFILEcommandtorenamethefilewithintheOracledictionary.
Openthedatabase.
ThefollowingSQL*Plusoutputshowshowthisisdone.
SQL>SHUTDOWNIMMEDIATE
Databaseclosed.
Databasedismounted.
ORACLEinstanceshutdown.
SQL>HOSTMOVEC:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\USERS01.DBFC:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_USERS01.DBF
SQL>STARTUPMOUNT
ORACLEinstancestarted.
TotalSystemGlobalArea167772160bytes
FixedSize787968bytes
VariableSize61864448bytes
DatabaseBuffers104857600bytes
RedoBuffers262144bytes
Databasemounted.
SQL>ALTERDATABASERENAMEFILE'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\USERS01.DBF'
>TO'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_USERS01.DBF';
Databasealtered.
SQL>ALTERDATABASEOPEN;
Databasealtered.
SQL>
Repeatingtheinitialqueryshowsthatthethedatafilehasbeenrenamedinthedatadictionary.
SQL>SELECTnameFROMv$datafile;

NAME

C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSTEM01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\UNDOTBS01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\SYSAUX01.DBF
C:\ORACLE\PRODUCT\10.1.0\ORADATA\DB10G\RENAME_USERS01.DBF
4rowsselected.
SQL>

RMAN
RMANcanbeusedtomovefileswithlessdowntimebycopyingtheminadvanceofthemove,thenrecoveringthemaspartofthemoveitself.First,loginto
RMANandlistthecurrentfiles.
RMAN>REPORTSCHEMA;
Reportofdatabaseschemafordatabasewithdb_unique_nameDB11G
ListofPermanentDatafiles
===========================
FileSize(MB)TablespaceRBsegsDatafileName

1750SYSTEM***/u01/app/oracle/oradata/DB11G/system01.dbf
21150SYSAUX***/u01/app/oracle/oradata/DB11G/sysaux01.dbf
3444UNDOTBS1***/u01/app/oracle/oradata/DB11G/undotbs01.dbf
4120USERS***/u01/app/oracle/oradata/DB11G/users01.dbf
5345EXAMPLE***/u01/app/oracle/oradata/DB11G/example01.dbf
83277SOE***/u01/app/oracle/product/11.2.0.2/db_1/dbs/soe.dbf
ListofTemporaryFiles
=======================
FileSize(MB)TablespaceMaxsize(MB)TempfileName

1370TEMP32767/u01/app/oracle/oradata/DB11G/temp01.dbf
RMAN>
Copythefile(s)tothenewlocation.
RMAN>COPYDATAFILE8TO'/u01/app/oracle/oradata/DB11G/soe.dbf';
Turnthetablespacetooffline.Wecouldhaveturnedthetablespaceofflinebeforethecopy,removingtheneedforarecovery,butthetablespacewouldhavebeen
offlinelongerusingthatmethod.
RMAN>SQL'ALTERTABLESPACEsoeOFFLINE';
Switchtothenewdatafilecopy(s)andrecoverthetablespace.
RMAN>SWITCHDATAFILE8TOCOPY;
RMAN>RECOVERTABLESPACEsoe;
Turnthetablespaceonlineagain.
RMAN>SQL'ALTERTABLESPACEsoeONLINE';
Removetheolddatafile(s).
RMAN>HOST'rm/u01/app/oracle/product/11.2.0.2/db_1/dbs/soe.dbf';
Listingthecurrentfilesshowsthemoveiscomplete.
RMAN>REPORTSCHEMA;
Reportofdatabaseschemafordatabasewithdb_unique_nameDB11G
ListofPermanentDatafiles
===========================
FileSize(MB)TablespaceRBsegsDatafileName

1750SYSTEM***/u01/app/oracle/oradata/DB11G/system01.dbf

21150SYSAUX***/u01/app/oracle/oradata/DB11G/sysaux01.dbf
3444UNDOTBS1***/u01/app/oracle/oradata/DB11G/undotbs01.dbf
4120USERS***/u01/app/oracle/oradata/DB11G/users01.dbf
5345EXAMPLE***/u01/app/oracle/oradata/DB11G/example01.dbf
83277SOE***/u01/app/oracle/oradata/DB11G/soe.dbf
ListofTemporaryFiles
=======================
FileSize(MB)TablespaceMaxsize(MB)TempfileName

1370TEMP32767/u01/app/oracle/oradata/DB11G/temp01.dbf
RMAN>
MovingtheSYSTEMtablespaceispossibleusingasimilarmethod,butthedatabasemustbeshutdownandmountedbeforetheswitchandrecovercanbedone.

RecreatingtheControlfile
Forlargescalerearrangementsitmaybeeasiertomanipulatethecontrolfilecontentsmanuallybybackingupthecontrolfiletotrace.
SQL>CONNsys/passwordASSYSDBA
Connected.
SQL>ALTERDATABASEBACKUPCONTROLFILETOTRACE;
Databasealtered.
SQL>
Theresultingtracefileintheuser_dump_destdirectorycontainscommandsandinstructionsforrecreatingthecontrolfile.ThepathsintheCREATE
CONTROLFILEcommandcanbemanipulatedtorenamealldatafilesandlogfilesononestep.
Thisisquiteadrasticstepanditmayaffecttheusefulnessofexistingbackups,especiallyifthecontrolfileisbeingusedastherecoverycatlog.

DataGuardEnvironments
InDataGuardenvironmentsyouhavetobecarefulaboutrenamingandmovingfiles.TheSTANDBY_FILE_MANAGEMENTparameterdetermineshowfile
changesontheprimaryserverareappliedtothestandbyserver.WhensettoAUTO,filesaddedordeletedundernormaldatabaseusewillbeautomatically
createdordeletedonthestandbyserver.WhensettoMANUAL,thisautomaticmaintenancewillnothappen.
IfyouaremanuallymovingorrenamingfilesinaDataGuardenvironmentwhereSTANDBY_FILE_MANAGEMENT=AUTO,youshouldfirst
setSTANDBY_FILE_MANAGEMENT=MANUAL,makeyourchangesintheprimaryandstandbyenvironment,thensetSTANDBY_FILE_MANAGEMENT=AUTOagain.
Formoreinformationsee:
ALTERDATABASE
ALTERSYSTEM
HowtoRenameorMoveDatafilesandLogfiles[ID115424.1]
OnlineDatafileMoveinOracleDatabase12cRelease1(12.1)
Hopethishelps.RegardsTim...
BacktotheTop.

Vous aimerez peut-être aussi