当前位置: 首页 > news >正文

rman 备份尽量使用 backup database plus archivelog

backup database archivelog all delete input; 当前日志不会切换及备份


RMAN archivelog backup

Yesterday I encountered a problem with a RMAN backup. There were no backups of archivelogs, only datafile backups and archivelogs. So I investigated the issue and found the following backup script:

1

2

backup database archivelog all delete input;

delete noprompt obsolete;

Looks good at the first glance but what it does is not what I wanted it to do. The “redundancy” is configured to be 1. So what happens is this, first the database is being backued up and right after it the archivelogs are being backed up to. But only those archivelogs that existed at the time the backup command started. No archivelogs that were created during the database backup are being backed up. So the archivelog backups become obsolete immediately and are deleted by the following “delete obsolete” command.
The thing is, the script should look like this:

1

2

backup database plus archivelog delete input;

delete noprompt obsolete;

Minor change with a major impact.

Let’s see what happens in both cases

Case 1

Check what sequences are in the online logs and generate some more:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

[oracle@oel6u4 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Sep 13 10:45:04 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing opt                                                                ions

SYS@db12cb> select group#, sequence#, status from v$log;

    GROUP#  SEQUENCE# STATUS

---------- ---------- ---------------

         1         16 CURRENT

         2         14 ACTIVE

         3         15 ACTIVE

SYS@db12cb> alter system switch logfile;

System altered.

SYS@db12cb> alter system switch logfile;

System altered.

SYS@db12cb> alter system switch logfile;

System altered.

SYS@db12cb> alter system checkpoint;

System altered.

SYS@db12cb> select group#, sequence#, status from v$log;

    GROUP#  SEQUENCE# STATUS

---------- ---------- ---------------

         1         19 CURRENT

         2         17 INACTIVE

         3         18 INACTIVE

At that point we have archivelogs until sequnce 18. Now we start the RMAN backup:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

[oracle@oel6u4 ~]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Sep 13 10:48:07 2017

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DB12C (DBID=1357631873)

RMAN> backup database archivelog all delete input;

Starting backup at 13.09.2017 10:48:16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=276 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_example_d3lq5h14_.dbf

input datafile file number=00001 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_system_d3lq3d22_.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_sysaux_d3lq4lpd_.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_marco_d3qvwcwt_.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_undotbs1_d3lq5ctw_.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_users_d3lq6w0q_.dbf

channel ORA_DISK_1: starting piece 1 at 13.09.2017 10:48:17

channel ORA_DISK_1: finished piece 1 at 13.09.2017 10:51:02

piece handle=/u01/app/oracle/fra/DB12CB/backupset/2017_09_13/o1_mf_nnndf_TAG20170913T104816_dvkw6kls_.bkp tag=TAG20170913T104816 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:45

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=14 RECID=43 STAMP=954585900

input archived log thread=1 sequence=15 RECID=44 STAMP=954585901

input archived log thread=1 sequence=16 RECID=46 STAMP=954585995

input archived log thread=1 sequence=17 RECID=48 STAMP=954585996

input archived log thread=1 sequence=18 RECID=50 STAMP=954585998

channel ORA_DISK_1: starting piece 1 at 13.09.2017 10:51:02

channel ORA_DISK_1: finished piece 1 at 13.09.2017 10:51:05

piece handle=/u01/app/oracle/fra/DB12CB/backupset/2017_09_13/o1_mf_annnn_TAG20170913T104816_dvkwcpnp_.bkp tag=TAG20170913T104816 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_14_dvkw0cm1_.arc RECID=43 STAMP=954585900

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_15_dvkw0f1w_.arc RECID=44 STAMP=954585901

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_16_dvkw3c38_.arc RECID=46 STAMP=954585995

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_17_dvkw3d1f_.arc RECID=48 STAMP=954585996

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_18_dvkw3g00_.arc RECID=50 STAMP=954585998

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 13.09.2017 10:51:09

channel ORA_DISK_1: finished piece 1 at 13.09.2017 10:51:10

piece handle=/u01/app/oracle/fra/DB12CB/backupset/2017_09_13/o1_mf_ncsnf_TAG20170913T104816_dvkwcx24_.bkp tag=TAG20170913T104816 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 13.09.2017 10:51:10

We see, that all archivelogs until and including sequence 18 are being backed up. No sign of sequence 19 or any sequence beyond that.

Case 2

Again, we check the sequences in the online logs. There is no change to what we had ad the beginning of Case-1-Backup. That’s why I create some more archivelogs.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

[oracle@oel6u4 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Wed Sep 13 12:36:06 2017

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to:

Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SYS@db12cb> select group#, sequence#, status from v$log;

    GROUP#  SEQUENCE# STATUS

---------- ---------- ---------------

         1         19 CURRENT

         2         17 INACTIVE

         3         18 INACTIVE

SYS@db12cb> alter system switch logfile;

System altered.

SYS@db12cb> alter system switch logfile;

System altered.

SYS@db12cb> alter system checkpoint;

System altered.

SYS@db12cb> select group#, sequence#, status from v$log;

    GROUP#  SEQUENCE# STATUS

---------- ---------- ---------------

         1         19 INACTIVE

         2         20 INACTIVE

         3         21 CURRENT

Now we start the backup with the slightly modified command:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

[oracle@oel6u4 ~]$ rman target /

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Sep 13 12:36:41 2017

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DB12C (DBID=1357631873)

RMAN> backup database plus archivelog delete input;

Starting backup at 13.09.2017 12:36:49

current log archived

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=264 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=19 RECID=52 STAMP=954592574

input archived log thread=1 sequence=20 RECID=54 STAMP=954592575

input archived log thread=1 sequence=21 RECID=56 STAMP=954592610

channel ORA_DISK_1: starting piece 1 at 13.09.2017 12:36:50

channel ORA_DISK_1: finished piece 1 at 13.09.2017 12:36:51

piece handle=/u01/app/oracle/fra/DB12CB/backupset/2017_09_13/o1_mf_annnn_TAG20170913T123650_dvl2l2o8_.bkp tag=TAG20170913T123650 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_19_dvl2jx41_.arc RECID=52 STAMP=954592574

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_20_dvl2jzhj_.arc RECID=54 STAMP=954592575

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_21_dvl2l23m_.arc RECID=56 STAMP=954592610

Finished backup at 13.09.2017 12:36:51

Starting backup at 13.09.2017 12:36:51

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00005 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_example_d3lq5h14_.dbf

input datafile file number=00001 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_system_d3lq3d22_.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_sysaux_d3lq4lpd_.dbf

input datafile file number=00002 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_marco_d3qvwcwt_.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_undotbs1_d3lq5ctw_.dbf

input datafile file number=00006 name=/u01/app/oracle/oradata/DB12CB/datafile/o1_mf_users_d3lq6w0q_.dbf

channel ORA_DISK_1: starting piece 1 at 13.09.2017 12:36:52

channel ORA_DISK_1: finished piece 1 at 13.09.2017 12:39:07

piece handle=/u01/app/oracle/fra/DB12CB/backupset/2017_09_13/o1_mf_nnndf_TAG20170913T123651_dvl2l435_.bkp tag=TAG20170913T123651 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:02:15

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 13.09.2017 12:39:08

channel ORA_DISK_1: finished piece 1 at 13.09.2017 12:39:09

piece handle=/u01/app/oracle/fra/DB12CB/backupset/2017_09_13/o1_mf_ncsnf_TAG20170913T123651_dvl2pd9n_.bkp tag=TAG20170913T123651 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 13.09.2017 12:39:09

Starting backup at 13.09.2017 12:39:09

current log archived

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=22 RECID=58 STAMP=954592749

channel ORA_DISK_1: starting piece 1 at 13.09.2017 12:39:09

channel ORA_DISK_1: finished piece 1 at 13.09.2017 12:39:10

piece handle=/u01/app/oracle/fra/DB12CB/backupset/2017_09_13/o1_mf_annnn_TAG20170913T123909_dvl2pfxh_.bkp tag=TAG20170913T123909 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=/u01/app/oracle/fra/DB12CB/archivelog/2017_09_13/o1_mf_1_22_dvl2pflz_.arc RECID=58 STAMP=954592749

Finished backup at 13.09.2017 12:39:10

Looks different now. We have a logswitch at the very beginning of the backup. Then all the archivelogs that exists at that point are being backed up. Then there is the database backup. And finally another logswitch is done and all the logs that were created during the database backup are being backed up too.
That is, what I really want.

Conclusion

The effect of the “plus archivelog” syntax is completely different from the combined “backup” command for different file types. So be very careful which option you use and most important: check your backup strategy by doing test restores on a regular basis.

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 数据库进阶:2.索引
  • 【 html+css 绚丽Loading 】 000045 太极旋流轮
  • 【SpringCloud】 实现负载均衡
  • 【C++ 09】继承
  • Path系统环境变量和CLASSPATH环境变量
  • 存储课程学习笔记2_借助内核插入一个文件系统,用文件夹下测试文件系统(mount文件系统到目录下是入口)
  • yolov5-6.2 在 rk3399pro 上的移植
  • 力扣面试150 三角形最小路径和 DFS 记忆化搜索 DP 滚动数组优化DP
  • 一次性了解Neo4j图形数据库
  • 外贸人提高潜在客户EDM电子邮件营销参与度的一些建议
  • C++ 类型的转换
  • vivado 时间汇总报告
  • 一台手机一个ip地址吗?手机ip地址泄露了怎么办
  • 快速上手基于 BaGet 的脚本自动化构建 .net 应用打包
  • Lianwei 安全周报|2024.09.09
  • 【刷算法】从上往下打印二叉树
  • Django 博客开发教程 16 - 统计文章阅读量
  • Java IO学习笔记一
  • LintCode 31. partitionArray 数组划分
  • mysql常用命令汇总
  • RxJS 实现摩斯密码(Morse) 【内附脑图】
  • Spark学习笔记之相关记录
  • vue中实现单选
  • WebSocket使用
  • 基于Android乐音识别(2)
  • 猫头鹰的深夜翻译:JDK9 NotNullOrElse方法
  • 通过几道题目学习二叉搜索树
  • 小程序01:wepy框架整合iview webapp UI
  • 一些关于Rust在2019年的思考
  • ​2020 年大前端技术趋势解读
  • ![CDATA[ ]] 是什么东东
  • #调用传感器数据_Flink使用函数之监控传感器温度上升提醒
  • #我与虚拟机的故事#连载20:周志明虚拟机第 3 版:到底值不值得买?
  • (1)Android开发优化---------UI优化
  • (2024,RWKV-5/6,RNN,矩阵值注意力状态,数据依赖线性插值,LoRA,多语言分词器)Eagle 和 Finch
  • (zhuan) 一些RL的文献(及笔记)
  • (安卓)跳转应用市场APP详情页的方式
  • (附程序)AD采集中的10种经典软件滤波程序优缺点分析
  • (附源码)spring boot校园健康监测管理系统 毕业设计 151047
  • (六)DockerCompose安装与配置
  • (十) 初识 Docker file
  • (四)软件性能测试
  • (一)Thymeleaf用法——Thymeleaf简介
  • (转) RFS+AutoItLibrary测试web对话框
  • (转)linux自定义开机启动服务和chkconfig使用方法
  • (转载)VS2010/MFC编程入门之三十四(菜单:VS2010菜单资源详解)
  • .class文件转换.java_从一个class文件深入理解Java字节码结构
  • .halo勒索病毒解密方法|勒索病毒解决|勒索病毒恢复|数据库修复
  • .NET “底层”异步编程模式——异步编程模型(Asynchronous Programming Model,APM)...
  • .Net Core中Quartz的使用方法
  • .Net6 Api Swagger配置
  • .NET开发者必备的11款免费工具
  • .NET中两种OCR方式对比
  • /ThinkPHP/Library/Think/Storage/Driver/File.class.php  LINE: 48
  • ??如何把JavaScript脚本中的参数传到java代码段中