熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

利用RMAN將數據庫從文件系統遷移到ASM

2022-06-13   來源: Oracle 

  一打開ASM實例

  [oracle@ASM ~]$ echo $ORACLE_SID

  +ASM

  [oracle@ASM ~]$ sqlplus /nolog

  SQL*Plus: Release Production on Mon Apr ::

  Copyright (c) Oracle  All rights reserved

  SQL> conn / as sysdba

  Connected to an idle instance

  SQL> startup

  ASM instance started

  Total System Global Area   bytes

  Fixed Size                  bytes

  Variable Size              bytes

  ASM Cache                  bytes

  ASM diskgroups mounted

  SQL> select namestate from v$asm_diskgroup;

  NAME                           STATE

  

  DATA                           MOUNTED

  DGROUP                       MOUNTED

  二修改目標數據庫(TOASM)的SPFILE

  SQL> ALTER SYSTEM SET CONTROL_FILES=+DGROUP  SCOPE=SPFILE;

  System altered

  SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST=+DGROUP SCOPE=SPFILE;

  System altered

  三關閉目標數據庫

  SQL> SHUTDOWN IMMEDIATE

  Database closed

  Database dismounted

  ORACLE instance shut down

  四通過RMAN連接到目標數據庫並啟動到NOMOUNT狀態

  [oracle@ASM admin]$ rman target /

  Recovery Manager: Release Production on Mon Apr ::

  Copyright (c) Oracle  All rights reserved

  connected to target database (not started)

  RMAN> startup nomount

  Oracle instance started

  Total System Global Area     bytes

  Fixed Size                     bytes

  Variable Size                 bytes

  Database Buffers             bytes

  Redo Buffers                   bytes

  RMAN>

  五還原控制文件到ASM磁盤組並將數據庫啟動到MOUNT狀態

  RMAN> RESTORE CONTROLFILE FROM /u/oradata/TOASM/controlctl;

  Starting restore at APR

  using target database control file instead of recovery catalog

  allocated channel: ORA_DISK_

  channel ORA_DISK_: sid= devtype=DISK

  channel ORA_DISK_: copied control file copy

  output filename=+DGROUP/toasm/controlfile/backup

  Finished restore at APR

  RMAN> ALTER DATABASE MOUNT;

  database mounted

  released channel: ORA_DISK_

  RMAN>

  六利用RMAN復制數據文件到ASM磁盤組

  RMAN > BACKUP AS COPY DATABASE FORMAT +DGROUP;

  Starting backup at APR

  allocated channel: ORA_DISK_

  channel ORA_DISK_: sid= devtype=DISK

  channel ORA_DISK_: starting datafile copy

  input datafile fno= name=/u/oradata/TOASM/systemdbf

  output filename=+DGROUP/toasm/datafile/system tag=TAGT recid= stamp=

  channel ORA_DISK_: datafile copy complete elapsed time: ::

  channel ORA_DISK_: starting datafile copy

  input datafile fno= name=/u/oradata/TOASM/sysauxdbf

  output filename=+DGROUP/toasm/datafile/sysaux tag=TAGT recid= stamp=

  channel ORA_DISK_: datafile copy complete elapsed time: ::

  channel ORA_DISK_: starting datafile copy

  input datafile fno= name=/u/oradata/TOASM/exampledbf

  output filename=+DGROUP/toasm/datafile/example tag=TAGT recid= stamp=

  channel ORA_DISK_: datafile copy complete elapsed time: ::

  channel ORA_DISK_: starting datafile copy

  input datafile fno= name=/u/oradata/TOASM/undotbsdbf

  output filename=+DGROUP/toasm/datafile/undotbs tag=TAGT recid= stamp=

  channel ORA_DISK_: datafile copy complete elapsed time: ::

  channel ORA_DISK_: starting datafile copy

  input datafile fno= name=/u/oradata/TOASM/usersdbf

  output filename=+DGROUP/toasm/datafile/users tag=TAGT recid= stamp=

  channel ORA_DISK_: datafile copy complete elapsed time: ::

  channel ORA_DISK_: starting datafile copy

  copying current control file

  output filename=+DGROUP/toasm/controlfile/backup tag=TAGT recid= stamp=

  channel ORA_DISK_: datafile copy complete elapsed time: ::

  channel ORA_DISK_: starting full datafile backupset

  channel ORA_DISK_: specifying datafile(s) in backupset

  including current SPFILE in backupset

  channel ORA_DISK_: starting piece at APR

  channel ORA_DISK_: finished piece at APR

  piece handle=+DGROUP/toasm/backupset/__/nnsnf_tagt_ tag=TAGT comment=NONE

  channel ORA_DISK_: backup set complete elapsed time: ::

  Finished backup at APR

  RMAN>

  七利用RMAN的SWITCH 命令修改控制文件內數據文件的指針使其指向新位置

  RMAN> SWITCH DATABASE TO COPY;

  datafile switched to datafile copy +DGROUP/toasm/datafile/system

  datafile switched to datafile copy +DGROUP/toasm/datafile/undotbs

  datafile switched to datafile copy +DGROUP/toasm/datafile/sysaux

  datafile switched to datafile copy +DGROUP/toasm/datafile/users

  datafile switched to datafile copy +DGROUP/toasm/datafile/example

  RMAN> RECOVER DATABASE;

  Starting recover at APR

  using channel ORA_DISK_

  starting media recovery

  media recovery complete elapsed time: ::

  Finished recover at APR

  RMAN>

  八打開數據庫

  RMAN> ALTER DATABASE OPEN;

  database opened

  RMAN>

  九遷移臨時文件

  由於臨時文件不會被遷移所以我們只需要刪除原來的增加新的就可以

  SQL> SELECT NAME FROM V$TEMPFILE;

  NAME

  

  /u/oradata/TOASM/tempdbf

  SQL> ALTER TABLESPACE TEMP ADD TEMPFILE +DGROUP;

  Tablespace altered

  SQL> ALTER TABLESPACE TEMP DROP TEMPFILE /u/oradata/TOASM/tempdbf;

  Tablespace altered

  SQL> SELECT NAME FROM V$TEMPFILE;

  NAME

  

  +DGROUP/toasm/tempfile/temp

  SQL>

  十增加新的ONLINE REDOLOGS 到ASM

  SQL> SELECT * FROM V$LOG;

  GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

  

                                   YES INACTIVE                APR

                                   NO  CURRENT                 APR

                                   YES INACTIVE                APR

  SQL> ALTER DATABASE ADD LOGFILE +DGROUP SIZE M;

  Database altered

  SQL> ALTER DATABASE ADD LOGFILE +DGROUP SIZE M;

  Database altered

  SQL> ALTER DATABASE ADD LOGFILE +DGROUP SIZE M;

  Database altered

  SQL> ALTER DATABASE DROP LOGFILE GROUP ;

  Database altered

  SQL> ALTER SYSTEM SWITCH LOGFILE;

  System altered

  SQL> ALTER SYSTEM SWITCH LOGFILE;

  System altered

  SQL> SQL> ALTER DATABASE DROP LOGFILE GROUP ;

  ALTER DATABASE DROP LOGFILE GROUP

  *

  ERROR at line :

  ORA: log needed for crash recovery of instance TOASM (thread )

  ORA: online log thread : /u/oradata/TOASM/redolog

  SQL> ALTER SYSTEM CHECKPOINT;

  System altered

  SQL> ALTER DATABASE DROP LOGFILE GROUP ;

  Database altered

  SQL>ALTER DATABASE DROP LOGFILE GROUP ;

  Database altered

  SQL> SELECT MEMBER FROM V$LOGFILE;

  MEMBER

  

  +DGROUP/toasm/onlinelog/group_

  +DGROUP/toasm/onlinelog/group_

  +DGROUP/toasm/onlinelog/group_

  SQL>

  十一最後刪除原來的數據庫文件

  [oracle@ASM ~]$ ls lh /u/oradata/TOASM/

  total M

  rwr  oracle oinstall M Apr  : controlctl

  rwr  oracle oinstall M Apr  : controlctl

  rwr  oracle oinstall M Apr  : controlctl

  rwr  oracle oinstall M Apr  : exampledbf

  rwr  oracle oinstall  M Apr  : redolog

  rwr  oracle oinstall  M Apr  : redolog

  rwr  oracle oinstall  M Apr  : redolog

  rwr  oracle oinstall M Apr  : sysauxdbf

  rwr  oracle oinstall M Apr  : systemdbf

  rwr  oracle oinstall  M Apr  : undotbsdbf

  rwr  oracle oinstall M Apr  : usersdbf

  [oracle@ASM ~]$ rm rf /u/oradata/TOASM/*

  [oracle@ASM ~]$ ls lh /u/oradata/TOASM/

  total

  [oracle@ASM ~]$

  遷移完畢!


From:http://tw.wingwit.com/Article/program/Oracle/201311/17127.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.