您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > Oracle 10 Dataguard升级步骤
一、升级之前先备份好主备库数据,建议停止服务后对主备库做一个冷备份二、按以下步骤进行升级:1在B机上,sqlplus/assysdbarecovermanagedstandbydatabasecancel;shutdownimmediate;exitlsnrctlstopemctlstopdbconsolecd/opt/Disk1./runInstall–ignoresysprereqs执行root.sh结束patch2修改spfile的compatible参数,将10.2.0.1.0改为10.2.0.4.0lsnrctlstartsqlplus/assysdbastartupnomount;altersystemsetcompatible='10.2.0.4.0'scope=spfilealterdatabasemountstandbydatabase;alterdatabaserecovermanagedstandbydatabasedisconnectfromsession;3.验证主备库同步3.1检查归档目录是否有误SQLselecterrorfromv$archive_dest;ERROR-----------------------------------------------------------------10rowsselected.SQL正常,没有错误。3.2在主库(A机)手工切换归档SQLaltersystemswitchlogfile;Systemaltered.SQL3.3查看主库(A机)归档情况SQLselectmax(sequence#)fromv$archived_log;MAX(SEQUENCE#)--------------21SQL3.4查看备库归档(B机)情况SQLselectsequence#,appliedfromv$archived_log;SEQUENCE#APP-------------2YES3YES4YES5YES6YES7YES8YES9YES10YES11YES12YESSEQUENCE#APP-------------13YES14YES15YES16YES17YES18YES19YES20YES21YES20rowsselected.主备一致,同步正常。4.确认standby同步没有问题后,将A机和B机做一个switchovers4.1.查看主库(A机)switchover状态SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOSTANDBY附:A:switchover_status出现sessionactive/notallowed当出现sessionactive的时候表示还有活动的session,则运行Alterdatabasecommittoswitchovertophysicalstandbywithsessionshutdown;当出现notallowed时,在官方文档说转换会不成功,但是我测试的时候成功了。B.ora-01153:anincompatiblemediarecoveryisactive运行下面代码Alterdatabaserecovermanagedstandbydatabasefinish;或者Alterdatabaserecovermanagedstandbydatabasefinishforce;Alterdatabaserecovermanagedstandbydatabasedisconnectfromsession;4.2将主库(A机)切换成备库SQLALTERDATABASECOMMITTOSWITCHOVERTOPHYSICALSTANDBY;或者SQLAlterdatabasecommittoswitchovertophysicalstandbywithsessionshutdown;4.3查看备库(B机)switchover状态SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOPRIMARY附:若不是,用此语句切换:ALTERDATABASECOMMITTOSWITCHOVERTOPRIMARYwithsessionshutdown补充:若出现:ORA-16139:mediarecoveryrequired是因为没有执行:alterdatabaserecovermanagedstandbydatabasedisconnectfromsession;4.4将备库(B机)切换成主库,然后关闭SQLALTERDATABASECOMMITTOSWITCHOVERTOPRIMARY;或SQLALTERDATABASECOMMITTOSWITCHOVERTOPRIMARYwithsessionshutdown;SQLshutdownimmediate;5.开始对B机升级sqlplus'/assysdba'SQLstartupupgrade;---以upgrade方式打开数据库,否则无法打开实例SQL@$ORACLE_HOME/rdbms/admin/catupgrd.sqlSQLshutdownimmediateSQLstartup;SQLselectcount(1)fromdba_objectswherestatus='INVALID';5.1、编译无效对象SQL@?/rdbms/admin/utlrp.sql5.2、再执行下面过程:declarethreadspls_integer:=&&1;beginutl_recomp.recomp_parallel(threads);end;验证一下:SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOSTANDBY这个时候,B机的数据库就切换为primary数据库了。(可以把应用切换到这台服务器上了).6.升级A机在A机上:sqlplus/assysdbashutdownimmediateexitlsnrctlstopemctlstopdbconsolecd/opt/Disk1./runInstall–ignoresysprereq执行root.sh结束patch7.由于A机此时在standby状态,需切换回PRIMARY状态才能完成升级,这需要B机先切回备库,A机才可以切回主库7.1首先,A机启动到recovermanagedstandby状态:lsnrctlstartsqlplus/assysdbastartupnomount;altersystemsetcompatible='10.2.0.4.0'scope=spfilealterdatabasemountstandbydatabase;alterdatabaserecovermanagedstandbydatabasedisconnectfromsession;7.2在B机上:SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOSTANDBYlsnrctlstartSQLALTERDATABASECOMMITTOSWITCHOVERTOPHYSICALSTANDBY;或者SQLAlterdatabasecommittoswitchovertophysicalstandbywithsessionshutdown;检查一下:SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOPRIMARY7.3在A机上:SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOPRIMARYSQLALTERDATABASECOMMITTOSWITCHOVERTOPRIMARY;或SQLALTERDATABASECOMMITTOSWITCHOVERTOPRIMARYwithsessionshutdown;SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOSTANDBY8.开始升级A机sqlplus'/assysdba'SQLstartupupgrade;---以upgrade方式打开数据库,否则无法打开实例SQL@$ORACLE_HOME/rdbms/admin/catupgrd.sqlSQLshutdownimmediateSQLstartup;SQLselectcount(1)fromdba_objectswherestatus='INVALID';8.1编译无效对象SQL@?/rdbms/admin/utlrp.sql8.2再执行下面过程:SQLdeclarethreadspls_integer:=&&1;beginutl_recomp.recomp_parallel(threads);end;最后验证一下:SQLSELECTSWITCHOVER_STATUSFROMV$DATABASE;SWITCHOVER_STATUS--------------------TOSTANDBY表明A机已切换回primary数据库了。回到第3验证同步。
本文标题:Oracle 10 Dataguard升级步骤
链接地址:https://www.777doc.com/doc-3883726 .html