zoukankan      html  css  js  c++  java
  • 终极RMAN复制,简单直接!

    还在expdp,impdp吗,烦琐的授权,建表空间,编译异常对象,头的搞大了,来试试简单直接暴力的RMAN复制吧,保证让你爽到底!

    --rman复制     计划把172.19.201.240上的SGPMDB  ,复制到 172.19.201.188上的testa
    --源机 172.19.201.240  SGPMDB
    --目标机 172.19.201.188  testa

    --目标机上准备
    su - oracle
    cd $ORACLE_BASE/admin
    mkdir testa
    mkdir adump bdump cdump udump pfile arch
    cd $ORACLE_BASE/oradata
    mkdir testa

    --目标机$ORACLE_BASE/admin/testa/pfile位置新建pfiletesta.ora
    db_name=testa
    compatible=10.2.0.3.0
    db_file_name_convert=('/app/oracle/base/oradata/SGPMDB','/oracle/base/oradata/testa')
    log_file_name_convert=('/app/oracle/base/oradata/SGPMDB','/oracle/base/oradata/testa')
    shared_pool_size=800000000
        
    --在目标机上生成密码文件,路径和名字一点都不能错
    orapwd file=$ORACLE_HOME/dbs/orapwtesta password=oracle entries=5 

    --目标机
    export ORACLE_SID=testa
    sqlplus / as sysdba
    startup nomount pfile='/oracle/base/admin/testa/pfile/pfiletesta.ora'

    --目标机上新建tns
    CIS240,指向源机上的库SGPMDB

    --目标机上
    rman
    connect target sys/sys_release4144_sgpmdb@CIS240
    connect auxiliary /

    --目标机上
    备份操作
    RMAN> sql 'alter system switch logfile' ; --多执行几遍,尽量让所有日志归档

    然后
    RMAN> run {
     allocate channel ch1 device type disk maxpiecesize=20g;
     sql 'alter system archive log current';
     change archivelog all crosscheck;
     backup full database tag=fullbk
      format '/app/oracle/base/admin/SGPMDB/arch/%d_db_%t_%s_%p'
      plus archivelog format '/app/oracle/base/admin/SGPMDB/arch/%d_arch_%t_%s_%p' delete all input;
     backup current controlfile
      format '/app/oracle/base/admin/SGPMDB/arch/%d_ctlfile_%t_%s_%p';
     release channel ch1;
      }

    备份完成后,查看备份文件
    RMAN> list backup ;

    ftp复制备份文件
    ftp 172.19.201.240
    bin
    cd /app/oracle/base/admin/SGPMDB/arch
    lcd /oradata/arch01
    get /app/oracle/base/admin/SGPMDB/arch/SGPMDB_arch_701352461_57_1 SGPMDB_arch_701352461_57_1
    get /app/oracle/base/admin/SGPMDB/arch/SGPMDB_db_701352479_58_1 SGPMDB_db_701352479_58_1
    get /app/oracle/base/admin/SGPMDB/arch/SGPMDB_arch_701353285_59_1 SGPMDB_arch_701353285_59_1
    get /app/oracle/base/admin/SGPMDB/arch/SGPMDB_ctlfile_701353287_60_1 SGPMDB_ctlfile_701353287_60_1
    get /app/oracle/base/product/10.2.0/db_1/dbs/c-3784337228-20091027-02 c-3784337228-20091027-02


    为了rman能够识别到,在目标机上,和原机同样的位置,做了软链接
    mkdir -p /app/oracle/base/admin/SGPMDB/arch/
    ln -s /oradata/arch01/SGPMDB_arch_700343479_11_1 /app/oracle/base/admin/SGPMDB/arch/SGPMDB_arch_700343479_11_1
    ...

    复制

    正确的是这样的:
    run{
    DUPLICATE TARGET DATABASE TO testa
    pfile='/oracle/base/admin/testa/pfile/pfiletesta.ora'
    db_file_name_convert=('/app/oracle/base/oradata/SGPMDB','/oracle/base/oradata/testa');
    };

    --如果顺利的话,数据库会自动重启到open状态

    --接下来,1.增加undo表空间,2.修改pfile ,3.建spfile ,重启

    --1.创建一个新的undo表空间,修改数据库将undo_tablespace指向新的UNDOTBS2表空间,在后面的pfile中指定
    create undo tablespace UNDOTBS2
    datafile '/oracle/base/oradata/testa/undotbs02.dbf'
    size 200m ;

    --2.修改pfile文件如下:
    db_name=testa
    *.aq_tm_processes=2
    *.audit_file_dest='/oracle/base/admin/testa/adump'
    *.background_dump_dest='/oracle/base/admin/testa/bdump'
    *.compatible='10.2.0.3.0'
    *.control_files='/oracle/base/oradata/testa/control01.ctl','/oracle/base/oradata/testa/control02.ctl','
    /oracle/base/oradata/testa/control03.ctl'
    *.core_dump_dest='/oracle/base/admin/testa/cdump'
    *.db_block_size=8192
    *.db_domain=''
    *.db_file_multiblock_read_count=16
    *.pga_aggregate_target=1073741824
    *.processes=2500
    *.remote_login_passwordfile='EXCLUSIVE'
    *.sessions=3000
    *.sga_max_size=2097152000
    *.sga_target=2097152000
    *.user_dump_dest='/oracle/base/admin/testa/udump'
    *.open_cursors=3000
    undo_management='AUTO'
    undo_tablespace='UNDOTBS2'

    --关掉重启
    startup pfile='/oracle/base/admin/testa/pfile/pfiletesta.ora' ;

    --3.建spfile ,重启
    create spfile='/oracle/base/product/10.2.0/db_1/dbs/spfiletesta.ora' from pfile='/oracle/base/admin/testa/pfile/pfiletesta.ora';

    最后重起库就可以啦。

    到此一切搞定,多出来的时间又可以去泡论坛了,哈哈!

  • 相关阅读:
    我用自己做的图书比价搜索买了一本书
    2.17
    最近的工作
    FireBug的Bug
    2.18
    tecent面试题解答
    .net杂记
    python的round测试
    最近在网上买书的体会
    关于迅雷评论的一个改造html css
  • 原文地址:https://www.cnblogs.com/caibird2005/p/1592047.html
Copyright © 2011-2022 走看看