设为首页 收藏本站
查看: 1132|回复: 0

[经验分享] Oracle 学习之RMAN(三)全量备份

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-31 08:29:50 | 显示全部楼层 |阅读模式
  我们已经知道如何进入rman,并连接到需要备份的数据库上。那么如何使用rman备份,以及rman能备份哪些东西呢?
  • 备份数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
RMAN> backup database;

Starting backup at 2015/07/08 00:58:27
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/devdb/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/devdb/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/devdb/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/devdb/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/devdb/idx01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/devdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015/07/08 00:58:28
channel ORA_DISK_1: finished piece 1 at 2015/07/08 01:00:33
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T005827_bsr19n9z_.bkp tag=TAG20150708T005827 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015/07/08 01:00:34
channel ORA_DISK_1: finished piece 1 at 2015/07/08 01:00:35
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncsnf_TAG20150708T005827_bsr1flnq_.bkp tag=TAG20150708T005827 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 01:00:35



  • 备份表空间

1
2
3
4
5
6
7
8
9
10
11
12
RMAN> backup tablespace users ;

Starting backup at 2015/07/08 01:59:43
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/devdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015/07/08 01:59:43
channel ORA_DISK_1: finished piece 1 at 2015/07/08 01:59:44
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T015943_bsr4whv0_.bkp tag=TAG20150708T015943 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 01:59:44



  • 备份数据文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
RMAN> backup datafile '/u01/app/oracle/oradata/devdb/system01.dbf';

Starting backup at 2015/07/08 02:01:07
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/devdb/system01.dbf
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:01:08
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:01:33
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T020108_bsr4z487_.bkp tag=TAG20150708T020108 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:01:34
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:01:35
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncsnf_TAG20150708T020108_bsr4zygn_.bkp tag=TAG20150708T020108 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 02:01:35



需要说明的一点时,RMAN无法备份临时文件。其实道理很简单,临时文件根本没有必要备份。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
RMAN> backup datafile '/u01/app/oracle/oradata/devdb/temp01.dbf';

Starting backup at 2015/07/08 02:02:24
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 07/08/2015 02:02:24
RMAN-20201: datafile not found in the recovery catalog
RMAN-06010: error while looking up datafile: /u01/app/oracle/oradata/devdb/temp01.dbf

RMAN> backup tempfile '/u01/app/oracle/oradata/devdb/temp01.dbf';

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "tempfile": expecting one of: "archivelog, as, auxiliary, backupset, backup, channel, check, controlfilecopy, copies, copy, cumulative, current, database, datafilecopy, datafile, db_file_name_convert, db_recovery_file_dest, device, diskratio, duration, filesperset, force, format, for, from, full, incremental, keep, maxsetsize, nochecksum, noexclude, nokeep, not, pool, proxy, recovery, reuse, section, skip readonly, skip, spfile, tablespace, tag, to, validate, ("
RMAN-01007: at line 1 column 8 file: standard input



  • 备份控制文件

  • 手工备份控制文件

1
2
3
4
5
6
7
8
9
10
11
12
RMAN> backup current controlfile;

Starting backup at 2015/07/08 02:08:15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:08:16
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:08:17
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncnnf_TAG20150708T020815_bsr5djdz_.bkp tag=TAG20150708T020815 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 02:08:17



2. INCLUDE CURRENT CONTROLFILE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
RMAN> BACKUP DATAFILE '/u01/app/oracle/oradata/devdb/example01.dbf' INCLUDE CURRENT CONTROLFILE;

Starting backup at 2015/07/08 02:13:22
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/devdb/example01.dbf
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:13:22
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:13:29
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T021322_bsr5p2of_.bkp tag=TAG20150708T021322 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:13:30
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:13:31
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_ncnnf_TAG20150708T021322_bsr5pbv3_.bkp tag=TAG20150708T021322 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 02:13:31



无论进行什么备份,只要在备份语句后面加上INCLUDE CURRENT CONTROLFILE,RMAN就会自动备份controlfile 。
3. 通过配置RMAN的参数,让rman无论在做了何种备份时都会自动备份controlfile。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
RMAN> SHOW CONTROLFILE AUTOBACKUP;

RMAN configuration parameters for database with db_unique_name DEVDB are:
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> BACKUP DATAFILE '/u01/app/oracle/oradata/devdb/undotbs01.dbf';

Starting backup at 2015/07/08 02:18:38
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/devdb/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:18:38
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:18:39
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T021838_bsr5zyb4_.bkp tag=TAG20150708T021838 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 02:18:39

Starting Control File and SPFILE Autobackup at 2015/07/08 02:18:39
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/autobackup/2015_07_08/o1_mf_s_884485119_bsr5zzrp_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2015/07/08 02:18:40



设置了CONTROLFILE AUTOBACKUP ON后,rman不光自动备份控制文件,连spfile也一同被备份。

  如果你仔细留意备份时打印的信息,你就是会发现当我们执行backup database时,即便CONTROLFILE AUTOBACKUP设置成off。rman也会自动备份控制文件和spfile。因为默认情况下,rman把controlfile与spfile当成是数据库的一部分。
  • 备份归档日志

  • 执行backup archivelog命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
RMAN> backup archivelog all;

Starting backup at 2015/07/08 02:36:09
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=7 STAMP=884486041
input archived log thread=1 sequence=17 RECID=8 STAMP=884486144
input archived log thread=1 sequence=18 RECID=9 STAMP=884486148
input archived log thread=1 sequence=19 RECID=10 STAMP=884486151
input archived log thread=1 sequence=20 RECID=11 STAMP=884486169
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:36:09
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:36:10
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_annnn_TAG20150708T023609_bsr70spk_.bkp tag=TAG20150708T023609 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 02:36:10

Starting Control File and SPFILE Autobackup at 2015/07/08 02:36:10
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/autobackup/2015_07_08/o1_mf_s_884486170_bsr70v0k_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2015/07/08 02:36:11



2. 执行backup命令时,添加plus archivelog子句。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
RMAN> backup database plus archivelog;


Starting backup at 2015/07/08 02:41:08
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=7 STAMP=884486041
input archived log thread=1 sequence=17 RECID=8 STAMP=884486144
input archived log thread=1 sequence=18 RECID=9 STAMP=884486148
input archived log thread=1 sequence=19 RECID=10 STAMP=884486151
input archived log thread=1 sequence=20 RECID=11 STAMP=884486169
input archived log thread=1 sequence=21 RECID=12 STAMP=884486468
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:41:08
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:41:09
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_annnn_TAG20150708T024108_bsr7b4wr_.bkp tag=TAG20150708T024108 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 02:41:09

Starting backup at 2015/07/08 02:41:09
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/devdb/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/devdb/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/devdb/example01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/devdb/undotbs01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/devdb/idx01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/devdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:41:10
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:42:05
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_nnndf_TAG20150708T024110_bsr7b68z_.bkp tag=TAG20150708T024110 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 2015/07/08 02:42:05

Starting backup at 2015/07/08 02:42:05
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=22 RECID=13 STAMP=884486525
channel ORA_DISK_1: starting piece 1 at 2015/07/08 02:42:05
channel ORA_DISK_1: finished piece 1 at 2015/07/08 02:42:06
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/backupset/2015_07_08/o1_mf_annnn_TAG20150708T024205_bsr7cxsd_.bkp tag=TAG20150708T024205 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015/07/08 02:42:06

Starting Control File and SPFILE Autobackup at 2015/07/08 02:42:06
piece handle=/u01/app/oracle/fast_recovery_area/DEVDB/autobackup/2015_07_08/o1_mf_s_884486526_bsr7cz3l_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 2015/07/08 02:42:07



这种方式与上种有什么区别呢,区别太明显了,BACKUP.....PLUS ARCHIVELOG命令在备份过程中会依次执行下列步骤:
1>.运行ALTER SYSTEM ARCHIVE LOG CURRENT语句对当前redolog进行归档。
2>.执行BACKUP ARCHIVELOG ALL命令备份所有已归档日志。
3>.执行BACKUP命令对指定项进行备份。
4>.再次运行ALTER SYSTEM ARCHIVE LOG CURRENT对当前redolog归档。
5>.对新生成的尚未备份的归档文件进行备份。



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-92466-1-1.html 上篇帖子: Oracle 学习之RMAN(二)由此开始 下篇帖子: Oracle 学习之RMAN(四)增量备份 Oracle
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表