rman channel是无限制的吗?
我们在rman备份或者还原的时候,为了增加备份或者还原恢复的速度,
我们可以开启多个备份还原的进程。然而在平时的工作中,有同事跟我说
开的channel越多那么恢复的越快,是这样吗?答案是否定的.
先说结论: max(channel)=cpu_count
cpu_count,是指linux服务器的进程。具体来说是CPU的逻辑数量。
在Linux服务器中,我们可以用如下两种方式得到该值。
oracle会读取cpu_count
SQL> show parameter cpu_count
cpu_count integer 4[oracle@hdp 2017_08_11]$ mpstat
Linux 2.6.32-358.el6.x86_64
(hdp.oracle.com) 08/11/2017 x86_64 (4 CPU)07:45:51 AM CPU %usr %nice %sys %iowait %irq %soft
%steal %guest %idle 07:45:51 AM all 0.07 0.00 0.05
0.02 0.00 0.00 0.00 0.00 99.87
或者
[oracle@hdp 2017_08_11]$ cat /proc/cpuinfo| grep "processor"| wc -l
4
如上是我的虚拟机,只有4个cput_count.
[oracle@hdp 2017_08_11]$ cat rman.sh
run{ allocate channel c1 type
disk; allocate channel c2 type disk; allocate channel c3 type disk;
allocate channel c4 type disk; allocate channel c5 type disk; allocate
channel c6 type disk; backup as compressed backupset database plus
archivelog; release channel c1; release channel c2; release channel
c3; release channel c4; release channel c5; release channel c6; }
在上面的rman脚本中,我定义了六个通道
跑一下试试
[oracle@hdp 2017_08_11]$ rman target/
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Aug 11
07:49:08 2017Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights
reserved.connected to target database: ORCL (DBID=1477533441)
RMAN> @rman.sh
RMAN> run{ 2> allocate channel c1 type disk; 3> allocate channel c2
type disk; 4> allocate channel c3 type disk; 5> allocate channel c4
type disk; 6> allocate channel c5 type disk; 7> allocate channel c6
type disk; 8> backup as compressed backupset database plus archivelog;
9> release channel c1; 10> release channel c2; 11> release channel c3;
12> release channel c4; 13> release channel c5; 14> release channel
c6; 15> } using target database control file instead of recovery
catalog allocated channel: c1 channel c1: SID=134 device type=DISKallocated channel: c2 channel c2: SID=198 device type=DISK
allocated channel: c3 channel c3: SID=12 device type=DISK
allocated channel: c4 channel c4: SID=71 device type=DISK
allocated channel: c5 channel c5: SID=135 device type=DISK
allocated channel: c6 channel c6: SID=199 device type=DISK
Starting backup at 11-AUG-17 current log archived channel c1: starting
compressed archived log backup set channel c1: specifying archived
log(s) in backup set input archived log thread=1 sequence=25 RECID=1
STAMP=951724160 channel c1: starting piece 1 at 11-AUG-17 channel c1:
finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_annnn_TAG20170811T074920_drsw80op_.bkp
tag=TAG20170811T074920 comment=NONE channel c1: backup set complete,
elapsed time: 00:00:01 Finished backup at 11-AUG-17Starting backup at 11-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 channel c1: starting
piece 1 at 11-AUG-17 channel c2: starting compressed full datafile
backup set channel c2: specifying datafile(s) in backup set input
datafile file number=00001
name=/u01/app/oracle/oradata/orcl/system01.dbf channel c2: starting
piece 1 at 11-AUG-17 channel c3: starting compressed full datafile
backup set channel c3: specifying datafile(s) in backup set input
datafile file number=00002
name=/u01/app/oracle/oradata/orcl/sysaux01.dbf channel c3: starting
piece 1 at 11-AUG-17 channel c4: starting compressed full datafile
backup set channel c4: specifying datafile(s) in backup set input
datafile file number=00003
name=/u01/app/oracle/oradata/orcl/undotbs01.dbf channel c4: starting
piece 1 at 11-AUG-17 channel c4: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw825m_.bkp
tag=TAG20170811T074921 comment=NONE channel c4: backup set complete,
elapsed time: 00:00:01 channel c1: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw820o_.bkp
tag=TAG20170811T074921 comment=NONE channel c1: backup set complete,
elapsed time: 00:00:03 channel c3: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw823s_.bkp
tag=TAG20170811T074921 comment=NONE channel c3: backup set complete,
elapsed time: 00:00:15 channel c2: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw8222_.bkp
tag=TAG20170811T074921 comment=NONE channel c2: backup set complete,
elapsed time: 00:00:25 Finished backup at 11-AUG-17Starting backup at 11-AUG-17 current log archived channel c1: starting
compressed archived log backup set channel c1: specifying archived
log(s) in backup set input archived log thread=1 sequence=26 RECID=2
STAMP=951724187 channel c1: starting piece 1 at 11-AUG-17 channel c1:
finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_annnn_TAG20170811T074947_drsw8vbb_.bkp
tag=TAG20170811T074947 comment=NONE channel c1: backup set complete,
elapsed time: 00:00:01 Finished backup at 11-AUG-17Starting Control File and SPFILE Autobackup at 11-AUG-17 piece
handle=/u02/backup/ORCL/autobackup/2017_08_11/o1_mf_s_951724188_drsw8wg6_.bkp
comment=NONE Finished Control File and SPFILE Autobackup at 11-AUG-17released channel: c1
released channel: c2
released channel: c3
released channel: c4
released channel: c5
released channel: c6
RMAN> end-of-file
RMAN>
其实仔细观察,真正分配的也就四个通道。
Starting backup at 11-AUG-17 current log archived channel c1: starting
compressed archived log backup set channel c1: specifying archived
log(s) in backup set input archived log thread=1 sequence=25 RECID=1
STAMP=951724160 channel c1: starting piece 1 at 11-AUG-17 channel c1:
finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_annnn_TAG20170811T074920_drsw80op_.bkp
tag=TAG20170811T074920 comment=NONE channel c1: backup set complete,
elapsed time: 00:00:01 Finished backup at 11-AUG-17Starting backup at 11-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 channel c1: starting
piece 1 at 11-AUG-17 channel c2: starting compressed full datafile
backup set channel c2: specifying datafile(s) in backup set input
datafile file number=00001
name=/u01/app/oracle/oradata/orcl/system01.dbf channel c2: starting
piece 1 at 11-AUG-17 channel c3: starting compressed full datafile
backup set channel c3: specifying datafile(s) in backup set input
datafile file number=00002
name=/u01/app/oracle/oradata/orcl/sysaux01.dbf channel c3: starting
piece 1 at 11-AUG-17 channel c4: starting compressed full datafile
backup set channel c4: specifying datafile(s) in backup set input
datafile file number=00003
name=/u01/app/oracle/oradata/orcl/undotbs01.dbf channel c4: starting
piece 1 at 11-AUG-17 channel c4: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw825m_.bkp
tag=TAG20170811T074921 comment=NONE channel c4: backup set complete,
elapsed time: 00:00:01 channel c1: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw820o_.bkp
tag=TAG20170811T074921 comment=NONE channel c1: backup set complete,
elapsed time: 00:00:03 channel c3: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw823s_.bkp
tag=TAG20170811T074921 comment=NONE channel c3: backup set complete,
elapsed time: 00:00:15 channel c2: finished piece 1 at 11-AUG-17 piece
handle=/u02/backup/ORCL/backupset/2017_08_11/o1_mf_nnndf_TAG20170811T074921_drsw8222_.bkp
tag=TAG20170811T074921 comment=NONE channel c2: backup set complete,
elapsed time: 00:00:25 Finished backup at 11-AUG-17
所以我再次确认我的公式: max(channel)=cpu_count
2017.9.3 这篇文章的观点可能是错误了,但是过了这么久,居然也没有人愿意点出来。我将在后续更正
rman channel的定义
The RMAN client itself does not perform backup, restore, or recovery
operations. When you connect the RMAN client to a target database,
RMAN allocates server sessions on the target instance and directs them
to perform the operations.An RMAN channel represents one stream of data to a device, and
corresponds to one database server session. The channel reads data
into PGA memory, processes it, and writes it to the output device.
简而言之,rman channel其实是一个服务器会话
下图是rman channel的一个示意图
最高可以为一个备份恢复脚本分配255个channel,且每个channel一次性可以读取max(files)=64
You can allocate up to 255 channels; each channel can read up to 64 files in parallel. You can control the degree of parallelism within a job by the number of channels that you allocate. Allocating multiple channels simultaneously allows a single job to read or write multiple backup sets or disk copies in parallel, which each channel operating on a separate backup set or copy.