zoukankan      html  css  js  c++  java
  • RAC环境中某数据文件(非system表空间)创建在本地,不停机迁移到ASM磁盘中

    Datafiles are mistakenly built into the local file system for processing in the RAC environment

    The RAC environment has been opened for archiving

    1. 本地文件迁移到共享磁盘

    1.1 RAC环境中在本地创建数据文件

    Node1:vastdata3
    SQL> create tablespace asd datafile'/home/oracle/asd01.dbf' size 10M autoextend on;
    Tablespace created.
    SQL> col TABLESPACE_NAME for a20
    SQL> col FILE_NAME for a50
    SQL> select file_name,file_id,online_status,tablespace_name from dba_data_files;
      
    FILE_NAME                                  FILE_ID  ONLINE_STATUS  TABLESPACE_NAME
    ---------------------- ------   ---- ---------   --------------------
    +DATA/prod/datafile/undotbs1.258.1001122667      3  ONLINE         UNDOTBS1
    +DATA/prod/datafile/users.259.1001073567         4  ONLINE         USERS
    +DATA/prod/datafile/sysaux.257.1001073565        2  ONLINE         SYSAUX
    +DATA/prod/datafile/system.256.1001073565        1  SYSTEM         SYSTEM
    +DATA/prod/datafile/example.264.1001073679       5  ONLINE         EXAMPLE
    +DATA/prod/datafile/undotbs2.265.1001073909      6  ONLINE         UNDOTBS2
    /home/oracle/asd01.dbf                           7  ONLINE         ASD
    7 rows selected.

    1.2 在二节点上查看数据字典DBA_DATA_FILES时,发现报错

    Node2:vastdata4
    SQL> select file_name,file_id,online_status,tablespace_name from dba_data_files;
    ERROR:
    ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
    ORA-01110: data file 7: '/home/oracle/asd01.dbf'
    no rows selected

    1.3 使用RMAN创建数据文件并替换上面提到的数据文件

    Node1:vastdata3
    SQL> alter database datafile 7 offline;
    Database altered.
    RMAN> copy datafile '/home/oracle/asd01.dbf' to '+DATA';
    Starting backup at 2019-02-28 03:13:57
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=51 instance=PROD1 device type=DISK
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00007 name=/home/oracle/asd01.dbf
    output file name=+DATA/prod/datafile/asd.269.1001387639 tag=TAG20190228T031358 RECID=2 STAMP=1001387638
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 2019-02-28 03:13:59
    RMAN> switch datafile '/home/oracle/asd01.dbf' to copy;
    datafile 7 switched to datafile copy "+DATA/prod/datafile/asd.269.1001387639"

    1.4 通过复制移动创建的数据文件到ASM磁盘组目录中,恢复7号数据文件并使其online

    Recover the datafile 7 And let it online.
    
    Node1:vastdata3
    SQL> alter database datafile 7 online;
    alter database datafile 7 online
    *
    ERROR at line 1:
    ORA-01113: file 7 needs media recovery
    ORA-01110: data file 7: '+DATA/prod/datafile/asd.269.1001387639'
    SQL> recover datafile 7;
    Media recovery complete.
    SQL> alter database datafile 7 online;
    Database altered.
      
    Node1:vastdata3
    SQL> select file_name,file_id,online_status,tablespace_name from dba_data_files;
      
    FILE_NAME                     FILE_ID  ONLINE_STATUS  TABLESPACE_NAME
    ---------------------- ------   ---- ---------   --------------------
    +DATA/prod/datafile/undotbs1.258.1001122667      3 ONLINE           UNDOTBS1
    +DATA/prod/datafile/users.259.1001073567        4 ONLINE           USERS
    +DATA/prod/datafile/sysaux.257.1001073565       2 ONLINE           SYSAUX
    +DATA/prod/datafile/system.256.1001073565       1 SYSTEM           SYSTEM
    +DATA/prod/datafile/example.264.1001073679       5 ONLINE           EXAMPLE
    +DATA/prod/datafile/undotbs2.265.1001073909      6 ONLINE           UNDOTBS2
    +DATA/prod/datafile/asd.269.1001387639         7 ONLINE           ASD
    7 rows selected.
      
    [oracle@vastdata3 ~]$ rm asd01.dbf
      
    Node2:vastdata4
    SQL> select file_name,file_id,online_status,tablespace_name from dba_data_files;
      
    FILE_NAME                     FILE_ID  ONLINE_STATUS  TABLESPACE_NAME
    ---------------------- ------   ---- ---------   --------------------
    +DATA/prod/datafile/undotbs1.258.1001122667      3 ONLINE            UNDOTBS1
    +DATA/prod/datafile/users.259.1001073567              4 ONLINE           USERS
    +DATA/prod/datafile/sysaux.257.1001073565            2 ONLINE           SYSAUX
    +DATA/prod/datafile/system.256.1001073565            1 SYSTEM           SYSTEM
    +DATA/prod/datafile/example.264.1001073679         5 ONLINE           EXAMPLE
    +DATA/prod/datafile/undotbs2.265.1001073909           6 ONLINE           UNDOTBS2
    +DATA/prod/datafile/asd.269.1001387639           7 ONLINE                ASD
    7 rows selected.

    2. 共享数据文件迁移到本地文件系统中

    2.1 在共享磁盘上创建数据文件

    Node1:vastdata3
    
    SQL> create tablespace asd datafile'+DATA' size 10M autoextend on;
    Tablespace created.
      
    SQL> select file_name,file_id,online_status,tablespace_name from dba_data_files;
    FILE_NAME                                    FILE_ID ONLINE_STATUS  TABLESPACE_NAME
    -------------------------------------    ---------- --------------    ---
    +DATA/prod/datafile/undotbs1.258.1001122667      3 ONLINE           UNDOTBS1
    +DATA/prod/datafile/users.259.1001073567        4 ONLINE           USERS
    +DATA/prod/datafile/sysaux.257.1001073565       2 ONLINE           SYSAUX
    +DATA/prod/datafile/system.256.1001073565       1 SYSTEM           SYSTEM
    +DATA/prod/datafile/example.264.1001073679       5 ONLINE           EXAMPLE
    +DATA/prod/datafile/undotbs2.265.1001073909      6 ONLINE           UNDOTBS2
    +DATA/prod/datafile/asd. 269.1001415229        7 ONLINE           ASD
    +DATA/prod/datafile/zxc                                            8 SYSTEM           SYSTEM

    2.2 在共享盘中复制数据文件到本地

    Node1:vastdata3
    
    SQL> alter database datafile 7 offline;
    Database altered.
      
    ASMCMD> pwd
    +DATA/PROD/DATAFILE
    ASMCMD> ls
    ASD.269.1001415229
    ASMCMD> cp ASD.269.1001415229 /tmp/asd01.dbf
    copying +DATA/PROD/DATAFILE/ASD.269.1001415229 -> /tmp/asd01.dbf
    Destinations in cp allow at most one level of directory structure

    2.3 变更数据文件到路径,并恢复该数据文件

    Node1:vastdata3
    
    SQL> alter database rename file '+DATA/PROD/DATAFILE/ASD.269.1001415229' to '/tmp/asd01.dbf';
    Database altered.
      
    SQL> select file_name,file_id,online_status,tablespace_name from dba_data_files;
    FILE_NAME                                FILE_ID ONLINE_STATUS TABLESPACE_NAME
    -------------------------------------------------- ---------- -------------- --------------------
    +DATA/prod/datafile/undotbs1.258.1001122667    3 ONLINE        UNDOTBS1
    +DATA/prod/datafile/users.259.1001073567       4 ONLINE        USERS
    +DATA/prod/datafile/sysaux.257.1001073565      2 ONLINE        SYSAUX
    +DATA/prod/datafile/system.256.1001073565      1 SYSTEM        SYSTEM
    +DATA/prod/datafile/example.264.1001073679     5 ONLINE        EXAMPLE
    +DATA/prod/datafile/undotbs2.265.1001073909    6 ONLINE        UNDOTBS2
    /tmp/asd01.dbf                                 7 RECOVER       ASD
    +DATA/prod/datafile/zxc                        8 SYSTEM        SYSTEM
      
    8 rows selected.
      
    SQL> recover datafile 7;
    ORA-00283: recovery session canceled due to errors
    ORA-01114: IO error writing block to file 7 (block # 1)
    ORA-01110: data file 7: '/tmp/asd01.dbf'
    ORA-27091: unable to queue I/O
    ORA-27041: unable to open file
    Linux-x86_64 Error: 13: Permission denied
    Additional information: 3
      
    [root@vastdata3 ~]# ll /tmp/asd01.dbf
    -rw-r----- 1 grid  oinstall 10493952 Feb 28 11:05 /tmp/asd01.dbf
    [root@vastdata3 ~]# chown oracle:oinstall /tmp/asd01.dbf
      
    SQL> recover datafile 7;
    Media recovery complete.
      
    SQL> alter database datafile 7 online;
    Database altered.

    至此,Oracle RAC架构搭建完成。

    如有转载,请标明出处。

    我报路长嗟日暮,学诗谩有惊人句。 九万里风鹏正举。风休住,蓬舟吹取三山去!
  • 相关阅读:
    快速幂模板
    部分有关素数的题
    POJ 3624 Charm Bracelet (01背包)
    51Nod 1085 背包问题 (01背包)
    POJ 1789 Truck History (Kruskal 最小生成树)
    HDU 1996 汉诺塔VI
    HDU 2511 汉诺塔X
    HDU 2175 汉诺塔IX (递推)
    HDU 2077 汉诺塔IV (递推)
    HDU 2064 汉诺塔III (递推)
  • 原文地址:https://www.cnblogs.com/klyyk0950/p/12504193.html
Copyright © 2011-2022 走看看