[20171121]rman backup as copy 2.txt
[20171121]rman backup as copy 2.txt
--//昨天测试backup as copy ,备份时备份文件的文件头什么时候更新.是最后完成后还是顺序写入备份文件.
--//我测试的数据文件使用数据文件2(表空间sysaux),也许是文件不够大,应该减慢备份速度来测试看看.
1.环境:
SCOTT@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
$ cat dump_head.sh
#! /bin/bash
for i in $(seq 1000)
do
# echo $i
xxd -c32 -g 2 -s 8192 -l 32 $1 >> /tmp/dump_head.txt 2>/dev/null
sleep 1
done
2.测试:
--//首先启动dump_head.sh脚本,session 1:
$ . dump_head.sh /home/oracle/backup/tea01.dbf &
--//在sesion 2,在rman下执行备份:
RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 1M;
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 1 M;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored
--//设置DISK RATE 1M,这样可以减慢备份的速度,便于观察.并且仅仅打开1个并行.
RMAN> backup as copy datafile 6 format '/home/oracle/backup/%b';
Starting backup at 2017-11-21 09:43:09
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/home/oracle/backup/tea01.dbf tag=TAG20171121T094309 RECID=17 STAMP=960630229
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
channel ORA_DISK_1: throttle time: 0:00:40
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Finished backup at 2017-11-21 09:43:54
Starting Control File and SPFILE Autobackup at 2017-11-21 09:43:54
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_11_21/o1_mf_s_960630234_f1716tsv_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-11-21 09:43:55
--//注意看下划线内容,throttle time: 0:00:40.
throttle
英 [?θr?tl] 美 [?θrɑ:tl]
n.
节流阀;喉咙,气管;[机]风门
vt.& vi.
扼杀,压制;勒死,使窒息;使节流;(用节汽阀等)调节
vi.
节流,减速;窒息
-----------------------------------------------
--//而我的备份文件就是40M+8k的数据文件.
$ ls -lh /home/oracle/backup/tea01.dbf
-rw-r----- 1 oracle oinstall 41M 2017-11-21 09:43:49 /home/oracle/backup/tea01.dbf
$ ls -l /home/oracle/backup/tea01.dbf
-rw-r----- 1 oracle oinstall 41951232 2017-11-21 09:43:49 /home/oracle/backup/tea01.dbf
--//session 1:
$ fg
. dump_head.sh /home/oracle/backup/tea01.dbf
^C^
3.检查/tmp/dump_head.txt输出记录:
$ uniq -c /tmp/dump_head.txt
1 0002000: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ................................
40 0002000: 00a2 0000 0100 8001 0000 0000 0000 0105 81a6 0000 0000 0000 0000 0000 0000 0000 ................................
14 0002000: 0ba2 0000 0100 8001 0000 0000 0000 0104 61c1 0000 0000 0000 0004 200b 6e21 b74f ................a?....... .n!.O
--//^_^,再次验证我的判断.
--//从以上输出可以发现使用backup as copy备份,一定先建立一个空文件,输出一堆0000(需要大约1秒),大小与数据文件一致,这样可以先检测是否磁盘满足备份需求.
--//然后写入开头00a2,出现40次(我脚本执行sleep 1,不考虑其它消耗正好是40秒).
--//到最后才更新as copy方式的备份映像的文件头.
--//oracle的设计确实考虑许多因素,与备份文件集模式一样最后写入文件头信息,这样保证使用备份image是正确的,
--//设想一下,如果顺序写入备份image文件,如果备份过程中发生中断,而那这个image备份文件来恢复,会发生什么情况呢?
--//而现在这样设计意味着发生中断,备份image的文件头是"坏"的,意味着不能用于恢复.
--//还有一个疑问,写入备份image的文件头信息是 开始备份前读取的文件头信息,然后最后完成备份在读取文件头信息呢?
--//我只要在备份过程发出alter system checkpoint就知道.
--// 重复测试看看.
RMAN> delete datafilecopy all ;
SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE# , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME CREATION_CHANGE# RESETLOGS_CHANGE# STATUS CHECKPOINT_COUNT FUZ NAME TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------- ---------------
1 13279819419 2017-11-21 10:22:57 7 925702 ONLINE 1246 YES /mnt/ramdisk/book/system01.dbf SYSTEM
2 13279819419 2017-11-21 10:22:57 1834 925702 ONLINE 1247 YES /mnt/ramdisk/book/sysaux01.dbf SYSAUX
3 13279819419 2017-11-21 10:22:57 923328 925702 ONLINE 1156 YES /mnt/ramdisk/book/undotbs01.dbf UNDOTBS1
4 13279819419 2017-11-21 10:22:57 16143 925702 ONLINE 1243 YES /mnt/ramdisk/book/users01.dbf USERS
5 13279819419 2017-11-21 10:22:57 952916 925702 ONLINE 1152 YES /mnt/ramdisk/book/example01.dbf EXAMPLE
6 13279819419 2017-11-21 10:22:57 13276257767 925702 ONLINE 634 YES /mnt/ramdisk/book/tea01.dbf TEA
6 rows selected.
--//session 1:
RMAN> backup as copy datafile 6 format '/home/oracle/backup/%b';
Starting backup at 2017-11-21 10:26:10
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
....等
--//session 2:
SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE# , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME CREATION_CHANGE# RESETLOGS_CHANGE# STATUS CHECKPOINT_COUNT FUZ NAME TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------- ----------------
1 13279819419 2017-11-21 10:22:57 7 925702 ONLINE 1246 YES /mnt/ramdisk/book/system01.dbf SYSTEM
2 13279819419 2017-11-21 10:22:57 1834 925702 ONLINE 1247 YES /mnt/ramdisk/book/sysaux01.dbf SYSAUX
3 13279819419 2017-11-21 10:22:57 923328 925702 ONLINE 1156 YES /mnt/ramdisk/book/undotbs01.dbf UNDOTBS1
4 13279819419 2017-11-21 10:22:57 16143 925702 ONLINE 1243 YES /mnt/ramdisk/book/users01.dbf USERS
5 13279819419 2017-11-21 10:22:57 952916 925702 ONLINE 1152 YES /mnt/ramdisk/book/example01.dbf EXAMPLE
6 13279819660 2017-11-21 10:26:10 13276257767 925702 ONLINE 635 YES /mnt/ramdisk/book/tea01.dbf TEA
--//注意看数据文件6的CHECKPOINT_CHANGE#=13279819660(备份开始前CHECKPOINT_CHANGE#=13279819419),说明在备份开始时要做文件检查点, 更新文件头scn.
SYS@book> alter system checkpoint ;
System altered.
SYS@book> alter system checkpoint ;
System altered.
SYS@book> alter system checkpoint ;
System altered.
--//在备份的过程中我发3次alter system checkpoint ;
--//session 1:
RMAN> backup as copy datafile 6 format '/home/oracle/backup/%b';
Starting backup at 2017-11-21 10:26:10
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/mnt/ramdisk/book/tea01.dbf
output file name=/home/oracle/backup/tea01.dbf tag=TAG20171121T102610 RECID=19 STAMP=960632810
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: throttle time: 0:00:39
Finished backup at 2017-11-21 10:26:55
Starting Control File and SPFILE Autobackup at 2017-11-21 10:26:55
piece handle=/u01/app/oracle/fast_recovery_area/BOOK/autobackup/2017_11_21/o1_mf_s_960632816_f173qj22_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2017-11-21 10:26:57
--//session 2:
SYS@book> SELECT file#, CHECKPOINT_CHANGE#, CHECKPOINT_TIME,CREATION_CHANGE# , RESETLOGS_CHANGE#,status, CHECKPOINT_COUNT,fuzzy,name,tablespace_name FROM v$datafile_header;
FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME CREATION_CHANGE# RESETLOGS_CHANGE# STATUS CHECKPOINT_COUNT FUZ NAME TABLESPACE_NAME
----- ------------------ ------------------- ---------------- ----------------- ------- ---------------- --- -------------------------------------------------- ------------------------------
1 13279819678 2017-11-21 10:26:26 7 925702 ONLINE 1249 YES /mnt/ramdisk/book/system01.dbf SYSTEM
2 13279819678 2017-11-21 10:26:26 1834 925702 ONLINE 1250 YES /mnt/ramdisk/book/sysaux01.dbf SYSAUX
3 13279819678 2017-11-21 10:26:26 923328 925702 ONLINE 1159 YES /mnt/ramdisk/book/undotbs01.dbf UNDOTBS1
4 13279819678 2017-11-21 10:26:26 16143 925702 ONLINE 1246 YES /mnt/ramdisk/book/users01.dbf USERS
5 13279819678 2017-11-21 10:26:26 952916 925702 ONLINE 1155 YES /mnt/ramdisk/book/example01.dbf EXAMPLE
6 13279819678 2017-11-21 10:26:26 13276257767 925702 ONLINE 638 YES /mnt/ramdisk/book/tea01.dbf TEA
6 rows selected.
--//看看备份写入的scn是13279819678还是13279819660呢?
BBED> p /d filename '/home/oracle/backup/tea01.dbf' block 1 kcvfh.kcvfhckp.kcvcpscn
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 394917772
ub2 kscnwrp @488 3
BBED> p /d filename '/mnt/ramdisk/book/tea01.dbf' block 1 kcvfh.kcvfhckp.kcvcpscn
struct kcvcpscn, 8 bytes @484
ub4 kscnbas @484 394917790
ub2 kscnwrp @488 3
SYS@book> select power(2,32)*3+394917772 from dual ;
POWER(2,32)*3+394917772
-----------------------
13279819660
SYS@book> select power(2,32)*3+394917790 from dual ;
POWER(2,32)*3+394917790
-----------------------
13279819678
--//从CHECKPOINT_CHANGE#的scn号可以看出是备份文件的文件头信息是备份时读取的文件头信息,而不是经过多次alter system checkpint后的信息.
--//也就是备份时已经读取这部分信息到内存(下面的补充测试也说明问题),最后在写入备份image的文件头的.
--//我再次修改我的测试脚本,-s 8676对应的CHECKPOINT_CHANGE#号信息.再次重复测试,仅仅贴出结果.
$ cat dump_head.sh
#! /bin/bash
for i in $(seq 1000)
do
# echo $i
xxd -c32 -g 2 -s 8192 -l 32 $1 >> /tmp/dump_head.txt 2>/dev/null
xxd -c32 -g 2 -s 8676 -l 32 $1 >> /tmp/dump_head.txt 2>/dev/null
sleep 1
done
$ grep "^0002000:" /tmp/dump_head.txt | uniq -c
40 0002000: 00a2 0000 0100 8001 0000 0000 0000 0105 81a6 0000 0000 0000 0000 0000 0000 0000 ................................
39 0002000: 0ba2 0000 0100 8001 0000 0000 0000 0104 1292 0000 0000 0000 0004 200b 6e21 b74f .......................... .n!.O
$ grep "^00021e4:" /tmp/dump_head.txt | uniq -c
40 00021e4: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 ................................
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77 00021e4: 73fc 8917 0300 0000 f91b 4239 0100 0000 c003 0000 875a 0100 1000 313b 0200 0000 s?.....?B9....?...Z....1;....
--//可以看出前面40秒,根本没有写入文件头scn信息.最后才写入的.
--//收尾还原:
RMAN> configure channel 1 device type disk clear;
old RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 1 M;
old RMAN configuration parameters are successfully deleted
released channel: ORA_DISK_1
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
new RMAN configuration parameters are successfully stored
[20171121]rman backup as copy 2.txt的更多相关文章
- RMAN BACKUP
转自 RMAN BACKUP backup terminology Using the RMAN BACKUP Command to Create Backups Server-Managed Con ...
- RMAN-06023: no backup or copy of datafile 1 found to restore
在ORACLE 10g数据库还原过程遭遇RMAN-06023: no backup or copy of datafile x found to restore,具体情况如下所示 .......... ...
- 异机恢复 RMAN-06023: no backup or copy of datafile 17 found to restore
前不久因工作需要使用RMAN异机恢复,很基础也很具有代表性和普遍性,希望对需要的人有所帮助. 具体过程如下: 先拷贝原库的口令文件和参数文件到备库. 然后使用如下脚本对原库进行备份: run { al ...
- RMAN-06023: no backup or copy of datafile 6 found to restore
一:问题描述 我用指定备份集恢复时,报错: RMAN> run { 2> shutdown immediate; 3> startup mount; 4> allocate c ...
- ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode
备份数据库,报错如下 RMAN> backup database; Starting backup at -JAN- allocated channel: ORA_DISK_1 channel ...
- 官方文档 恢复备份指南八 RMAN Backup Concepts
本章内容 Consistent and Inconsistent RMAN Backups Online Backups and Backup Mode Backup Sets Image Copie ...
- [20190510]rman备份的疑问8.txt
[20190510]rman备份的疑问8.txt --//上午测试rman备份多个文件,探究input memory buffer 的问题.--//补充测试5个文件的情况.--//http://blo ...
- [20190510]rman备份的疑问7.txt
[20190510]rman备份的疑问7.txt --//上午测试rman备份时备份文件大小回缩的测试.链接:--//http://blog.itpub.net/267265/viewspace-26 ...
- [20190509]rman备份的疑问5.txt
[20190509]rman备份的疑问5.txt --//别人跟我提到的rman备份问题,我开始以为是assm与mssm的问题,实际测试情况不是.--//开始备份时生成的备份集文件很大,以后会回缩(对 ...
随机推荐
- vue.js多页面开发环境搭建
利用 vue-cli 搭建的项目大都是单页面应用项目,对于简单的项目,单页面就能满足要求.但对于有多个子项目的应用,如果创建多个单页面,显示有点重复,特别是 node_modules 会有多份相同的. ...
- VueRouter 源码深度解析
VueRouter 源码深度解析 该文章内容节选自团队的开源项目 InterviewMap.项目目前内容包含了 JS.网络.浏览器相关.性能优化.安全.框架.Git.数据结构.算法等内容,无论是基础还 ...
- 课程三(Structuring Machine Learning Projects),第一周(ML strategy(1)) —— 0.Learning Goals
Learning Goals Understand why Machine Learning strategy is important Apply satisficing and optimizin ...
- Android_Studio_Checkout_Github_Error"Cannot run program "git.exe":CreateProcess error = 2
答案都在这了,如果你有下载过git而不是github,那么你可以指定git.exe给android studio 正如这样:
- 【原创】贡献一个JS的弹出框代码...
一.前言 最近在做一个项目,自己感觉系统自带的alert()方法的弹出框实在是不堪入目,所以在网上找了一些资料,然后自己加工了一下,做出了自己的一个js弹出框,在这里贡献出来,希望对你有帮助. 二.开 ...
- 扩展方法IEnumerable<T>转换为IList<SelectListItem> ,提供@Html.DropDownList使用
由于在MVC中经常会使用到@Html.DropDownList方法,而该方法接收的是List<SelectListItem> 参数,因此就想着写一个扩展方法,直接把IEnumerable转 ...
- python实现定时任务
定时任务的实现方式有很多种,如windows服务,借助其他定时器jenkins运行脚本等方式.本文介绍的是python中的一个轻量级模块schedule. 安装 pip命令:pip install s ...
- Deep learning with Python 学习笔记(8)
Keras 函数式编程 利用 Keras 函数式 API,你可以构建类图(graph-like)模型.在不同的输入之间共享某一层,并且还可以像使用 Python 函数一样使用 Keras 模型.Ker ...
- Java与c#的一些细节区别
实习中用的语言是c#,第一次接触到这种语言,然后写的过程中,发觉和Java几乎一摸一样,好像根本是无缝切换,但细节仍有很大的区别,称有空总结一波里面的部分细节实现. ps. 我写c#过程中,发觉c#有 ...
- [JLOI 2016]成绩比较
Description 题库链接( \(\text{bzoj}\) 不知道为什么过不了啊... \(\text{luogu loj}\) 都能过...就给 \(\text{luogu}\) 的链接了. ...