免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: flutter
打印 上一主题 下一主题

[文本处理] 求两个文件匹配脚本,祝各位工作快乐 [复制链接]

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
11 [报告]
发表于 2014-10-20 17:02 |只看该作者
zxy877298415 发表于 2014-10-20 14:05
回复 7# flutter
主库可以根据v$ARCHIVED_LOG这个视图中的APPLIED字段是否在备库应用了。然后选择行的删除 ...


不知道您手边有没有DG,您可以在两边的库中查询一下日志状态看看。

很遗憾,在我这里的DG里,主库的归档日志却显示如下:

NAME                                                                                                             ARC APPLIED   DEL S
---------------------------------------------------------------------------------------------------- --- --------- --- -
stdb                                                                                                                YES YES       NO  A
stdb                                                                                                                YES YES       NO  A
+RECO/whut/archivelog/2014_10_11/thread_2_seq_810.536.860686287            YES NO        NO  A
stdb                                                                                                                YES YES       NO  A
+RECO/whut/archivelog/2014_10_11/thread_2_seq_811.547.860687265            YES NO        NO  A
stdb                                                                                                                YES YES       NO  A
+RECO/whut/archivelog/2014_10_11/thread_2_seq_812.521.860692783             YES NO        NO  A
stdb                                                                                                                YES YES       NO  A
+RECO/whut/archivelog/2014_10_11/thread_2_seq_813.633.860704083             YES NO        NO  A

我知道有这个APPLIED字段,但这个字段的含义不是那么简单,也不是能用滴。。。。

论坛徽章:
30
申猴
日期:2014-04-10 09:43:532015年亚洲杯纪念徽章
日期:2015-03-20 14:40:232015亚冠之阿尔纳斯尔
日期:2015-06-02 18:59:042015亚冠之阿尔希拉尔
日期:2015-06-30 15:22:572015亚冠之大阪钢巴
日期:2015-07-20 10:44:332015亚冠之阿尔纳斯尔
日期:2015-10-28 14:57:5215-16赛季CBA联赛之新疆
日期:2015-12-25 10:18:45黑曼巴
日期:2016-06-26 21:39:5315-16赛季CBA联赛之山西
日期:2016-07-25 21:54:2715-16赛季CBA联赛之北京
日期:2016-10-27 12:07:2315-16赛季CBA联赛之八一
日期:2017-07-07 16:39:0915-16赛季CBA联赛之吉林
日期:2017-09-04 12:14:43
12 [报告]
发表于 2014-10-20 20:00 |只看该作者
回复 11# flutter
Indicates whether the archivelog has been applied to its corresponding standby database (YES) or not (NO). The value is always NO for local destinations.
This column is meaningful at the physical standby site for the ARCHIVED_LOG entries with REGISTRAR='RFS' (which means this log is shipped from the primary to the standby database). If REGISTRAR='RFS' and APPLIED is NO, then the log has arrived at the standby but has not yet been applied. If REGISTRAR='RFS' and APPLIED is YES, the log has arrived and been applied at the standby database.
You can use this field to identify archivelogs that can be backed up and removed from disk.
文档上的解释!



   

论坛徽章:
3
丑牛
日期:2014-09-13 18:19:22摩羯座
日期:2014-10-10 17:43:02水瓶座
日期:2014-10-16 01:00:22
13 [报告]
发表于 2014-10-20 20:52 |只看该作者
学生党:飘过~不知道楼主是要脚本还是10g rman?如果是脚本的话简单写一下

  1. $ cat yhsafe.py
  2. #!/usr/bin/env python
  3. # -*- coding: gbk -*-

  4. import sys,re
  5. import linecache
  6. date_old=set(re.findall(r'(?<=/)(\d+_\d+_\d+)(?=/)',open(sys.argv[1]).read()))
  7. print r'connect target /'
  8. for x in linecache.getlines(sys.argv[2])[1:-2]:
  9.         if not x.split('/')[-2] in date_old:
  10.                 print x,
  11. print 'exit;'
复制代码
测试:
$ ./yhsafe.py sd.rman pd.rman
connect target /
delete force noprompt archivelog like '+RECO/orcl/archivelog/2014_10_13/thread_1_seq_568.700.860680471';
delete force noprompt archivelog like '+RECO/orcl/archivelog/2014_10_13/thread_2_seq_640.712.854680471';
exit;

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
14 [报告]
发表于 2014-10-21 09:03 |只看该作者
zxy877298415 发表于 2014-10-20 20:00
回复 11# flutter
Indicates whether the archivelog has been applied to its corresponding standby da ...


谢谢您的耐心解答!偶也学习了哈,在实际DG上检查了哈。

正如文档所说,Indicates whether the archivelog has been applied to its corresponding standby database (YES) or not (NO). The value is always NO for local destinations.
无论归档应用与否,主库的applied字段一直是NO

This column is meaningful at the physical standby site for the ARCHIVED_LOG entries with REGISTRAR='RFS' (which means this log is shipped from the primary to the standby database). If REGISTRAR='RFS' and APPLIED is NO, then the log has arrived at the standby but has not yet been applied. If REGISTRAR='RFS' and APPLIED is YES, the log has arrived and been applied at the standby database.

文档上说了,这个REGISTRAR='RFS' and APPLIED is YES指的是STANDBY端的日志应用状态,在STANDBY端,其实只要一个APPLIED字段就可以搞定了。

文档并没有说主库这边如何来判断日志是否传送并应用到了备库,主库的REGISTRAR其实是ARCH和LGWR,无法判断的,我主要也是为了清理主库的日志。

所以,当年ORACLE官方并没有给我一个满意的答复,只是告诉我手工去删除,我只好来求脚本了。

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
15 [报告]
发表于 2014-10-21 09:06 |只看该作者
回复 8# wiliiwin


    谢谢wiliiwin 和 Shell_HAT 的热心解答,也谢谢李满满同学。

   待会我验证哈,有结果向你们表示感谢!

论坛徽章:
30
申猴
日期:2014-04-10 09:43:532015年亚洲杯纪念徽章
日期:2015-03-20 14:40:232015亚冠之阿尔纳斯尔
日期:2015-06-02 18:59:042015亚冠之阿尔希拉尔
日期:2015-06-30 15:22:572015亚冠之大阪钢巴
日期:2015-07-20 10:44:332015亚冠之阿尔纳斯尔
日期:2015-10-28 14:57:5215-16赛季CBA联赛之新疆
日期:2015-12-25 10:18:45黑曼巴
日期:2016-06-26 21:39:5315-16赛季CBA联赛之山西
日期:2016-07-25 21:54:2715-16赛季CBA联赛之北京
日期:2016-10-27 12:07:2315-16赛季CBA联赛之八一
日期:2017-07-07 16:39:0915-16赛季CBA联赛之吉林
日期:2017-09-04 12:14:43
16 [报告]
发表于 2014-10-21 09:33 |只看该作者
回复 14# flutter
恩,那你们的库就搞个dg,数据库的备份怎么搞的呢?


   

论坛徽章:
1
CU十二周年纪念徽章
日期:2013-10-24 15:41:34
17 [报告]
发表于 2014-10-21 09:50 |只看该作者
zxy877298415 发表于 2014-10-21 09:33
回复 14# flutter
恩,那你们的库就搞个dg,数据库的备份怎么搞的呢?


RAC是HA,DG是容灾,我觉得就是备份了,您觉得呢

我觉得RAC+DG对一般的应用足够了,个人愚见,嘿嘿。

论坛徽章:
30
申猴
日期:2014-04-10 09:43:532015年亚洲杯纪念徽章
日期:2015-03-20 14:40:232015亚冠之阿尔纳斯尔
日期:2015-06-02 18:59:042015亚冠之阿尔希拉尔
日期:2015-06-30 15:22:572015亚冠之大阪钢巴
日期:2015-07-20 10:44:332015亚冠之阿尔纳斯尔
日期:2015-10-28 14:57:5215-16赛季CBA联赛之新疆
日期:2015-12-25 10:18:45黑曼巴
日期:2016-06-26 21:39:5315-16赛季CBA联赛之山西
日期:2016-07-25 21:54:2715-16赛季CBA联赛之北京
日期:2016-10-27 12:07:2315-16赛季CBA联赛之八一
日期:2017-07-07 16:39:0915-16赛季CBA联赛之吉林
日期:2017-09-04 12:14:43
18 [报告]
发表于 2014-10-21 10:15 |只看该作者
回复 17# flutter
哈哈,我感觉备份是必须的,不管什么场景下!


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

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP