rman压缩备份本地数据库,进行异地恢复操作-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 2090598
  • 博文数量: 195
  • 博客积分: 4378
  • 博客等级: 上校
  • 技术积分: 4046
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-09 11:37
个人简介

白天和黑夜只交替没交换无法想像对方的世界

文章分类

全部博文(195)

文章存档

2014年(3)

2013年(20)

2012年(18)

2011年(107)

2010年(17)

2009年(5)

2008年(20)

2007年(5)

相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2011-08-03 00:06:17

rman压缩备份本地数据库,进行异地恢复操作:

原来数据库ip:  a:172.21.1.30
要恢复的库ip:  b:172.21.1.40

服务器a:172.21.1.30上的操作如下:

    1.删除/bk下的所有备份文件,删除/arc下的归档文件
    [oracle@dg ~]$ rman target /

    recovery manager: release 10.2.0.1.0 - production on tue aug 2 10:59:27 2011
    凯发app官方网站 copyright (c) 1982, 2005, oracle.  all rights reserved.
    connected to target database: dg01 (dbid=370021178)
   
    rman>delete noprompt expired backup;
    rman>delete noprompt expired copy;

    2.执行脚本 rmanback.sh,对数据库进行压缩备份:
   
    脚本内容如下:
    rman target / log=/bk/rmanbackup.log <    backup as compressed backupset filesperset 3 database format '/bk/%u';
    backup  archivelog all delete input format '/bk/arc_%u.bk';
    delete noprompt obsolete;
    backup current controlfile format '/bk/%u.ctl';
    eof
   
    [oracle@dg ~]$sh /bk/rmanback.sh
    [oracle@dg bk]$ ls

    08mivn8k  09mivnci  0amivnd1  0bmivndq  0cmivne9  0emivneh.ctl  arc_0dmivnee.bk   rmanback.sh  rmanbackup.log
   
    [oracle@dg bk]$ tar cvfz bk30.tar.gz  ./* --exclude=*.sh --exclude=*.log
    [oracle@dg bk]$ scp -r bk30.tar.gz     172.21.1.40:/disk/


    3.一致性停数据库:

    [oracle@dg ~]$ sqlplus / as sysdba

    sys_s:142_p:13539_dg01>shutdown immediate;
   
服务器b:172.21.1.40 的操作步骤:

    1.解压备份文件:
    [oracle@vcdog disk]$ tar xvfz bk30.tar.gz ./
    [oracle@vcdog disk]$ ls
    08mivn8k  09mivnci  0amivnd1  0bmivndq  0cmivne9  0emivneh.ctl    arc_0dmivnee.bk
   
    2.恢复controlfile及spfile:
    [oracle@vcdog disk]$ rman target /

    recovery manager: release 10.2.0.1.0 - production on tue aug 2 11:22:07 2011

    凯发app官方网站 copyright (c) 1982, 2005, oracle.  all rights reserved.
   
    rman>startup nomount;
    rman>restore controlfile from '/disk/0emivneh.ctl';   
    rman>restore spfile from '/disk/0cmivne9';
   
    [oracle@vcdog disk]$ cp $oracle_home/dbs/cntrlorcl.dbf  $oracle_base/oradata/dg01/control01.ctl
    [oracle@vcdog disk]$ cp $oracle_home/dbs/cntrlorcl.dbf  $oracle_base/oradata/dg01/control02.ctl
    [oracle@vcdog disk]$ cp $oracle_home/dbs/cntrlorcl.dbf  $oracle_base/oradata/dg01/control03.ctl
    [oracle@vcdog disk]$strings  $oracle_home/dbs/spfiledg01.ora > $oracle_home/dbs/initdg01.ora
    [oracle@vcdog disk]$ vim  /data/oracle/product/10.2.0.1.0/db_01/dbs/initdg01.ora                    
    *.audit_file_dest='/data/oracle/admin/dg01/adump'
    *.background_dump_dest='/data/oracle/admin/dg01/bdump'
    *.compatible='10.2.0.1.0'
    *.control_files='/data/oracle/oradata/dg01/control01.ctl','/data/oracle/oradata/dg01/control02.ctl','/data/oracle/oradata/dg01/control03.ctl'#restore controlfile
    *.core_dump_dest='/data/oracle/admin/dg01/cdump'
    *.db_block_size=8192
    *.db_cache_size=62914560
    *.db_file_multiblock_read_count=16
    *.db_name='dg01'
    *.job_queue_processes=2
    *.large_pool_size=20971520
    *.pga_aggregate_target=16777216
    *.processes=150
    *.sga_max_size=314572800
    *.sga_target=293601280
    *.shared_pool_size=96468992
    *.undo_management='auto'
    *.undo_tablespace='undotbs1'
    *.user_dump_dest='/data/oracle/admin/dg01/udump'
   
    保存退出。
   
    3.启动数据库到mount状态:
   
    [oracle@vcdog dbs]$ sqlplus / as sysdba

    sys_s:159_p:5659_dg01>    alter database mount;
   
    sys_s:159_p:5659_dg01>select 'set  newname for datafile '||file#|| ' to '''||replace(name,'u01','data')||''';' from v$datafile;
   
    set  newname for datafile 1 to '/data/oracle/oradata/dg01/system01.dbf';
    set  newname for datafile 2 to '/data/oracle/oradata/dg01/undotbs01.dbf';
    set  newname for datafile 3 to '/data/oracle/oradata/dg01/sysaux01.dbf';
    set  newname for datafile 4 to '/data/oracle/oradata/dg01/users01.dbf';
    set  newname for datafile 5 to '/data/oracle/oradata/dg01/example01.dbf';
    set  newname for datafile 6 to '/data/oracle/oradata/dg01/vc.dbf';
    set  newname for datafile 7 to '/data/oracle/oradata/dg01/mytest01.dbf';
    set  newname for datafile 8 to '/data/oracle/oradata/dg01/mytest02.dbf';
    set  newname for datafile 9 to '/data/oracle/oradata/dg01/mytbs01.dbf';
    set  newname for datafile 10 to '/data/oracle/oradata/dg01/ind_tbs01.dbf';
    set  newname for datafile 11 to '/data/oracle/oradata/dg01/wd01.dbf';
   
    4.rman下执行脚本:
   
    rman> catalog start with '/disk/';
    rman>run{
        set  newname for datafile 1 to '/data/oracle/oradata/dg01/system01.dbf';
        set  newname for datafile 2 to '/data/oracle/oradata/dg01/undotbs01.dbf';
        set  newname for datafile 3 to '/data/oracle/oradata/dg01/sysaux01.dbf';
        set  newname for datafile 4 to '/data/oracle/oradata/dg01/users01.dbf';
        set  newname for datafile 5 to '/data/oracle/oradata/dg01/example01.dbf';
        set  newname for datafile 6 to '/data/oracle/oradata/dg01/vc.dbf';
        set  newname for datafile 7 to '/data/oracle/oradata/dg01/mytest01.dbf';
        set  newname for datafile 8 to '/data/oracle/oradata/dg01/mytest02.dbf';
        set  newname for datafile 9 to '/data/oracle/oradata/dg01/mytbs01.dbf';
        set  newname for datafile 10 to '/data/oracle/oradata/dg01/ind_tbs01.dbf';
        set  newname for datafile 11 to '/data/oracle/oradata/dg01/wd01.dbf';
        restore database;
        switch datafile all;
        recover database;
        }
       
    5.rename logfile日志文件:
   
    [oracle@vcdog dbs]$scp -r 172.21.1.30:/u01/oracle/oradata/dg01/redo01.log /data/oracle/oradata/dg01/redo01.log
    [oracle@vcdog dbs]$scp -r 172.21.1.30:/u01/oracle/oradata/dg01/redo03.log /data/oracle/oradata/dg01/redo03.log
    sys_s:159_p:5659_dg01>alter database rename file  '/u01/oracle/oradata/dg01/redo01.log' to '/data/oracle/oradata/dg01/redo01.log';
    sys_s:159_p:5659_dg01>alter database rename file  '/u01/oracle/oradata/dg01/redo03.log' to '/data/oracle/oradata/dg01/redo03.log';
   
    此时,由于原来备份时,redo02.log文件是current状态,不能直接归档。在服务器a:172.21.1.30上执行如下命令:
    sys_s:159_p:5659_dg01>alter system switch logfile;
   
    [oracle@vcdog dbs]$scp -r 172.21.1.30:/u01/oracle/oradata/dg01/redo02.log /data/oracle/oradata/dg01/redo02.log
    sys_s:159_p:5659_dg01>alter database rename file  '/u01/oracle/oradata/dg01/redo02.log' to '/data/oracle/oradata/dg01/redo02.log';
   
    6.打开数据库到open状态:
   
    sys_s:159_p:5659_dg01> alter database open resetlogs;

    此时,数据库的异地恢复完成。

阅读(8585) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图