ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle11新特性——备份恢复功能增强(十)

Oracle11新特性——备份恢复功能增强(十)

原创 Linux操作系统 作者:yangtingkun 时间:2007-12-11 00:00:00 0 删除 编辑

打算写一系列的文章介绍11g的新特性和变化。

Oracle11g在备份和恢复方面新增了很多的功能,无论是性能、功能性、安全性和可操作性方面都有了不同程度的提高。

这一篇介绍rman备份脚本的替换变量功能。

Oracle11新特性——备份恢复功能增强(一):http://yangtingkun.itpub.net/post/468/412991

Oracle11新特性——备份恢复功能增强(二):http://yangtingkun.itpub.net/post/468/414647

Oracle11新特性——备份恢复功能增强(三):http://yangtingkun.itpub.net/post/468/414834

Oracle11新特性——备份恢复功能增强(四):http://yangtingkun.itpub.net/post/468/414941

Oracle11新特性——备份恢复功能增强(五):http://yangtingkun.itpub.net/post/468/416015

Oracle11新特性——备份恢复功能增强(六):http://yangtingkun.itpub.net/post/468/423531

Oracle11新特性——备份恢复功能增强(七):http://yangtingkun.itpub.net/post/468/426943

Oracle11新特性——备份恢复功能增强(八):http://yangtingkun.itpub.net/post/468/427877

Oracle11新特性——备份恢复功能增强(九):http://yangtingkun.itpub.net/post/468/429571


11g增加了备份脚本的变量替换功能,提高了备份脚本的灵活性。

看一个简单的例子:

[oracle@yangtk ~]$ vi rman_backup.sh

rman target / << EOF
{
allocate channel c1 device type disk format '/data1/backup/%U';
backup database tag regular_backup_071211;
}
EOF

编写一个简单的备份脚本,将文件属性设置为可以执行:

[oracle@yangtk ~]$ chmod 744 rman_backup.sh

下面就可以执行这个脚本对数据库进行备份了:

[oracle@yangtk ~]$ . rman_backup.sh

Recovery Manager: Release 11.1.0.6.0 - Production on Sat Nov 10 07:08:49 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: ORA11G (DBID=4026820313)

RMAN> 2> 3> 4> 5>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=135 device type=DISK
released channel: c1

Starting backup at 10-NOV-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK
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=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_system_3d3795py_.dbf
input datafile file number=00002 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_sysaux_3d379f1s_.dbf
input datafile file number=00003 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_undotbs1_3d379k48_.dbf
input datafile file number=00005 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_yangtk_3d3kn7k4_.dbf
input datafile file number=00006 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_yangtk_3g73q02m_.dbf
input datafile file number=00004 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_users_3d37bq45_.dbf
channel ORA_DISK_1: starting piece 1 at 10-NOV-07
channel ORA_DISK_1: finished piece 1 at 10-NOV-07
piece handle=/data1/backup/1oj0m784_1_1 tag=REGULAR_BACKUP_071211 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:56
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 10-NOV-07
channel ORA_DISK_1: finished piece 1 at 10-NOV-07
piece handle=/data1/backup/1pj0m7e0_1_1 tag=REGULAR_BACKUP_071211 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 10-NOV-07

使用脚本虽然很方便,但是不够灵活,有的时候希望更改一些参数,甚至是动态输入一些参数。11g新增的替换变量功能使得这种需求可以很简单的实现。

首先创建一个RMAN命令文件:

[oracle@yangtk ~]$ vi rman_command.cmd

run
{
allocate channel c1 device type disk format '/data1/&1/%U';
backup database tag &2;
}

这样在rman中就可以直接调用了:

[oracle@yangtk ~]$ rman target /

Recovery Manager: Release 11.1.0.6.0 - Production on Sat Nov 10 07:49:33 2007

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: ORA11G (DBID=4026820313)

RMAN> @rman_command.cmd 'backup' 'tag_var_071211'


RMAN> run
2> {
3> allocate channel c1 device type disk format '/data1/backup/%U';
4> backup database tag tag_var_071211;
5> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=106 device type=DISK

Starting backup at 10-NOV-07
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_system_3d3795py_.dbf
input datafile file number=00002 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_sysaux_3d379f1s_.dbf
input datafile file number=00003 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_undotbs1_3d379k48_.dbf
input datafile file number=00005 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_yangtk_3d3kn7k4_.dbf
input datafile file number=00006 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_yangtk_3g73q02m_.dbf
input datafile file number=00004 name=/data/oracle/oradata/ora11g/ORA11G_P/datafile/o1_mf_users_3d37bq45_.dbf
channel c1: starting piece 1 at 10-NOV-07
channel c1: finished piece 1 at 10-NOV-07
piece handle=/data1/backup/1tj0m9lh_1_1 tag=TAG_VAR_071211 comment=NONE
channel c1: backup set complete, elapsed time: 00:03:38
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 10-NOV-07
channel c1: finished piece 1 at 10-NOV-07
piece handle=/data1/backup/1uj0m9sk_1_1 tag=TAG_VAR_071211 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
Finished backup at 10-NOV-07
released channel: c1

RMAN>
RMAN> **end-of-file**

RMAN>

这种变量替换还可以使用在SCRIPTS中。这里就不描述了。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/4227/viewspace-69537/,如需转载,请注明出处,否则将追究法律责任。

上一篇: DIM-00003错误
请登录后发表评论 登录
全部评论
暂无介绍

注册时间:2007-12-29

  • 博文量
    1955
  • 访问量
    10390153