温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

dataguard oracle 归档管理脚本

发布时间:2020-07-30 10:45:20 来源:网络 阅读:540 作者:snowhill 栏目:关系型数据库

管理部分

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

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

--force logging /nologging 测试

alter database force logging;
select force_logging from dba_tablespaces;
select force_logging from v$database;
alter tablespace test force logging;
select  logging,table_name,tablespace_name from user_tables where table_name ='TEST';
alter tablespace test no force logging;
select tablespace_name,logging,force_logging from dba_tablespaces;

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

CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;

--传过去就删除

CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO STANDBY;

备库删除脚本

vi delete_archive.sh 

#!/bin/sh
source /home/oracle/.bash_profile
export ORACLE_SID=standby
TABLE='v$archived_log'
$ORACLE_HOME/bin/sqlplus -silent "/ as sysdba" <<EOF
set heading off;
set pagesize 0;
set term off;
set feedback off;
set linesize 199;
set trims  on ;
set verif off;
spool /home/oracle/scripts/del_arch.sh;
select 'rm -rf '||name from v\$archived_log  where DELETED='NO' and APPLIED='YES';
spool off;
exit;
EOF
chmod +x /home/oracle/scripts/del_arch.sh
sh /home/oracle/scripts/del_arch.sh
rman target / <<EOF
crosscheck archivelog all;
delete noprompt expired archivelog all;
exit;
EOF

增加定时任务:crontab -e

0 1 * * *  su - oracle -c     /home/oracle/scripts/delete_archive.sh 1

备库自启动脚本:

vi /etc/rc.local

su - oracle -c /home/oracle/scripts/start_db.sh
vi start_db.sh
source /home/oracle/.bash_profile
lsnrctl start
export ORACLE_SID=standby
sqlplus / as sysdba <<EOF
startup;
recover managed standby database using current logfile disconnect from session;
exit


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI