[20190517]rman tape compressed.txt
[20190517]rman tape compressed.txt
--//前一段測試rman選擇壓縮備份時,如果備份單個資料檔案小於64M-3*8K時,先建立大小64M檔案,最後會回收到自己的備份大小.
--//連結:[20190509]rman備份的疑問5.txt
--//測試也說明開始建立的檔案時稀疏檔案,自己有1個奇怪的想法,如果使用磁帶方式,磁帶是流式裝置,oracle的rman會如何處理這
--//些細節呢?不管結果如何,還是透過測試說明問題。
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
CREATE TABLESPACE T01 DATAFILE '/mnt/ramdisk/book/t01.dbf' SIZE 40M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT
LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT MANUAL;
ALTER DATABASE DATAFILE '/mnt/ramdisk/book/t01.dbf' RESIZE 65512K;
create table t01 tablespace t01 as select rownum id ,lpad('A',32,'A') name from dual connect by level<=7e5;
2.測試:
--//說明我沒有磁帶,不過oracle提供模式磁帶庫的方式(實際上現在許多知名的備份軟體實際上使用虛擬磁帶庫)。
CONFIGURE CHANNEL DEVICE TYPE SBT PARMS 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/backup)';
CONFIGURE DEFAULT DEVICE TYPE TO SBT_TAPE ;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 5M;
--//執行如下:
RMAN> CONFIGURE CHANNEL DEVICE TYPE SBT PARMS 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/backup)';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/backup)';
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO SBT_TAPE ;
old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;
old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
new RMAN configuration parameters are successfully stored
RMAN> CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 1M;
new RMAN configuration parameters:
CONFIGURE CHANNEL 1 DEVICE TYPE DISK RATE 1 M;
new RMAN configuration parameters are successfully stored
--//還原指令碼:
--//CONFIGURE CHANNEL DEVICE TYPE SBT_TAPE clear;
--//CONFIGURE DEFAULT DEVICE TYPE TO DISK;
--//建立測試指令碼:
$ cat ts.sh
#! /bin/bash
file=$1
>| /tmp/xx_${file}
>| /tmp/yy_${file}
strace -ftt -x -o /tmp/tt_${file}.txt rman target / <<< "backup as compressed backupset datafile "$file" format \"/u01/backup/T_"${file}"_%U\" ;" &
seq 30 | xargs -I{} echo "ls -l /u01/backup/T_${file}_*;sleep 0.5" | bash 2>/dev/null| ts.awk >> /tmp/xx_${file} 2>/dev/null &
seq 30 | xargs -I{} echo "stat -c '%s %b %B' /u01/backup/T_${file}_*;sleep 0.5" | bash 2>/dev/null | ts.awk >> /tmp/yy_${file} 2>/dev/null &
wait
$ . ts.sh 9
Recovery Manager: Release 11.2.0.4.0 - Production on Wed May 22 08:46:31 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: BOOK (DBID=1337401710)
RMAN>
Starting backup at 2019-05-22 08:46:34
using target database control file instead of recovery catalog
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=59 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API
channel ORA_SBT_TAPE_1: starting compressed full datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/mnt/ramdisk/book/t01.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 2019-05-22 08:46:36
channel ORA_SBT_TAPE_1: finished piece 1 at 2019-05-22 08:46:37
piece handle=/u01/backup/T_9_2tu25tnc_1_1 tag=TAG20190522T084635 comment=API Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2019-05-22 08:46:37
RMAN>
Recovery Manager complete.
[1] Done strace -ftt -x -o /tmp/tt_${file}.txt rman target / <<< "backup as compressed backupset datafile "$file" format \"/u01/backup/T_"${file}"_%U\" ;"
[2]- Done seq 30 | xargs -I{} echo "ls -l /u01/backup/T_${file}_*;sleep 0.5" | bash 2> /dev/null | ts.awk >> /tmp/xx_${file} 2> /dev/null
[3]+ Done seq 30 | xargs -I{} echo "stat -c '%s %b %B' /u01/backup/T_${file}_*;sleep 0.5" | bash 2> /dev/null | ts.awk >> /tmp/yy_${file} 2> /dev/null
$ ls -l Oracle_Disk_SBT_Catalog T_9_2tu25tnc_1_1
-rw-r--r-- 1 oracle oinstall 3360 2019-05-22 08:46:36 Oracle_Disk_SBT_Catalog
-rw-r--r-- 1 oracle oinstall 8388624 2019-05-22 08:46:36 T_9_2tu25tnc_1_1
$ cat /tmp/xx_9
[2019-05-22 08:46:36] -rw-r--r-- 1 oracle oinstall 4194320 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:37] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:37] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:38] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:38] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:39] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:39] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:40] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:40] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:41] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:41] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:42] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:42] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:43] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:43] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:44] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:44] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:45] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:45] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
[2019-05-22 08:46:46] -rw-r--r-- 1 oracle oinstall 8388624 May 22 08:46 /u01/backup/T_9_2tu25tnc_1_1
$ cat /tmp/yy_9
[2019-05-22 08:46:36] 4194320 8208 512
[2019-05-22 08:46:37] 8388624 16416 512
[2019-05-22 08:46:37] 8388624 16416 512
[2019-05-22 08:46:38] 8388624 16416 512
[2019-05-22 08:46:38] 8388624 16416 512
[2019-05-22 08:46:39] 8388624 16416 512
[2019-05-22 08:46:39] 8388624 16416 512
[2019-05-22 08:46:40] 8388624 16416 512
[2019-05-22 08:46:40] 8388624 16416 512
[2019-05-22 08:46:41] 8388624 16416 512
[2019-05-22 08:46:41] 8388624 16416 512
[2019-05-22 08:46:42] 8388624 16416 512
[2019-05-22 08:46:42] 8388624 16416 512
[2019-05-22 08:46:43] 8388624 16416 512
[2019-05-22 08:46:43] 8388624 16416 512
[2019-05-22 08:46:44] 8388624 16416 512
[2019-05-22 08:46:44] 8388624 16416 512
[2019-05-22 08:46:45] 8388624 16416 512
[2019-05-22 08:46:45] 8388624 16416 512
[2019-05-22 08:46:46] 8388624 16416 512
--//4194320/1024/1024 = 4.0000152587890625
0.0000152587890625*1024*1024 = 16
--//你可以發現備份檔案集並沒有建立稀疏檔案.而且一開始就建立大小大於4M+16位元組的檔案.
--//8388624/1024/1024 = 8.00001525878906250000,最後大小是壓縮的.
$ strings T_9_2tu25tnc_1_1 | grep AAAAAAAAAAAAAAAAAAAAAAAA|wc
64579 109753 2336114
--//有點奇怪的是僅僅看到AAAAAAAAAAAAAAAAAAAAAAAA是64579,應該至少7E5.
--//700000-64579 = 635421有這麼多AAAAA涉及壓縮.
SCOTT@book> select sum(bytes)/1024/1024 from dba_extents where file_id=9;
SUM(BYTES)/1024/1024
--------------------
33
--//33M.這麼講實際上還是存在可以實現壓縮的.
$ strings -t d T_9_2tu25tnc_1_1 | grep AAAAAAAAAAAAAAAAAAAAAAAA| tail
4193914 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4193955 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4193996 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4194037 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4194078 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4194119 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4194160 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4194201 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4194242 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
4194283 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
--//最後1個AAAAA出現的位置在4194283,4194283/1024/1024 = 3.99997997283935546875,前面4M之內.
--//也就是可以大致推斷前面4M是不壓縮的,後面才壓縮.不然建立的備份檔案不會是8M.
3.重新測試:
$ cat dx.sql
drop tablespace t&1 including contents and datafiles;
CREATE TABLESPACE T&1 DATAFILE '/mnt/ramdisk/book/T&1..dbf' SIZE 40M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
create table t&1 tablespace t&1 as select rownum id ,to_char(rownum,'FM000000')||lpad('&&2',26,'&&2') name from dual connect by level<=7e5;
SCOTT@book> @ dx.sql 01 B
old 1: drop tablespace t&1 including contents and datafiles
new 1: drop tablespace t01 including contents and datafiles
Tablespace dropped.
old 1: CREATE TABLESPACE T&1 DATAFILE '/mnt/ramdisk/book/T&1..dbf' SIZE 40M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON
new 1: CREATE TABLESPACE T01 DATAFILE '/mnt/ramdisk/book/T01.dbf' SIZE 40M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON
Tablespace created.
old 1: create table t&1 tablespace t&1 as select rownum id ,to_char(rownum,'FM000000')||lpad('&&2',26,'&&2') name from dual connect by level<=6e5
new 1: create table t01 tablespace t01 as select rownum id ,to_char(rownum,'FM000000')||lpad('B',26,'B') name from dual connect by level<=6e5
Table created.
--//刪除前面的備份重複測試.
--//RMAN> delete backupset ;
$ . ts.sh 9
Recovery Manager: Release 11.2.0.4.0 - Production on Wed May 22 09:07:27 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: BOOK (DBID=1337401710)
RMAN>
Starting backup at 2019-05-22 09:07:30
using target database control file instead of recovery catalog
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=114 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: WARNING: Oracle Test Disk API
channel ORA_SBT_TAPE_1: starting compressed full datafile backup set
channel ORA_SBT_TAPE_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/mnt/ramdisk/book/T01.dbf
channel ORA_SBT_TAPE_1: starting piece 1 at 2019-05-22 09:07:32
channel ORA_SBT_TAPE_1: finished piece 1 at 2019-05-22 09:07:33
piece handle=/u01/backup/T_9_2uu25uuk_1_1 tag=TAG20190522T090732 comment=API Version 2.0,MMS Version 8.1.3.0
channel ORA_SBT_TAPE_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2019-05-22 09:07:33
RMAN>
Recovery Manager complete.
[1] Done strace -ftt -x -o /tmp/tt_${file}.txt rman target / <<< "backup as compressed backupset datafile "$file" format \"/u01/backup/T_"${file}"_%U\" ;"
[2]- Done seq 30 | xargs -I{} echo "ls -l /u01/backup/T_${file}_*;sleep 0.5" | bash 2> /dev/null | ts.awk >> /tmp/xx_${file} 2> /dev/null
[3]+ Done seq 30 | xargs -I{} echo "stat -c '%s %b %B' /u01/backup/T_${file}_*;sleep 0.5" | bash 2> /dev/null | ts.awk >> /tmp/yy_${file} 2> /dev/null
SELECT set_count
,device_type
,TYPE
,filename
,buffer_size
,buffer_count
,open_time
,close_time
FROM v$backup_async_io
where set_count=94
ORDER BY set_count
,TYPE
,open_time
,close_time;
SET_COUNT DEVICE_TYPE TYPE FILENAME BUFFER_SIZE BUFFER_COUNT OPEN_TIME CLOSE_TIME
---------- ----------------- --------- ------------------------------ ----------- ------------ ------------------- -------------------
94 DISK AGGREGATE 0 0 2019-05-22 09:07:32 2019-05-22 09:07:32
94 DISK INPUT /mnt/ramdisk/book/T01.dbf 1048576 16 2019-05-22 09:07:32 2019-05-22 09:07:32
$ head -2 /tmp/xx_9 /tmp/yy_9
==> /tmp/xx_9 <==
[2019-05-22 09:07:32] -rw-r--r-- 1 oracle oinstall 4194320 May 22 09:07 /u01/backup/T_9_2uu25uuk_1_1
[2019-05-22 09:07:32] -rw-r--r-- 1 oracle oinstall 8388624 May 22 09:07 /u01/backup/T_9_2uu25uuk_1_1
--//(8388624-4194320)/1024/1024 = 4
==> /tmp/yy_9 <==
[2019-05-22 09:07:32] 4194320 8208 512
[2019-05-22 09:07:32] 8388624 16416 512
$ strings -t d T_9_2uu25uuk_1_1 | grep BBBBBBBBBBBBB| tail
4193913 % 062236BBBBBBBBBBBBBBBBBBBBBBBBBB,
4193954 $ 062235BBBBBBBBBBBBBBBBBBBBBBBBBB,
4193995 # 062234BBBBBBBBBBBBBBBBBBBBBBBBBB,
4194036 o 062233BBBBBBBBBBBBBBBBBBBBBBBBBB,
4194077 ! 062232BBBBBBBBBBBBBBBBBBBBBBBBBB,
4194118 062231BBBBBBBBBBBBBBBBBBBBBBBBBB,
4194160 062230BBBBBBBBBBBBBBBBBBBBBBBBBB,
4194201 062229BBBBBBBBBBBBBBBBBBBBBBBBBB,
4194242 062228BBBBBBBBBBBBBBBBBBBBBBBBBB,
4194283 062227BBBBBBBBBBBBBBBBBBBBBBBBBB
SCOTT@book> select rowid,t01.* from t01 where id=062227;
ROWID ID NAME
------------------ ---------- ----------------------------------------
ACgY2MAAJAAAAH/AAA 62227 062227BBBBBBBBBBBBBBBBBBBBBBBBBB
SCOTT@book> @ rowid ACgY2MAAJAAAAH/AAA
OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
42044812 9 511 0 0x24001FF 9,511 alter system dump datafile 9 block 511 ;
--//在dba=9,511位置.511*8192 = 4186112 ,行號=0,資料從塊底部開始插入.所以tail看到的最後1行是行號0.
$ ls -l T_9_2uu25uuk_1_1
-rw-r--r-- 1 oracle oinstall 8388624 2019-05-22 09:07:32 T_9_2uu25uuk_1_1
--//可以看出使用磁碟模擬還是可以壓縮的,僅僅前面4M不壓縮(注我僅僅測試備份集包含單個檔案的情況)為什麼一些虛擬帶庫不支援壓縮呢?
--//另外視乎虛擬帶庫的檔案建立按照4M大小建立的.
--//看來應該建議他們測試看看,是否支援壓縮方式.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2645144/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20221028]rman使用tape與增量備份測試2.txt
- Tape-out Checklist FormORM
- 【RMAN】RMAN備份至ASMASM
- Oracle 11G RAC複製備庫RMAN-03002 RMAN-05501 RMAN-03015 RMAN-03009 RMAN-10038Oracle
- 【RMAN】RMAN的備份保留策略
- ORACLE rman與RMAN-00054&ORA-09945Oracle
- RMAN(轉)
- RMAN恢復之RMAN-06555處理
- 【RMAN】Oracle rman 常用命令參考Oracle
- RMAN-06207和RMAN-06208的處理
- 【RMAN】在備庫執行rman備份時報錯RMAN-06820 ORA-17629
- RMAN增量恢復
- RMAN備份概述
- oracle手工建庫後rman無法啟用(RMAN-04015)Oracle
- [譯] JavaScript 單元測試框架:Jasmine, Mocha, AVA, Tape 和 Jest 的比較JavaScript框架ASM
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- 【RMAN】Oracle11g透過rman升級到12cOracle
- RMAN修復壞塊
- RMAN恢復實踐
- RMAN-06214: Datafile Copy
- [20191122]RMAN-03999.txt
- RMAN Duplicate RAC to Single Instance
- RMAN備份進度
- rman 備份指令碼指令碼
- RMAN中的通道分配
- RMAN的備份原理
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- 【RMAN】在多租戶環境下的RMAN備份及恢復
- 資料遷移的時候出現RMAN-03002,RMAN-06026
- RMAN之環境配置(一)
- RMAN備份恢復技巧
- 【rman備份策略】實驗
- Oracle RMAN恢復測試Oracle
- Oracle RMAN備份實戰Oracle
- Oracle OCP(60):RMAN 備份Oracle
- rman duplicate操作手冊
- rman 增量備份恢復
- RMAN命令LIST操作總結