[20161212]备份archivelog.txt

简介: [20161212]备份archivelog.txt --许多人都知道如果执行backup database plus archivelog;实际上是先执行如下: 1.

[20161212]备份archivelog.txt

--许多人都知道如果执行backup database plus archivelog;实际上是先执行如下:

1.alter system archive log current ;
2.备份archivelog;
3.备份数据库
4.alter system archive log current ;
5.备份剩下的archivelog备份.

自己测试看看:
1.环境:
SYS@book> @ &r/ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/archivelog/book
Oldest online log sequence     9
Next log sequence to archive   11
Current log sequence           11

--当前Current log sequence=11.

$ ls -ltr /u01/app/oracle/archivelog/book/1_*
-rw-r----- 1 oracle oinstall 47245824 2016-12-12 09:01:58 /u01/app/oracle/archivelog/book/1_6_896605872.dbf
-rw-r----- 1 oracle oinstall  1170944 2016-12-12 09:26:56 /u01/app/oracle/archivelog/book/1_7_896605872.dbf
-rw-r----- 1 oracle oinstall     2048 2016-12-12 09:27:53 /u01/app/oracle/archivelog/book/1_8_896605872.dbf
-rw-r----- 1 oracle oinstall     3072 2016-12-12 09:28:04 /u01/app/oracle/archivelog/book/1_9_896605872.dbf
-rw-r----- 1 oracle oinstall   482304 2016-12-12 09:55:58 /u01/app/oracle/archivelog/book/1_10_896605872.dbf

2.备份测试:

RMAN> backup database plus archivelog ;
Starting backup at 2016-12-12 09:58:07
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=6 RECID=2 STAMP=930387718
input archived log thread=1 sequence=7 RECID=3 STAMP=930389216
input archived log thread=1 sequence=8 RECID=4 STAMP=930389273
input archived log thread=1 sequence=9 RECID=5 STAMP=930389284
input archived log thread=1 sequence=10 RECID=6 STAMP=930390958
input archived log thread=1 sequence=11 RECID=7 STAMP=930391087
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<=说明先做了一次切换.alter system archive log current ;并且先备份archivelog.
channel ORA_DISK_1: starting piece 1 at 2016-12-12 09:58:07
channel ORA_DISK_1: finished piece 1 at 2016-12-12 09:58:08
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_annnn_TAG20161212T095807_d4w11hf9_.bkp tag=TAG20161212T095807 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-12 09:58:08

Starting backup at 2016-12-12 09:58:08
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=00001 name=/mnt/ramdisk/book/system01.dbf
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2016-12-12 09:58:08
channel ORA_DISK_1: finished piece 1 at 2016-12-12 09:58:15
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_nnndf_TAG20161212T095808_d4w11jno_.bkp tag=TAG20161212T095808 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
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 2016-12-12 09:58:16
channel ORA_DISK_1: finished piece 1 at 2016-12-12 09:58:17
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_ncsnf_TAG20161212T095808_d4w11rsb_.bkp tag=TAG20161212T095808 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-12 09:58:17

Starting backup at 2016-12-12 09:58:17
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=12 RECID=8 STAMP=930391097
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<=又做了1次切换,备份剩下的archivelog.
channel ORA_DISK_1: starting piece 1 at 2016-12-12 09:58:17
channel ORA_DISK_1: finished piece 1 at 2016-12-12 09:58:18
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_annnn_TAG20161212T095817_d4w11syb_.bkp tag=TAG20161212T095817 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-12 09:58:18


$ ls -ltr /u01/app/oracle/archivelog/book/1_*
-rw-r----- 1 oracle oinstall 47245824 2016-12-12 09:01:58 /u01/app/oracle/archivelog/book/1_6_896605872.dbf
-rw-r----- 1 oracle oinstall  1170944 2016-12-12 09:26:56 /u01/app/oracle/archivelog/book/1_7_896605872.dbf
-rw-r----- 1 oracle oinstall     2048 2016-12-12 09:27:53 /u01/app/oracle/archivelog/book/1_8_896605872.dbf
-rw-r----- 1 oracle oinstall     3072 2016-12-12 09:28:04 /u01/app/oracle/archivelog/book/1_9_896605872.dbf
-rw-r----- 1 oracle oinstall   482304 2016-12-12 09:55:58 /u01/app/oracle/archivelog/book/1_10_896605872.dbf
-rw-r----- 1 oracle oinstall    29696 2016-12-12 09:58:07 /u01/app/oracle/archivelog/book/1_11_896605872.dbf
-rw-r----- 1 oracle oinstall     1536 2016-12-12 09:58:17 /u01/app/oracle/archivelog/book/1_12_896605872.dbf

--//可以发现多了2个归档日志11,12.也就是讲这样备份对于恢复才有效,因为如果缺少后面的归档日志,可能恢复到某个特定的scn不行.
--//可以查看以前的测试链接:http://blog.itpub.net/267265/viewspace-2106087/
--//如果备份时存在写盘操作,scn大于 CHECKPOINT_CHANGE#的scn,要记录在控制文件中的. 视图 v$backup_datafile的字段
--//ABSOLUTE_FUZZY_CHANGE#可以反应出来.

3.其他方式备份archivelog呢?

RMAN> backup archivelog all ;
Starting backup at 2016-12-12 10:15:35
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=6 RECID=2 STAMP=930387718
input archived log thread=1 sequence=7 RECID=3 STAMP=930389216
input archived log thread=1 sequence=8 RECID=4 STAMP=930389273
input archived log thread=1 sequence=9 RECID=5 STAMP=930389284
input archived log thread=1 sequence=10 RECID=6 STAMP=930390958
input archived log thread=1 sequence=11 RECID=7 STAMP=930391087
input archived log thread=1 sequence=12 RECID=8 STAMP=930391097
input archived log thread=1 sequence=13 RECID=9 STAMP=930392135
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<=做了一次切换.alter system archive log current;
channel ORA_DISK_1: starting piece 1 at 2016-12-12 10:15:35
channel ORA_DISK_1: finished piece 1 at 2016-12-12 10:15:36
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_annnn_TAG20161212T101535_d4w22784_.bkp tag=TAG20161212T101535 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-12 10:15:36

$ ls -ltr /u01/app/oracle/archivelog/book/1_*
-rw-r----- 1 oracle oinstall 47245824 2016-12-12 09:01:58 /u01/app/oracle/archivelog/book/1_6_896605872.dbf
-rw-r----- 1 oracle oinstall  1170944 2016-12-12 09:26:56 /u01/app/oracle/archivelog/book/1_7_896605872.dbf
-rw-r----- 1 oracle oinstall     2048 2016-12-12 09:27:53 /u01/app/oracle/archivelog/book/1_8_896605872.dbf
-rw-r----- 1 oracle oinstall     3072 2016-12-12 09:28:04 /u01/app/oracle/archivelog/book/1_9_896605872.dbf
-rw-r----- 1 oracle oinstall   482304 2016-12-12 09:55:58 /u01/app/oracle/archivelog/book/1_10_896605872.dbf
-rw-r----- 1 oracle oinstall    29696 2016-12-12 09:58:07 /u01/app/oracle/archivelog/book/1_11_896605872.dbf
-rw-r----- 1 oracle oinstall     1536 2016-12-12 09:58:17 /u01/app/oracle/archivelog/book/1_12_896605872.dbf
-rw-r----- 1 oracle oinstall  1771008 2016-12-12 10:15:35 /u01/app/oracle/archivelog/book/1_13_896605872.dbf

--//如果仅仅备份archivelog all,仅仅切换1次.

RMAN> backup archivelog from time 'trunc(sysdate)';
Starting backup at 2016-12-12 10:19:11
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=6 RECID=2 STAMP=930387718
input archived log thread=1 sequence=7 RECID=3 STAMP=930389216
input archived log thread=1 sequence=8 RECID=4 STAMP=930389273
input archived log thread=1 sequence=9 RECID=5 STAMP=930389284
input archived log thread=1 sequence=10 RECID=6 STAMP=930390958
input archived log thread=1 sequence=11 RECID=7 STAMP=930391087
input archived log thread=1 sequence=12 RECID=8 STAMP=930391097
input archived log thread=1 sequence=13 RECID=9 STAMP=930392135
input archived log thread=1 sequence=14 RECID=10 STAMP=930392351
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<=做了一次切换.alter system archive log current;
channel ORA_DISK_1: starting piece 1 at 2016-12-12 10:19:11
channel ORA_DISK_1: finished piece 1 at 2016-12-12 10:19:12
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_annnn_TAG20161212T101911_d4w28zm4_.bkp tag=TAG20161212T101911 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-12 10:19:12

RMAN> backup archivelog from sequence 13;
Starting backup at 2016-12-12 10:20:11
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=13 RECID=9 STAMP=930392135
input archived log thread=1 sequence=14 RECID=10 STAMP=930392351
input archived log thread=1 sequence=15 RECID=11 STAMP=930392412
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<=做了一次切换.alter system archive log current;
channel ORA_DISK_1: starting piece 1 at 2016-12-12 10:20:12
channel ORA_DISK_1: finished piece 1 at 2016-12-12 10:20:13
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_annnn_TAG20161212T102012_d4w2bwwj_.bkp tag=TAG20161212T102012 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-12 10:20:13

4.另外的测试:
$ ls -ltr /u01/app/oracle/archivelog/book/1_1*
-rw-r----- 1 oracle oinstall  482304 2016-12-12 09:55:58 /u01/app/oracle/archivelog/book/1_10_896605872.dbf
-rw-r----- 1 oracle oinstall   29696 2016-12-12 09:58:07 /u01/app/oracle/archivelog/book/1_11_896605872.dbf
-rw-r----- 1 oracle oinstall    1536 2016-12-12 09:58:17 /u01/app/oracle/archivelog/book/1_12_896605872.dbf
-rw-r----- 1 oracle oinstall 1771008 2016-12-12 10:15:35 /u01/app/oracle/archivelog/book/1_13_896605872.dbf
-rw-r----- 1 oracle oinstall  304128 2016-12-12 10:19:11 /u01/app/oracle/archivelog/book/1_14_896605872.dbf
-rw-r----- 1 oracle oinstall    2048 2016-12-12 10:20:12 /u01/app/oracle/archivelog/book/1_15_896605872.dbf

RMAN> backup archivelog sequence between 10 and 20;
Starting backup at 2016-12-12 10:22:49
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=10 RECID=6 STAMP=930390958
input archived log thread=1 sequence=11 RECID=7 STAMP=930391087
input archived log thread=1 sequence=12 RECID=8 STAMP=930391097
input archived log thread=1 sequence=13 RECID=9 STAMP=930392135
input archived log thread=1 sequence=14 RECID=10 STAMP=930392351
input archived log thread=1 sequence=15 RECID=11 STAMP=930392412
channel ORA_DISK_1: starting piece 1 at 2016-12-12 10:22:49
channel ORA_DISK_1: finished piece 1 at 2016-12-12 10:22:50
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/backupset/2016_12_12/o1_mf_annnn_TAG20161212T102249_d4w2hsl0_.bkp tag=TAG20161212T102249 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2016-12-12 10:22:50
--这样不会切换.

总结:
1.backup database plus archivelog方式,至少切换2次,先备份archivelog,然后数据文件,再切换一次,在备份剩下的archivelog.
2.backup archivelog all ;,仅仅先切换归档,再备份.
3.backup archivelog from time 'trunc(sysdate)'; 仅仅先切换归档,再备份.
4.backup archivelog sequence between 10 and 20; 没有切换.
5.估计有范围的单独备份都没有切换,仅仅猜测不做测试了.

目录
相关文章
|
Oracle 关系型数据库
[20180423]关于rman备份的问题2.txt
[20180423]关于rman备份的问题2.txt --//别人问的问题,rman备份放在哪里的问题. SCOTT@book> @ ver1 PORT_STRING                    VERSION        BANNER --...
928 0
|
Oracle 关系型数据库 Linux
[20180115]RMAN-06820.txt
[20180115]RMAN-06820.txt --//在备库做归档备份出现RMAN-06820的问题。就是如果在备库做全表,因为要做主库日志切换,一般执行rman target /会出现问题。
1416 0
|
Oracle 关系型数据库 测试技术
[20171225]RMAN-06808.txt
[20171225]RMAN-06808: SECTION SIZE cannot be used when piece limit is in effect.txt --//朋友拿我的一些例子来测试遇到的RMAN-06808: SECTION SIZE cannot be used when piece limit is in effect问题.
947 0
|
关系型数据库
[20171221]RMAN-05501.txt
[20171221]RMAN-05501 aborting duplication of target database.txt --//昨天使用rman duplicate建立dg,出现如下错误: rman > duplicate target database for standby from active database; .
1068 0
|
Oracle 关系型数据库
[20171130]关于rman的一些总结.txt
[20171130]关于rman的一些总结.txt --//最近一直做rman相关测试,测试那个乱,没办法.无法从周围的人获得帮助,纯粹是自己的乱猜,乱测,不知道别人是否能看懂我写的东西.
1087 0
|
Oracle 关系型数据库 测试技术
[20171122]rman backup as copy的备份问题
[20171122]rman backup as copy的备份问题.txt --//以前曾经写过一篇[20160524]rman备份与检查点4.txt=>链接:http://blog.
1137 0
|
关系型数据库 Linux 数据库
[20171116]11GR2控制文件自动备份.txt
20171116]11GR2控制文件自动备份.txt SYS@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ---------------------------...
956 0
|
Oracle 关系型数据库 API
[20170208]rman tape.txt
[20170208]rman tape.txt --前一阵子,同事测试使用磁带做rman备份,留下一些备份信息在控制文件,要清除. --我依稀记得我以前也干过这些事情,晚上看了一下书: Apress.
983 0
|
关系型数据库 Oracle Linux
[20161230]rman checksyntax2.txt
[20161230]rman checksyntax2.txt --曾经写过一篇rman checksyntax的问题,这个问题存在10g: http://blog.
757 0
|
SQL Oracle 关系型数据库
[20161214]rman checksyntax.txt
[20161214]rman checksyntax.txt --rman在命令行使用参数checksyntax可以检查命令语法是否正确,而且并不会真正执行.但是昨天在恢复一个10g的数据库时遇到问题,做 --一个记录: 1.
939 0