• Oracle--单实例数据库迁移到RAC集群服务器(RMAN)


    单实例数据库版本:11.2.0.1

    RAC实例数据库版本:11.2.0.3

    1,在单实例数据库备份文件

    RMAN> show all;

    using target database control file instead of recovery catalog
    RMAN configuration parameters for database with db_unique_name ORCL are:
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
    CONFIGURE BACKUP OPTIMIZATION ON;
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
    CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
    CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE MAXSETSIZE TO UNLIMITED; # default
    CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
    CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
    CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
    CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
    CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/data/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl.f'; # default

    RMAN>backup as compressed backupset database format '/data/testbackup/full_U%' plus archivelog delete all input;

    Starting Control File and SPFILE Autobackup at 21-MAY-17
    piece handle=/data/oracle/product/11.2.0/dbhome_1/dbs/c-1417506066-20170521-04 comment=NONE
    Finished Control File and SPFILE Autobackup at 21-MAY-17

    注意:备份的时候数据文件备份和参数控制是分开路劲放的。数据文件我们已经指定好了位置。参数和控制文件的路劲会在最后显示出来。

    将这两个备份文件传输到RAC服务器上路劲一致。

    在RAC服务器上创建实例名相同的实例,为了获取适合RAC服务器配置的参数文件,不用做太多的调整。

    [oracle@oraclea ~]$ rman target /

    Recovery Manager: Release 11.2.0.3.0 - Production on Sun May 21 13:55:51 2017

    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

    connected to target database (not started)

    RMAN> startup nomount

    Oracle instance started

    Total System Global Area    4275781632 bytes

    Fixed Size                     2235208 bytes
    Variable Size                889193656 bytes
    Database Buffers            3372220416 bytes
    Redo Buffers                  12132352 bytes

    RMAN> restore controlfile from '/data/testbackup/c-1417506066-20170521-04';

    Starting restore at 21-MAY-17
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=10 instance=orcl1 device type=DISK

    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    output file name=+DATA2/orcl/controlfile/current.284.944572951
    output file name=+FRA/orcl/controlfile/current.264.944572951
    Finished restore at 21-MAY-17

    RMAN> alter database mount;

    database mounted
    released channel: ORA_DISK_1

    RMAN>

    查看源数据库数据文件,临时文件以及对应的ID

    SQL> select file_id,file_name from dba_data_files
      2  union
      3  select file_id,file_name from dba_temp_files
      4  order by 1;

       FILE_ID FILE_NAME
    ---------- ----------------------------------------
      1 /data/oracle/oradata/orcl/system01.dbf
      1 /data/oracle/oradata/orcl/temp01.dbf
      2 /data/oracle/oradata/orcl/sysaux01.dbf
      3 /data/oracle/oradata/orcl/undotbs01.dbf
      4 /data/oracle/oradata/orcl/users01.dbf
      5 /data/oradata/nnc_data01.dbf
      6 /data/oradata/nnc_index01.dbf
      7 /data/oradata/nnc_data02.dbf
      8 /data/oradata/nnc_index02.dbf
      9 /data/oradata/nnc_data03.dbf
     10 /data/oradata/nnc_index03.dbf

       FILE_ID FILE_NAME
    ---------- ----------------------------------------
     11 /data/oradata/nnc_data001.dbf

    12 rows selected.

    因为路劲不同,RAC用的是ASM存储,所以在还原数据文件的时候要进行路劲的变更,再对数据库进行restore

    run {
       set newname for datafile  1 to "+DATA2/ORCL/DATAFILE/system01.dbf";
       set newname for datafile  2 to "+DATA2/ORCL/DATAFILE/sysaux01.dbf";
       set newname for datafile  3 to "+DATA2/ORCL/DATAFILE/undotbs01.dbf";
       set newname for datafile  4 to "+DATA2/ORCL/DATAFILE/users01.dbf";
       set newname for datafile  5 to "+DATA2/ORCL/DATAFILE/nnc_data01.dbf";
       set newname for datafile  6 to "+DATA2/ORCL/DATAFILE/nnc_index01.dbf";
       set newname for datafile  7 to "+DATA2/ORCL/DATAFILE/nnc_data02.dbf";
       set newname for datafile  8 to "+DATA2/ORCL/DATAFILE/nnc_index02.dbf";
       set newname for datafile  9 to "+DATA2/ORCL/DATAFILE/nnc_data03.dbf";
       set newname for datafile  10 to "+DATA2/ORCL/DATAFILE/nnc_index03.dbf";
       set newname for datafile  11 to "+DATA2/ORCL/DATAFILE/nnc_data001.dbf";
       set newname for tempfile 1 to   "+DATA2/ORCL/DATAFILE/temp01.dbf";
       restore database;
       switch datafile all;
       switch tempfile all;
       }

    还原后做数据恢复

    这里报缺少日志,经检查可能是由于增量备份引起的日志丢失,到源库重新拷一份到指定路劲进行恢复

    这里报未知所需的日志需求,但是备份最新的是在第一个恢复报的日志序列号,可以忽略
    这里是提醒恢复到一个未知的scn号。在alter database mount之后,通过set until scn或者set until time命令设置恢复到的scn号或时间。就可以避免这个错误。

    处理在线日志文件,手动改为ASM磁盘路劲

    SQL> select member from v$logfile;

    MEMBER
    --------------------------------------------------------------------------------
    /data/oracle/oradata/orcl/redo04.log
    /data/oracle/oradata/orcl/redo05.log
    /data/oracle/oradata/orcl/redo06.log

    SQL> alter database rename file '/data/oracle/oradata/orcl/redo04.log' to '+data2/orcl/onlinelog/redo04.log';
    SQL> alter database rename file '/data/oracle/oradata/orcl/redo05.log' to '+data2/orcl/onlinelog/redo05.log';
    SQL> alter database rename file '/data/oracle/oradata/orcl/redo06.log' to '+data2/orcl/onlinelog/redo06.log';

    增加节点2的日志文件

    SQL>alter database add  logfile thread 2 group 1 ('+data2/orcl/onlinelog/redo01_1.log','+fra/orcl/onlinelog/redo01_2.log') size 300M;
    SQL> alter database add  logfile thread 2 group 2 ('+data2/orcl/onlinelog/redo02_1.log','+fra/orcl/onlinelog/redo02_2.log') size 300M;
    SQL> alter database add  logfile thread 2 group 3 ('+data2/orcl/onlinelog/redo03_1.log','+fra/orcl/onlinelog/redo03_2.log') size 300M;

    打开数据库resetlogs

    SQL> alter database open resetlogs;
    alter database open resetlogs
    *
    ERROR at line 1:
    ORA-00392: log 5 of thread 1 is being cleared, operation not allowed
    ORA-00312: online log 5 thread 1: '+DATA2/orcl/onlinelog/redo05.log'

    SQL>select group#,bytes/1024/1024||'M',status from v$log;


        GROUP# BYTES/1024/1024||'M'        STATUS
    ---------- ----------------------------------------- ----------------
      4 300M          CLEARING
      6 300M          CLEARING
      5 300M          CLEARING_CURRENT

    官方解释:

    CLEARING_CURRENT - Current log is being cleared of a closed thread. The log can stay in this status if there is some failure in the switch such as an I/O error writing the new log header.

    CLEARING - Log is being re-created as an empty log after an ALTER DATABASE CLEAR

    重做日志文件的集中状态:*(摘)*

    知识点补充:

    1.CURRENT - 当前正在被LGWR使用的group(同时是ACTIVE状态),其中记载数据库中正在进行的更改,删除将导致恢复时数据丢失。

    2.ACTIVE - 活动的日志文件状态,日志完成切换或等待检查点事件时都可能出于这种状态,不是CURRENT的日志但是实例恢复时是需要的,此时的日志有可能已经完成了归档,即将变成INACTIVE状态,或者日志文件在等待Checkpoint事件没有完成归档。

    3.INACTIVE - 非活动的日志状态,此时的日志实例恢复时不再需要,可能已经归档。

    4.UNUSED - 尚未记录change的空白日志组,一般会出现在add logfile, resetlogs打开数据库或者使用了clear logfile命令后。

    5.CLEARING - 表示该组重做日志文件正在被ALTER DATABASE CLEAR LOGFILE语句重建中(重建后状态会变成unused)。

    6.CLEARING_CURRENT - 表示该组重做日志文件重建时出现错误,出现对日志文件的I/O故障就会出现这种状态。

    解决办法:

    SQL>alter database clear logfile group 4;
    SQL>alter database clear logfile group 5;
    SQL>alter database clear logfile group 6;

    SQL> alter database open resetlogs;
    alter database open resetlogs
    *
    ERROR at line 1:
    ORA-01092: ORACLE instance terminated. Disconnection forced
    ORA-00704: bootstrap process failure
    ORA-39700: database must be opened with UPGRADE option
    Process ID: 31085
    Session ID: 63 Serial number: 5

    因为被迁的实例版本是11.2.0.1,所在环境是11.2.0.3所以在这里要以升级模式打开,进行小版本升级,

    SQL>startup upgrade

    .........

    ORA-39701: database must be mounted EXCLUSIVE for UPGRADE or DOWNGRADE

    ........

    对于RAC数据库需要把cluster_database参数改为false, 因为作为cluster数据库不会用EXCLUSIVE方式打开数据库。

     alter system set cluster_database=false scope=spfile;重启数据库到upgrade,执行脚本进行升级

    SQL>STARTUP UPGRADE

    SQL>@$ORACLE_HOME/rdbms/admin/catupgrd.sql;

    SQL>@$ORACLE_HOME/rdbms/admin/utlrp.sql;  --重新编译失效的object,跟这个问题本身关系不大,可以不执行
    重启数据库,增加节点2的undo表空间,名字要对应
    SQL>create undo tablespace UNDOTBS2 datafile '+data2/orcl/onlinelog/undotbs02.dbf' size 500m autoextend on next 100M maxsize 10240M;

    SQL>alter database enable thread 2;--要对节点2新建的日志文件进行enabled

    将cluster_database参数改为true,重启两边的数据库
     
    单实例迁移到RAC到这里就结束了。
  • 相关阅读:
    优先队列插入、删除
    堆排序
    UVALive 2474 Balloons in a Box(枚举)
    二叉树的建立、四种遍历、求深度、求叶子结点数
    说说尾递归(转载)
    1#Two Sum(qsort用法)
    马克思:青年在选择职业时的考虑
    最要紧的是,我们首先要善良,其次是要诚实,再次是以后永远不要相互遗忘。
    多重背包优化算法
    poj2976 Dropping tests(01分数规划 好题)
  • 原文地址:https://www.cnblogs.com/guipeng/p/6884470.html
Copyright © 2020-2023  润新知