关闭

关闭

关闭

封号提示

内容

首页 ORACLE10G_DATAGUARD.pdf

ORACLE10G_DATAGUARD.pdf

ORACLE10G_DATAGUARD.pdf

上传者: heweilo 2012-07-17 评分 0 0 0 0 0 0 暂无简介 简介 举报

简介:本文档为《ORACLE10G_DATAGUARDpdf》,可适用于IT/计算机领域,主题内容包含OraclegDATAGUARD安装配置维护LINUX操作系统的安装和配置DataGuard安装环境DataGuard物理Standby之创建MAX符等。

OraclegDATAGUARD安装配置维护LINUX操作系统的安装和配置DataGuard安装环境DataGuard物理Standby之创建MAXIMIZEPERFORMANCE和MAXIMIZEPROTECTION模式转换主库和备库的switchover配置DATAGUARD维护LINUX操作系统的安装和配置RedHatEnterpriseLinux(RHEL)所需内核:EL或更高版本验证内核版本:#unamerel#SMPMonMar::EDTxxxGNULinux其他所需程序包的版本(或更高版本):makeelgccelcompatdb验证已安装的程序包:#rpmqmakegcccompatdbmakeelgccelcompatdbRedHatEnterpriseLinux(RHEL)所需内核:EL或更高版本验证内核版本:#unamerel#SMPMonMar::EDTxxxGNULinux其他所需程序包的版本(或更高版本):makebinutilsmakeelgccelcompatdbcompatgcccompatgccccompatlibstdccompatlibstdcdevelopenmotifsetarch验证已安装的程序包:#rpmqmakebinutilsgcccompatdbcompatgcccompatgccccompatlibstdccompatlibstdcdevelopenmotifsetarchmakeelbinutilselgccelcompatgcccompatgccccompatlibstdccompatlibstdcdevelopenmotifsetarch所需内核:e或更高版本验证内核版本:#unameresmp其他所需程序包的版本(或更高版本):gccmakebinutilsopenmotifglibc验证已安装的程序包:#rpmqgccmakebinutilsopenmotifglibcgccmakebinutilsopenmotifglibc所需程序包集:基本运行时系统YaST图形基本系统Linux工具KDE桌面环境CC编译器和工具(默认情况下未选择)其他所需程序包的版本(或更高版本):makebinutilsgccopenmotifDataGuard安装环境OS:RHLu(位)ORACLEGIP:(primary)(standby)ORACLESID:lotteryORACLEHOME:optoracleproductDataGuard物理Standby之创建设置主库为forceloggingSQL>alterdatabaseforcelogging设置主库为归档模式:SQL>archiveloglistSQL>shutdownimmediateSQL>startupmountSQL>alterdatabasearchivelogSQL>archiveloglist检查主机是否有口令文件,如没有需建立orapwdfile='optoracleproductdbsorawdlotteryora'password=sysentries=为主数据库添加"备用联机日志文件"SQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizemSQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizemSQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizemSQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizem修改主库参数文件SQL>createpfile='optoracleadminlotterypfileinitora'fromspfilelotterydbcachesize=lotteryjavapoolsize=lotterylargepoolsize=lotterysharedpoolsize=lotterystreamspoolsize=*auditfiledest='optoracleadminlotteryadump'*backgrounddumpdest='optoracleadminlotterybdump'*compatible=''*controlfiles='optoracleoradatalotterycontrolctl','optoracleoradatalotterycontrolctl','optoracleoradatalotterycontrolctl'*coredumpdest='optoracleadminlotterycdump'*dbblocksize=*dbdomain=''*dbfilemultiblockreadcount=*dbname='lottery'*dbrecoveryfiledest='optoracleflashrecoveryarea'*dbrecoveryfiledestsize=*dispatchers='(PROTOCOL=TCP)(SERVICE=lotteryXDB)'*jobqueueprocesses=*logarchiveformat='TSrARC'*logarchivemaxprocesses=*opencursors=*pgaaggregatetarget=*processes=*remoteloginpasswordfile='EXCLUSIVE'*sgatarget=*undomanagement='AUTO'*undotablespace='UNDOTBS'*userdumpdest='optoracleadminlotteryudump'#addbelowparameterforstandydatabase*DBUNIQUENAME='primary'*logarchiveconfig='DGCONFIG=(primary,standby)'*logarchivedest='location=optoracleoradatalotteryarchiveVALIDFOR=(ALLLOGFILES,ALLROLES)DBUNIQUENAME=primary'*logarchivedest='SERVICE=standbyarchASYNCVALIDFOR=(ONLINELOGFILES,PRIMARYROLE)DBUNIQUENAME=standby'*STANDBYFILEMANAGEMENT=AUTO*LOGARCHIVEDESTSTATE=ENABLE*LOGARCHIVEDESTSTATE=ENABLE*FALSERVER='standby'*FALCLIENT='primary'主库用PFILE建立SPFILEoraclehostpfile$sqlplus'assysdba'SQL>createspfilefrompfile='optoracleadminlotterypfileinitora'建立备用库的控制文件SQL>alterdatabasecreatestandbycontrolfileas'tmpstandbyctlctl'配置主数据库listener及tnsnamesoraclehostadmin$catlisteneroraSIDLISTLISTENER=(SIDLIST=(SIDDESC=(GLOBALDBNAME=lottery)(ORACLEHOME=optoracleproduct)(SIDNAME=lottery)))LISTENER=(DESCRIPTIONLIST=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=))))#加端口供以后做switchoverSIDLISTLISTENER=(SIDLIST=(SIDDESC=(GLOBALDBNAME=lottery)(ORACLEHOME=optoracleproduct)(SIDNAME=lottery)))LISTENER=(DESCRIPTIONLIST=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=))))oraclehostadmin$cattnsnamesora#和端口都能连上主机和备机这样在做switchover时就不需要改这里的设置了primary=(DESCRIPTION=(ADDRESSLIST=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=)))(CONNECTDATA=(SID=lottery)))standby=(DESCRIPTION=(ADDRESSLIST=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=)))(CONNECTDATA=(SID=lottery)))复制文件到备机oraclehost~cdoptoracleoradatalotteryoraclehostlottery$rcphost:optoracleoradatalottery*dbforaclehostlottery$rcphost:tmpstandbyctlctloraclehostlottery$mvstandbyctlctlcontrolctloraclehostlottery$cpcontrolctlcontrolctloraclehostlottery$cpcontrolctlcontrolctl复制并修改备机的参数文件oraclehost~cdoptoracleadminlotterypfileoraclehostpfile$rcphost:optoracleadminlotterypfileinitora修改为如下:lotterydbcachesize=lotteryjavapoolsize=lotterylargepoolsize=lotterysharedpoolsize=lotterystreamspoolsize=*auditfiledest='optoracleadminlotteryadump'*backgrounddumpdest='optoracleadminlotterybdump'*compatible=''*controlfiles='optoracleoradatalotterycontrolctl','optoracleoradatalotterycontrolctl','optoracleoradatalotterycontrolctl'*coredumpdest='optoracleadminlotterycdump'*dbblocksize=*dbdomain=''*dbfilemultiblockreadcount=*dbname='lottery'*dbrecoveryfiledest='optoracleflashrecoveryarea'*dbrecoveryfiledestsize=*dispatchers='(PROTOCOL=TCP)(SERVICE=lotteryXDB)'*jobqueueprocesses=*logarchiveformat='TSrARC'*logarchivemaxprocesses=*opencursors=*pgaaggregatetarget=*processes=*remoteloginpasswordfile='EXCLUSIVE'*sgatarget=*undomanagement='AUTO'*undotablespace='UNDOTBS'*userdumpdest='optoracleadminlotteryudump'*DBUNIQUENAME='standby'*logarchiveconfig='DGCONFIG=(primary,standby)'*logarchivedest='location=optoracleoradatalotteryarchiveVALIDFOR=(ALLLOGFILES,ALLROLES)DBUNIQUENAME=standby'*logarchivedest='SERVICE=primaryarchASYNCVALIDFOR=(ONLINELOGFILES,PRIMARYROLE)DBUNIQUENAME=primary'*STANDBYFILEMANAGEMENT=AUTO*LOGARCHIVEDESTSTATE=ENABLE*LOGARCHIVEDESTSTATE=ENABLE*FALSERVER='primary'*FALCLIENT='standby'生成备用库密码文件orapwdfile='optoracleproductdbsorawdlotteryora'password=sysentries=修改备机的listener及tnsnamesoraclehostadmin$catlisteneroraSIDLISTLISTENER=(SIDLIST=(SIDDESC=(GLOBALDBNAME=lottery)(ORACLEHOME=optoracleproduct)(SIDNAME=lottery)))LISTENER=(DESCRIPTIONLIST=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=))))#加一个的端口供以后做switchoverSIDLISTLISTENER=(SIDLIST=)(SIDDESC=(GLOBALDBNAME=lottery)(ORACLEHOME=optoracleproduct)(SIDNAME=lottery)))LISTENER=(DESCRIPTIONLIST=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host)(PORT=))))oraclehostadmin$cattnsnamesoraprimary=(DESCRIPTION=(ADDRESSLIST=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=)))(CONNECTDATA=(SID=lottery)))standby=(DESCRIPTION=(ADDRESSLIST=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=)))(CONNECTDATA=(SID=lottery)))测试主备之间网络连通oraclehostadmin$lsnrctlstartoraclehostadmin$tnspingstandbyoraclehostadmin$lsnrctlstartoraclehostadmin$tnspingprimary打开备库SQL>startupmountpfile='optoracleadminlotterypfileinitora'SQL>createspfilefrompfile='optoracleadminlotterypfileinitora'SQL>alterdatabaserecovermanagedstandbydatabasedisconnectfromsession打开主库SQL>startup测试是否OK主库:SQL>altersystemswitchlogfile从库:SQL>selectFIRSTTIME,NEXTTIME,APPLIED,SEQUENCE#fromv$archivedlogorderbySEQUENCE#FIRSTTIMENEXTTIMEAPPSEQUENCE#::::YES::::YESMAXIMIZEPERFORM和MAXIMIZEPROTECTION模式转换在备机上:SQL>shutdownimmediateSQL>startupmountSQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizemSQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizemSQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizemSQL>alterdatabaseaddstandbylogfilegroup('optoracleoradatalotteryredolog')sizem在主机上SQL>shutdownimmediateSQL>startupmountSQL>altersystemsetlogarchivedest='SERVICE=standbyLGWRSYNCAFFIRMVALIDFOR=(ONLINELOGFILES,PRIMARYROLE)DBUNIQUENAME=standby'SQL>alterdatabasesetstandbydatabasetomaximizeprotectionSQL>alterdatabaseopenSQL>selectprotectionmodefromv$databasePROTECTIONMODEMAXIMUMPROTECTION在备机上SQL>recovermanagedstandbydatabasedisconnectfromsession测试一下:在主机上执行SQL>altesystemswitchlogfile在备机上查看v$standbylog视图SQL>selectGROUP#,THREAD#,SEQUENCE#,USED,ARCHIVED,STATUSfromv$standbylogGROUP#THREAD#SEQUENCE#USEDARCSTATUSYESACTIVENOUNASSIGNEDYESUNASSIGNEDYESUNASSIGNEDMAXIMIZEPROTECTION和MAXIMIZEAVAILABILITY模式下备机不能先关闭会出现如下错误SQL>shutdownimmediateORA:databasebusyOpen,close,mount,anddismountnotallowednow主库和备库的switchover配置注意:Swithover时只能先从Primary切到Standby再从Standby切到Primary准备原主库是否有standbyredolog上面已建好了。准备主库和备库的参数文件最好就是将两个数据库的参数文件互换在两台机器上同时保留主库和备库的参数文件。oraclehost$cdoptoracleadminlotterypfileoraclehostpfilercphost:optoracleadminlotterypfileinitorainitprimaryoraoraclehostpfilercpinitorahost:optoracleadminlotterypfileinitstandbyora从primary切换到standbyconnectassysdbaSQL>alterdatabasecommittoswitchovertophysicalstandbywithsessionshutdownSQL>shutdownSQL>startupmountpfile=optoracleadminlotterypfileinitstandbyoraSQL>recovermanagedstandbydatabasedisconnect启动新备库端的Listener(port=)oraclehostadmin$lsnrctlstoporaclehostadmin$lsnrctlstartLISTENER从standby切换到primaryconnectassysdbaSQL>alterdatabasecommittoswitchovertoprimarySQL>shutdownSQL>startuppfile=optoracleadminlotterypfileinitprimaryora启动新主库端的Listener(port=)oraclehostadmin$lsnrctlstoporaclehostadmin$lsnrctlstartLISTENERDataGuard维护、在生产库停止DataGuard操作:SQL>showparameterlogarchivedestSQL>altersystemsetlogarchivedeststate=defer、在生产库开启DataGuard操作:SQL>altersystemsetlogarchivedeststate=enable、在备份库查看生产库传过来的归档应用情况SQL>SELECTFILENAME,SEQUENCE#ASSEQ#,FIRSTCHANGE#ASFCHANGE#,NEXTCHANGE#ASNCHANGE#,TIMESTAMP,DICTBEGINASBEG,DICTENDASEND,THREAD#ASTHR#,APPLIEDFROMDBALOGSTDBYLOGORDERBYTHREAD#,SEQUENCE#、在备份库查看应用事件SQL>SELECTEVENTTIME,EVENT,XIDUSN,XIDSLT,XIDSQNFROMDBALOGSTDBYEVENTSorderbydesc可跳过某些引起阻塞的DDL或DML应用然后手工执行这些应用:SQL>alterdatabasestoplogicalstandbyapplySQL>execdbmslogstdbyskiptransaction(,,)SQL>ALTERDATABASESTARTLOGICALSTANDBYAPPLYIMMEDIATE、在备份库跳过特定的DML或DDL操作SQL>alterdatabasestoplogicalstandbyapplySQL>executedbmslogstdbyskip(stmt=>'DML',schemaname=>'BANPING',objectname=>'TABLENAME',procname=>)SQL>alterdatabasestartlogicalstandbyapply由于oracle的bug版本开始应用后会报以下错误:ORA:erroroccurredatrecursiveSQLlevelORA:escapecharactermustbecharacterstringoflength此时执行这个SQL语句可解决:SQL>updatesystemlogstdby$skipsetesc=''whereescisSQL>commit、重新初始化表SQL>alterdatabasestoplogicalstandbyapplySQL>executedbmslogstdbyunskip('DML','BANPING','TABLENAME')SQL>execdbmslogstdbyinstantiatetable('BANPING','TABLENAME','dblinkname')SQL>alterdatabasestartlogicalstandbyapply注意这里建立的DBLINKdblinkname必须是public的否则会报以下错误:ORA:invalidargumentvalueORA:at"SYSDBMSLOGSTDBY",lineORA:atline、在备库查看日志应用状态和进度:SQL>select*fromV$LOGSTDBYSTATESQL>select*fromV$LOGSTDBYPROGRESSLINUX操作系统的安装和配置DataGuard安装环境MAXIMIZEPERFORM和MAXIMIZEPROTECTION模式转换主库和备库的switchover配置DataGuard维护

用户评论(0)

0/200

精彩专题

上传我的资料

每篇奖励 +2积分

资料评价:

/13
1下载券 下载 加入VIP, 送下载券

意见
反馈

立即扫码关注

爱问共享资料微信公众号

返回
顶部