ITPub博客

首页 > Linux操作系统 > Linux操作系统 > rman给归档指定备份位置;库先备份盘同时到带库;更改控制文件自备路径;时间点的恢复

rman给归档指定备份位置;库先备份盘同时到带库;更改控制文件自备路径;时间点的恢复

原创 Linux操作系统 作者:shilei1 时间:2012-07-18 08:50:01 0 删除 编辑

在常规rman备份的时候,如果没有在rman配置里设置备份路径,需要给归档也制定个备份路径,否则会备份到D:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_1\DATABASE\ 下。

BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10

INCLUDE CURRENT CONTROLFILE

format 'g:\bk\%t_%u'

 PLUS ARCHIVELOG FILESPERSET 20 format='g:\bk\arch_%U_%T'

DELETE ALL INPUT;



该例子就备份到了上面路径下

 BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10

INCLUDE CURRENT CONTROLFILE

format 'g:\bk\%t_%u'

 PLUS ARCHIVELOG FILESPERSET 20

DELETE ALL INPUT;


一个数据库先是备份到本地磁盘,后来也备份到磁带。备份脚本需要修改,否则在运行delete noprompt obsolete 语句的时候会报错。需要分配个维护通道如下:

RMAN> connect target *

2> RUN {

3> ALLOCATE CHANNEL CH1 DEVICE TYPE DISK;

4> ALLOCATE CHANNEL CH2 DEVICE TYPE DISK;

5> BACKUP DATABASE SKIP INACCESSIBLE FILESPERSET 10

6>    INCLUDE CURRENT CONTROLFILE

7>    PLUS ARCHIVELOG FILESPERSET 20

8>    DELETE ALL INPUT;

9> RELEASE CHANNEL CH1;

10> RELEASE CHANNEL CH2;

11> }

12> allocate channel for maintenance type disk; 

13> delete noprompt obsolete device type disk; 

14> release channel;

15> 


在Oracle10g中,如果我们使用了闪回区,那么控制文件的自动备份会存储在闪回区中。

有时候为了安全,我们需要将控制文件的自动备份转移到其他目录下,这可以使用如下命令。

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/obak/control%F';


new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/obak/control%F';

new RMAN configuration parameters are successfully stored


当然,打开控制文件自动备份需要使用如下命令:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;


new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters are successfully stored


我们建议用户一定要打开这个功能。

现在控制文件的自动备份将指向新的目录:

RMAN> backup datafile 1;


Starting backup at 07-JAN-08

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=12 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

input datafile fno=00001 name=/opt/oracle/oradata/eygle/system01.dbf

channel ORA_DISK_1: starting piece 1 at 07-JAN-08

channel ORA_DISK_1: finished piece 1 at 07-JAN-08

piece handle=/opt/oracle/obak/bkup_3fj5jbqp_1_1 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36

Finished backup at 07-JAN-08


Starting Control File and SPFILE Autobackup at 07-JAN-08

piece handle=/opt/oracle/obak/controlc-1407686520-20080107-00 comment=NONE

Finished Control File and SPFILE Autobackup at 07-JAN-08



基于时间点的恢复

11:58:04 SQL> startup mount;

  ORACLE instance started.

  Total System Global Area 101785428 bytes

  Fixed Size 454484 bytes

  Variable Size 75497472 bytes

  Database Buffers 25165824 bytes

  Redo Buffers 667648 bytes

  Database mounted.

  SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

  11:58:15 SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

  Session altered.

  Elapsed: 00:00:00.00

  11:58:17 SQL> recover database until time '2005-01-17 11:57:28';

  Media recovery complete.

  recover database until time '2010-10-19 18:25:03';

  --恢复到提交完成时刻

  11:58:33 SQL> alter database open resetlogs;

  Database altered.

  Elapsed: 00:00:05.08

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

请登录后发表评论 登录
全部评论

注册时间:2018-10-10

  • 博文量
    530
  • 访问量
    4502