Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

6

积分

1

好友

2

主题
1#
发表于 2013-4-10 10:20:26 | 查看: 2682| 回复: 1
goldengate包名:fbo_ggs_Linux_x64_ora10g_64bit.tar
数据库版本:10.2.0.5
操作系统版本:CentOS 6.4
基本情况,由于业务需求不能使用分区表删除的方法,采用批量删除。
  1. create or replace procedure sys_pro_his_table(table_name varchar2,
  2.                                                       condition  varchar2) is
  3.   type mycursor_type is ref cursor;
  4.   mycursor mycursor_type;
  5.   type rowid_table_type is table of rowid index by pls_integer;
  6.   v_rowid         rowid_table_type;
  7.   v_sql_getrowid  varchar2(400);
  8.   v_sql_del_table varchar2(400);
  9. BEGIN  
  10.   execute immediate 'insert /*+ append*/ into ' ||table_name|| '_HIS select * from ' || table_name || ' t WHERE ' ||condition;
  11.   commit;
  12.   v_sql_getrowid  := 'SELECT ROWID FROM ' || table_name || ' t  WHERE ' ||condition || ' order by rowid ';
  13.   v_sql_del_table := 'delete from ' || table_name || ' t  WHERE rowid = :1';
  14.   open mycursor for v_sql_getrowid;
  15.   loop
  16.     fetch mycursor bulk collect--------每次处理5000行,也就是每5000行一提交
  17.       into v_rowid limit 5000;
  18.     exit when v_rowid.count = 0;
  19.     forall i in v_rowid.first .. v_rowid.last
  20.       execute immediate v_sql_del_table using v_rowid(i);
  21.     commit;
  22.   end loop;
  23.   close mycursor;
  24. END;
  25. begin
  26.    sys_pro_his_table( 'COMMENT_RECORD_BAK','exists (select 1 from comment_ad_item where status = ''1'' and id = t.comment_ad_item_id) and t.comment_time<=trunc(sysdate)');
  27. end;
  28. /
复制代码
job
  1. --1、任务 JOB_sys_pro_his_table
  2. declare
  3.   JOBNAME varchar2(100) := 'JOB_sys_pro_his_table';
  4.   JOB_CNT int;
  5. begin
  6.   select count(*) into JOB_CNT from user_scheduler_jobs uj where upper(uj.JOB_NAME) = upper(JOBNAME);
  7.   if JOB_CNT >= 1 then
  8.     begin dbms_scheduler.drop_job(job_name => JOBNAME); end;
  9.   end if;
  10. end;
  11. /

  12. begin
  13. dbms_scheduler.create_job
  14. (
  15. job_name => 'JOB_sys_pro_his_table',
  16. job_type => 'PLSQL_BLOCK',
  17. job_action => 'begin sys_pro_his_table( ''COMMENT_RECORD'',''exists (select 1 from comment_ad_item where status = ''''1'''' and id = t.comment_ad_item_id) and t.comment_time<=trunc(sysdate)'');END;',
  18. repeat_interval => 'FREQ=DAILY;BYHOUR=3;byminute=30',
  19. enabled => true
  20. );
  21. end;
  22. /

  23. --使job生效
  24. exec DBMS_SCHEDULER.enable('JOB_sys_pro_his_table');
复制代码
删除以后发现同步进程感觉僵死了,
  1. GGSCI (BI-240) 1> info all

  2. Program     Status      Group       Lag           Time Since Chkpt

  3. MANAGER     RUNNING
  4. REPLICAT    RUNNING     REPL        00:00:00      00:00:00
  5. REPLICAT    RUNNING     REPL2       00:00:00      00:00:01
  6. REPLICAT    RUNNING     REPL3       06:17:37      00:00:15
复制代码
  1. GGSCI (BI-240) 2> info REPL3

  2. REPLICAT   REPL3     Last Started 2013-04-10 09:45   Status RUNNING
  3. Checkpoint Lag       06:17:59 (updated 00:00:13 ago)
  4. Log Read Checkpoint  File /home/oracle/goldengate/dirdat/jp001173
  5.                      2013-04-10 03:58:47.071332  RBA 5329670
复制代码
repl3被重启过

info REPL3.txt

8.46 KB, 下载次数: 465

2#
发表于 2013-4-10 15:20:22
select * from v$transaction

dirrpt ggserr discard 日志文件打包上传

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-12-27 17:10 , Processed in 0.049730 second(s), 23 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569