[20171121] rman backup as copy 2.txt, 20171121 rman

Source: Internet
Author: User

[20171121] rman backup as copy 2.txt, 20171121 rman

[2, 20171121] rman backup as copy 2.txt

-- // Test backup as copy yesterday. When is the backup file header updated during backup? Is it written to the backup file in sequence after the backup is completed.
-- // The data file I tested uses data file 2 (table space sysaux). It may be because the file is not large enough and the backup speed should be slowed down for testing.

1. Environment:
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. test:
-- // First start the dump_head.sh script, session 1:
$. Dump_head.sh/home/oracle/backup/tea01.dbf &

-- // In sesion 2, perform backup under rman:
RMAN> configure channel 1 device type disk rate 1 M;
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

-- // Set disk rate 1 M, which can slow down the backup speed and facilitate observation. In addition, only one parallel operation is enabled.

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 = tag1_1121t093699 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 09:43:54
Starting Control File and SPFILE Autobackup at 09:43:54
Piece handle =/u01/app/oracle/fast_recovery_area/BOOK/autobackup/pai_11_21/o1_mf_s_960630234_f1716tsv _. bkp comment = NONE
Finished Control File and SPFILE Autobackup at 09:43:55
-- // Pay attention to the underlined content. throttle time: 0:00:40.
Throttle
English [? θ r? Tl] us [? θ r weight: tl]
N.
Throttle valve; throat, trachea; [MACHINE] Air Door
Vt. & vi.
Strangulation, suppression, strangulation, suffocation, and throttling (using a steam valve, etc.)
Vi.
Throttling, deceleration, and suffocation
-----------------------------------------------
-- // And my backup file is a 40 M + 8 K data file.
$ Ls-lh/home/oracle/backup/tea01.dbf
-Rw-r ----- 1 oracle oinstall 41 M 09:43:49/home/oracle/backup/tea01.dbf
$ Ls-l/home/oracle/backup/tea01.dbf
-Rw-r ----- 1 oracle oinstall 41951232 09:43:49/home/oracle/backup/tea01.dbf

-- // Session 1:
$ Fg
. Dump_head.sh/home/oracle/backup/tea01.dbf
^ C ^

3. Check the output records of/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 ........................ ........
40 0002000: 00a2 0000 0100 8001 0000 0000 0000 81a6 0105 0000 0000 0000 0000 0000 ........................ ........
14 0002000: 0ba2 0000 0100 8001 0000 0000 0000 0104 61c1 0000 0000 0000 0004 B 6e21 b74f ................ a ?....... . N !. O

-- // ^ _ ^: Verify my judgment again.
-- // From the above output, we can find that backup as copy is used for backup. We must first create an empty file and output a heap of 0000 (about 1 second). The size is the same as that of the data file, in this way, you can first check whether the disk meets the backup requirements.
-- // Then write the header 00a2, which appears 40 times (my script runs sleep 1, regardless of the other consumption, which is exactly 40 seconds ).
-- // The file header of the backup image in as copy mode is updated only at the end.

-- // The design of oracle does take many factors into account. Like the backup file set mode, the file header information is finally written to ensure that the backup image is correct,
-- // Imagine what will happen if the backup image file is written in sequence and interrupted during the backup process and the image backup file is restored?
-- // The current design means that the backup image file header is "bad" and cannot be used for restoration.

-- // There is another question: the file header information written to the backup image is the file header information read before the backup is started, and then the backup is completed before the file header information is read?
-- // I only need to issue alter system checkpoint during the backup process.
-- // Repeat the test.

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 10:22:57 7 925702 ONLINE 1246 YES/mnt/ramdisk/book/system01.dbf SYSTEM
2 13279819419 1834 10:22:57 925702 ONLINE 1247 YES/mnt/ramdisk/book/sysaux01.dbf SYSAUX
3 13279819419 923328 10:22:57 925702 ONLINE 1156 YES/mnt/ramdisk/book/undotbs01.dbf UNDOTBS1
4 13279819419 16143 10:22:57 925702 ONLINE 1243 YES/mnt/ramdisk/book/users01.dbf USERS
5 13279819419 952916 10:22:57 925702 ONLINE 1152 YES/mnt/ramdisk/book/example01.dbf EXAMPLE
6 13279819419 13276257767 10:22:57 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 10:22:57 7 925702 ONLINE 1246 YES/mnt/ramdisk/book/system01.dbf SYSTEM
2 13279819419 1834 10:22:57 925702 ONLINE 1247 YES/mnt/ramdisk/book/sysaux01.dbf SYSAUX
3 13279819419 923328 10:22:57 925702 ONLINE 1156 YES/mnt/ramdisk/book/undotbs01.dbf UNDOTBS1
4 13279819419 16143 10:22:57 925702 ONLINE 1243 YES/mnt/ramdisk/book/users01.dbf USERS
5 13279819419 952916 10:22:57 925702 ONLINE 1152 YES/mnt/ramdisk/book/example01.dbf EXAMPLE
6 13279819660 13276257767 10:26:10 925702 ONLINE 635 YES/mnt/ramdisk/book/tea01.dbf TEA
-- // Check the CHECKPOINT_CHANGE # = 13279819660 of data file 6 (CHECKPOINT_CHANGE # = 13279819419 before the backup starts). This indicates that a file checkpoint is required at the backup start to update the file header scn.

SYS @ book> alter system checkpoint;
System altered.

SYS @ book> alter system checkpoint;
System altered.

SYS @ book> alter system checkpoint;
System altered.
-- // During the backup process, I send the alter system checkpoint three times;

-- // 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 = tag1_1121t102610 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 10:26:55

Starting Control File and SPFILE Autobackup at 10:26:55
Piece handle =/u01/app/oracle/fast_recovery_area/BOOK/autobackup/pai_11_21/o1_mf_s_960632816_f173qj22 _. bkp comment = NONE
Finished Control File and SPFILE Autobackup at 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 10:26:26 7 925702 ONLINE 1249 YES/mnt/ramdisk/book/system01.dbf SYSTEM
2 13279819678 1834 10:26:26 925702 ONLINE 1250 YES/mnt/ramdisk/book/sysaux01.dbf SYSAUX
3 13279819678 923328 10:26:26 925702 ONLINE 1159 YES/mnt/ramdisk/book/undotbs01.dbf UNDOTBS1
4 13279819678 16143 10:26:26 925702 ONLINE 1246 YES/mnt/ramdisk/book/users01.dbf USERS
5 13279819678 952916 10:26:26 925702 ONLINE 1155 YES/mnt/ramdisk/book/example01.dbf EXAMPLE
6 13279819678 13276257767 10:26:26 925702 ONLINE 638 YES/mnt/ramdisk/book/tea01.dbf TEA
6 rows selected.

-- // Check whether the scn written by the backup is 13279819678 or 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 (394917772) * 3 + from dual;
POWER (394917772) * 3 +
-----------------------
13279819660

SYS @ book> select power (394917790) * 3 + from dual;
POWER (394917790) * 3 +
-----------------------
13279819678

-- // The scn Number of CHECKPOINT_CHANGE # indicates that the file header information of the backup file is the file header information read during the backup, rather than the information after multiple alter system checkpint operations.
-- // That is, this part of information has been read to the memory during Backup (the supplementary test below also describes the problem), and finally written to the backup image file header.

-- // I modify my test script again, and the CHECKPOINT_CHANGE # information corresponding to-s 8676. Repeat the test again and only paste the result.

$ 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 81a6 0105 0000 0000 0000 0000 0000 ........................ ........
39 0002000: 0ba2 0000 0100 8001 0000 0000 0000 0104 1292 0000 0000 0000 0004 B 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 ........................ ........
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
77 00021e4: 73fc 8917 0300 0000 f91b 4239 0100 0000 c003 0000 875a 0100 1000 313b 0200 0000 s ?.....? B9 ....?... Z... 1 ;....

-- // You can see that the first 40 seconds have not been written to the file header scn information.

-- // Restore:
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.