以下是我觉得比较有用,但却比较少用(至少对于我来说)的几个命令吧!
[oracle@hdp autobackup]$ rman target/
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Aug 14 19:20:30 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1477533441)
RMAN> backup duration 00:03 minimize load database;
Starting backup at 14-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=67 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=134 device type=DISK
allocated channel: ORA_DISK_3
(***ignore something ***)
piece handle=/u02/backup/ORCL/backupset/2017_08_14/o1_mf_nnndf_TAG20170814T192123_ds31xn35_.bkp tag=TAG20170814T192123 comment=NONE
channel ORA_DISK_5: backup set complete, elapsed time: 00:02:55
channel ORA_DISK_5: throttle time: 0:02:46
Finished backup at 14-AUG-17
Starting Control File Autobackup at 14-AUG-17
piece handle=/u02/backup/ORCL/autobackup/2017_08_14/o1_mf_n_952025059_ds32338v_.bkp comment=NONE
Finished Control File Autobackup at 14-AUG-17
RMAN> exit
限制备份时间,最低负载
backup duration 00:03 minimize load database;
限制备份速率
CONFIGURE CHANNEL DEVICE TYPE DISK RATE 2048 G;
限制备份通道
CONFIGURE DEVICE TYPE DISK PARALLELISM 6 BACKUP TYPE TO BACKUPSET;
压缩
CONFIGURE COMPRESSION ALGORITHM ‘BASIC’ AS OF RELEASE ‘DEFAULT’ OPTIMIZE FOR LOAD TRUE;
section
RMAN> backup section size 50m tablespace test001;
filesperset
不过这个参数也不是很准,RMAN> backup as compressed backupset database filesperset 8;我们就会发现:
[oracle@hdp 2017_08_15]$ ll
total 222368
-rw-r—–. 1 oracle oinstall 7241728 Aug 15 00:35 o1_mf_nnndf_TAG20170815T003458_ds3n9md4_.bkp
-rw-r—–. 1 oracle oinstall 146989056 Aug 15 00:35 o1_mf_nnndf_TAG20170815T003458_ds3n9mfr_.bkp
-rw-r—–. 1 oracle oinstall 70033408 Aug 15 00:35 o1_mf_nnndf_TAG20170815T003458_ds3n9mhk_.bkp
-rw-r—–. 1 oracle oinstall 1212416 Aug 15 00:35 o1_mf_nnndf_TAG20170815T003458_ds3n9mhz_.bkp
-rw-r—–. 1 oracle oinstall 2228224 Aug 15 00:35 o1_mf_nnndf_TAG20170815T003458_ds3n9mlr_.bkp
比如 RMAN> backup tablespace test001 filesperset 5;
[oracle@hdp 2017_08_15]$ ll -h
total 11M
-rw-r—–. 1 oracle oinstall 11M Aug 15 00:37 o1_mf_nnndf_TAG20170815T003733_ds3ngfxq_.bkp
有人说filesperset 是一个 backupset 中的最大文件数
实验一下
RMAN> backup as compressed backupset database filesperset 3;
[oracle@hdp 2017_08_15]$ ll -h
total 218M
-rw-r—–. 1 oracle oinstall 7.0M Aug 15 00:42 o1_mf_nnndf_TAG20170815T004235_ds3nqvdx_.bkp
-rw-r—–. 1 oracle oinstall 141M Aug 15 00:42 o1_mf_nnndf_TAG20170815T004235_ds3nqvg9_.bkp
-rw-r—–. 1 oracle oinstall 67M Aug 15 00:42 o1_mf_nnndf_TAG20170815T004235_ds3nqvh3_.bkp
-rw-r—–. 1 oracle oinstall 1.2M Aug 15 00:42 o1_mf_nnndf_TAG20170815T004235_ds3nqvjr_.bkp
-rw-r—–. 1 oracle oinstall 2.2M Aug 15 00:42 o1_mf_nnndf_TAG20170815T004235_ds3nqvk1_.bkp
魏武帝曾经说过,鸡肋,食之无味,弃之可惜。但愿是我理解错了!
后来,发现还真的是我理解错了!
The basic algorithm determines the number and size of the backup
pieces by balancing the FILESPERSET and MAXSETSIZE (if used)
parameters of the BACKUP command. The FILESPERSET parameter of the
BACKUP command determines the maximum number of data files in each
backup set. If none is specified, RMAN will calculate this figure by
comparing the value 64 to the rounded-up ratio of number of files
divided by the number of channels, and sets FILESPERSET to the lower
value. For example, if you are backing up 140 files and allocating two
channels, RMAN divides 140 by two, compares the resultant 70 to 64 and
chooses 64 as the value for FILESPERSET. The maximum size of a backup
set is determined by the MAXSETSIZE parameter of the CONFIGURE or
BACKUP command. When you set this, RMAN uses the algorithm to
determine the number of files to write to each set.
如果filesperset 限定的是每个备份集(backupset)最大读取的文件数的话,那么这个是可以理解的!
let’s have a try
这里先分配两个通道,filesperset 设定为3,但是先不限制文件的大小
> RMAN> run 2> { 3> allocate channel c1 type disk; 4> allocate channel
> c2 type disk; 5> backup as compressed backupset database filesperset
> 3; 6> release channel c1; 7> release channel c2; 8> }
>
> released channel: ORA_DISK_1 released channel: ORA_DISK_2 released
> channel: ORA_DISK_3 released channel: ORA_DISK_4 released channel:
> ORA_DISK_5 released channel: ORA_DISK_6 allocated channel: c1 channel
> c1: SID=7 device type=DISK
>
> allocated channel: c2 channel c2: SID=133 device type=DISK
>
> Starting backup at 15-AUG-17 channel c1: starting compressed full
> datafile backup set channel c1: specifying datafile(s) in backup set
> input datafile file number=00004
> name=/u01/app/oracle/oradata/orcl/users01.dbf input datafile file
> number=00005
> name=/u02/oradata/ORCL/datafile/o1_mf_test001_ds17lv9r_.dbf input
> datafile file number=00001
> name=/u01/app/oracle/oradata/orcl/system01.dbf channel c1: starting
> piece 1 at 15-AUG-17 channel c2: starting compressed full datafile
> backup set channel c2: specifying datafile(s) in backup set input
> datafile file number=00002
> name=/u01/app/oracle/oradata/orcl/sysaux01.dbf input datafile file
> number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf channel
> c2: starting piece 1 at 15-AUG-17 channel c2: finished piece 1 at
> 15-AUG-17 piece
> handle=/u02/backup/ORCL/backupset/2017_08_15/o1_mf_nnndf_TAG20170815T214657_ds5ytkph_.bkp
> tag=TAG20170815T214657 comment=NONE channel c2: backup set complete,
> elapsed time: 00:00:15 channel c1: finished piece 1 at 15-AUG-17 piece
> handle=/u02/backup/ORCL/backupset/2017_08_15/o1_mf_nnndf_TAG20170815T214657_ds5ytkoc_.bkp
> tag=TAG20170815T214657 comment=NONE channel c1: backup set complete,
> elapsed time: 00:00:25 Finished backup at 15-AUG-17
>
> Starting Control File and SPFILE Autobackup at 15-AUG-17 piece
> handle=/u02/backup/ORCL/autobackup/2017_08_15/o1_mf_s_952120042_ds5yvbsr_.bkp
> comment=NONE Finished Control File and SPFILE Autobackup at 15-AUG-17
>
> released channel: c1
>
> released channel: c2
>
> RMAN>
查看生成的文件:
[root@hdp 2017_08_15]# ll -h
total 216M
-rw-r-----. 1 oracle oinstall 149M Aug 15 21:47 o1_mf_nnndf_TAG20170815T214657_ds5ytkoc_.bkp
-rw-r-----. 1 oracle oinstall 68M Aug 15 21:47 o1_mf_nnndf_TAG20170815T214657_ds5ytkph_.bkp
这里两个通道生产了两个文件,每个文件属于一个backupset
我希望在一个backupset 中产生多个file piece
我们可以限制section size
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup as compressed backupset database section size 500m filesperset 3;
release channel c1;
release channel c2;
}
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
236 Full 8.47M DISK 00:00:01 15-AUG-17
BP Key: 561 Status: AVAILABLE Compressed: YES Tag: TAG20170815T220035
Piece Name: /u02/backup/ORCL/backupset/2017_08_15/o1_mf_nnndf_TAG20170815T220035_ds5zn3hx_.bkp
List of Datafiles in backup set 236
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
3 Full 1703360 15-AUG-17 /u01/app/oracle/oradata/orcl/undotbs01.dbf
4 Full 1579686 11-AUG-17 /u01/app/oracle/oradata/orcl/users01.dbf
5 Full 1703360 15-AUG-17 /u02/oradata/ORCL/datafile/o1_mf_test001_ds17lv9r_.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
237 Full 141.23M DISK 00:00:11 15-AUG-17
List of Datafiles in backup set 237
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1703361 15-AUG-17 /u01/app/oracle/oradata/orcl/system01.dbf
Backup Set Copy #1 of backup set 237
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:11 15-AUG-17 YES TAG20170815T220035
List of Backup Pieces for backup set 237 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
563 1 AVAILABLE /u02/backup/ORCL/backupset/2017_08_15/o1_mf_nnndf_TAG20170815T220035_ds5zn3jk_.bkp
562 2 AVAILABLE /u02/backup/ORCL/backupset/2017_08_15/o1_mf_nnndf_TAG20170815T220035_ds5zn6my_.bkp
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
238 Full 67.86M DISK 00:00:08 15-AUG-17
List of Datafiles in backup set 238
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 1703366 15-AUG-17 /u01/app/oracle/oradata/orcl/sysaux01.dbf
Backup Set Copy #1 of backup set 238
Device Type Elapsed Time Completion Time Compressed Tag
----------- ------------ --------------- ---------- ---
DISK 00:00:08 15-AUG-17 YES TAG20170815T220035
List of Backup Pieces for backup set 238 Copy #1
BP Key Pc# Status Piece Name
------- --- ----------- ----------
565 1 AVAILABLE /u02/backup/ORCL/backupset/2017_08_15/o1_mf_nnndf_TAG20170815T220035_ds5znfqj_.bkp
564 2 AVAILABLE /u02/backup/ORCL/backupset/2017_08_15/o1_mf_nnndf_TAG20170815T220035_ds5zngtc_.bkp
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
239 Full 10.70M DISK 00:00:01 15-AUG-17
BP Key: 566 Status: AVAILABLE Compressed: NO Tag: TAG20170815T220053
Piece Name: /u02/backup/ORCL/autobackup/2017_08_15/o1_mf_s_952120853_ds5znoyg_.bkp
SPFILE Included: Modification time: 15-AUG-17
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 1703375 Ckp time: 15-AUG-17
RMAN>
以上读取的最大文件数不会超过3