微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

dataguard oracle 归档管理脚本

管理部分

如果没有启用database force logging,则备库对/*+ append */操作,nologging操作,会报坏块;

建议表空间force logging或者database force logging;

--force logging /nologging 测试

alterdatabaseforcelogging;
selectforce_loggingfromdba_tablespaces;
selectforce_loggingfromv$database;
altertablespacetestforcelogging;
selectlogging,table_name,tablespace_namefromuser_tableswheretable_name='TEST';
altertablespacetestnoforcelogging;
selecttablespace_name,logging,force_loggingfromdba_tablespaces;

##配置主库的归档删除策略

CONfigUREARCHIVELOGDELETIONPOLICYTOAPPLIEDONSTANDBY;

--传过去就删除

CONfigUREARCHIVELOGDELETIONPOLICYTOSHIPPEDTOSTANDBY;

备库删除脚本

vi delete_archive.sh

#!/bin/sh
source/home/oracle/.bash_profile
exportORACLE_SID=standby
TABLE='v$archived_log'
$ORACLE_HOME/bin/sqlplus-silent"/assysdba"<<EOF
setheadingoff;
setpagesize0;
settermoff;
setFeedbackoff;
setlinesize199;
settrimson;
setverifoff;
spool/home/oracle/scripts/del_arch.sh;
select'rm-rf'||namefromv\$archived_logwhereDELETED='NO'andAPPLIED='YES';
spooloff;
exit;
EOF
chmod+x/home/oracle/scripts/del_arch.sh
sh/home/oracle/scripts/del_arch.sh
rmantarget/<<EOF
crosscheckarchivelogall;
deletenopromptexpiredarchivelogall;
exit;
EOF

增加定时任务:crontab -e

01***su-oracle-c/home/oracle/scripts/delete_archive.sh1

备库自启动脚本:

vi /etc/rc.local

su-oracle-c/home/oracle/scripts/start_db.sh
vistart_db.sh
source/home/oracle/.bash_profile
lsnrctlstart
exportORACLE_SID=standby
sqlplus/assysdba<<EOF
startup;
recovermanagedstandbydatabaseusingcurrentlogfiledisconnectfromsession;
exit

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐