Sei sulla pagina 1di 6

4/14/2016

Document1578787.1

12cDataguardSwitchoverBestPracticesusingSQLPLUS(DocID1578787.1)
InthisDocument
Goal

***ReviewedforRelevance16Jul2015***

ThisDocumentdescribsstepbystepmethodtoperformswitchoveronPhysicalStandbyEnvironmentusing
SQLPLUS.

Solution

I.PreSwitchovercheck

Verifythatthetargetstandbyisreadyforswitchover.

ChecksORLstatusontargetstandby.

Whattodo?

VerifyPrimaryandStandbytempfilesmatch

NOTE:FormultipleStandbyenvironmentmakesureallthestandbyinSYNCwithprimary.

IISWITCHOVER

Enabletracingonbothprimaryandstandbytodiagnoseincaseofanyissue.

TailAlertLogs(optional)onallinstances

Switchoverthestandbydatabasetoaprimary

Openthenewprimarydatabase

Restartthenewstandby

III.PostSwitchoverSteps

SetTracetoPriorValue

Verifythatthenewprimaryshippinglogstostandbyandstandbyisapplying.

APPLIESTO:
OracleDatabaseEnterpriseEditionVersion12.1.0.1to12.1.0.2[Release12.1]
Informationinthisdocumentappliestoanyplatform.

GOAL
***ReviewedforRelevance16Jul2015***
ThisDocumentdescribsstepbystepmethodtoperformswitchoveronPhysicalStandbyEnvironment
usingSQLPLUS.

SOLUTION

I.PreSwitchovercheck
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=4luwbnkd6_143&id=1578787.1

1/6

4/14/2016

Document1578787.1

Verifythatthetargetstandbyisreadyforswitchover.
VerifythatthetargetstandbyissynchronouswithprimaryandRedoshippingworkingfinefromprimary.
SQL>alterdatabaseswitchoverto<targetstandbydb_unique_name>verify
Theabovecommandwillverifyfollowingthings,
a.Verifiesthatthereleaseversionisminimum12.1
b.PrimaryREDOshipping.
c.StandbyMRPrecoveryrunninganditssynchronouswithprimary,elseitwillthroughbelowerrorinSQLPROMPTand
alertlogaswell.
Forexample,

SQL>alterdatabaseswitchovertochicagoverify
ORA16470:RedoApplyisnotrunningonswitchovertarget

Primaryalertlog
SQL>alterdatabaseswitchovertochicagoverify
ORA16470signaledduring:alterdatabaseswitchovertochicagoverify...

ChecksORLstatusontargetstandby.
Ifitisdirtythenitwillthoughthewarningmessageslike

SQL>alterdatabaseswitchovertochicagoverify
ERRORatline1:
ORA16475:succeededwithwarnings,checkalertlogformoredetails

PrimaryAlertlog
SWITCHOVERVERIFYWARNING:switchovertargethasdirtyonlineredologfilesthatrequireclearing.
Ittakestimetoclearonlineredologfiles.Thismayslowdownswitchoverprocess.

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=4luwbnkd6_143&id=1578787.1

2/6

4/14/2016

Document1578787.1

Whattodo?
Makesurelog_file_name_convertsetproperlyontargetstandby.
SQL>showparameterlog_file_name_convert
NOTE:Ifnotsetsetthevalueforexampleifdirectorystructurechangingonlyindb_uniquq_name.forexample,
PrimaryORLlocationis/oradata/boston/<>
Standbylogfilelocationis/oradata/chicago/logfiles>
Settheparameterlike,
altersystemsetLOG_FILE_NAME_CONVERT=boston,chicagoscope=spfile
NOTE:RestartthestandbyandstarttheMRP.WhenyourestartstandbyandstartMRPthenitclearsalltheORLs
atstandbyprovidedlog_file_name_convertsetproperly.
IfStandbyissynchronouswithprimary,wewillgetbelowmessages,

SQL>alterdatabaseswitchovertochicagoverify
Databasealtered.

PrimaryAlertlog
SWITCHOVERVERIFY:SendVERIFYrequesttoswitchovertargetCHICAGO
SWITCHOVERVERIFYCOMPLETE
Completed:alterdatabaseswitchovertochicagoverify

VerifyPrimaryandStandbytempfilesmatch
Tempfilescreatedafterstandbycreationwillnotbepropagatedtostandby.ChecktheTEMPfilesusingbelowquery
andaddnewTEMPfilesatstandbyisrequired.
SQL>colnamefora45
SQL>selectts#,name,ts#,statusfromv$tempfile

NOTE:FormultipleStandbyenvironmentmakesureallthestandbyinSYNCwithprimary.

IISWITCHOVER
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=4luwbnkd6_143&id=1578787.1

3/6

4/14/2016

Document1578787.1

Enabletracingonbothprimaryandstandbytodiagnoseincaseofanyissue.
SQL>altersystemsetlog_archive_trace=8191sid=*
TailAlertLogs(optional)onallinstances
@primaryandstandby,
SQL>showparameterbackground_dump_dest
$tail600fbackground_dump_dest/alert*

*NOTE:InRACenvironmentnoneedtoshutdownallinstancesapartfromoneinstanc.Switchover(SQLPLUS)
comanditselfshutdownallthenodes.

Switchoverthestandbydatabasetoaprimary
PrimaryBoston,
SQL>alterdatabaseswitchovertochicago
Databasealtered.
.
Sampleoutputfromprimary(BOSTON)andstandby(CHICAGO),
PrimaryAlertlog"alert_boston.log"

FriAug2311:05:232013
ALTERSYSTEMSETlog_archive_trace=8191SCOPE=BOTH
alterdatabaseswitchovertochicago
FriAug2311:05:432013
Startingswitchover[ProcessID:3340]
FriAug2311:05:432013
ALTERDATABASECOMMITTOSWITCHOVERTOPHYSICALSTANDBY[ProcessId:3340](boston)
.
FriAug2311:05:442013
Active,synchronizedPhysicalStandbyswitchovertargethasbeenidentified
PreventingupdatesandqueriesatthePrimary
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=4luwbnkd6_143&id=1578787.1

4/6

4/14/2016

Document1578787.1

Generatingandshippingfinallogstotargetstandby
SwitchoverEndOfRedoLogthread1sequence11hasbeenfixed<Sequence11isEndOfRedo
Switchover:PrimaryhighestseenSCNsetto0x0.0x229306
ARCH:Noswitcharchivalofthread1,sequence11
.
Switchover:Primarycontrolfileconvertedtostandbycontrolfilesuccesfully.
Switchover:CompleteDatabaseshutdownrequired
Sendingrequest(converttoprimarydatabase)toswitchovertargetCHICAGO
OCISessionBeginwithPasswordVerifiersucceeded
Switchovercomplete.Databaseshutdownrequired
USER(ospid:3340):terminatingtheinstance
FriAug2311:05:512013
InstanceterminatedbyUSER,pid=3340
Completed:alterdatabaseswitchovertochicago

alertlog"alert_chicago.log"

FriAug2311:05:472013
SWITCHOVER:receivedrequest'ALTERDATABASECOMMITTOSWITCHOVERTOPRIMARY'fromprimary
database.
FriAug2311:05:472013
ALTERDATABASESWITCHOVERTOPRIMARY(chicago)
Maximumwaitforroletransitionis15minutes.
.
StandbybecameprimarySCN:2265860
Switchover:CompleteDatabasemountedasprimary
SWITCHOVER:completedrequestfromprimarydatabase.

NOTE:Atstandbysidewewaitonlyfor15minutesforthestandbytosynchronouswithprimary.
Openthenewprimarydatabase
https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=4luwbnkd6_143&id=1578787.1

5/6

4/14/2016

Document1578787.1

SQL>alterdatabaseopen
Restartthenewstandby
SQL>shutabort
SQL>startup
SQL>alterdatabaserecovermanagedstandbydatabasedisconnect

III.PostSwitchoverSteps
SetTracetoPriorValue
SQL>altersystemsetlog_archive_trace=0
Systemaltered.
Verifythatthenewprimaryshippinglogstostandbyandstandbyisapplying.
@primary,
SQL>altersystemswitchlogfile
SQL>selectdest_id,error,statusfromv$archive_destwheredest_id=<yourremote
log_archive_dest_<n>>
SQL>selectmax(sequence#),thread#fromv$log_historygroupbythread#
Ifremotelog_Archive_destinationis2i.elog_archive_dest_2.
SQL>selectmax(sequence#)fromv$archived_logwhereapplied='YES'and
dest_id=2;

@standby,
SQL>selectprocess,sequence#,thread#,statusfromv$managed_standby
SQL>selectmax(sequence#),thread#fromv$archived_loggroupbythread#

Usegv$managed_standbyforRAC.
Didn'tfindwhatyouarelookingfor?

https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=4luwbnkd6_143&id=1578787.1

6/6