当前位置:首页 > 服务端 > Oracle单实例下oracle数据库从文件系统迁移到ASM上

Oracle单实例下oracle数据库从文件系统迁移到ASM上

第一步:启动ASM实例(+ASM)

[oracle@oracle ~]$ export ORACLE_SID=+ASM

[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Tue Jan 18 13:25:46 2011 Copyright (c) 1982, 2010, Oracle.  All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name,status from v$instance;

ASM实例已经启动

INSTANCE_NAME  STATUS

---------------- ------------

+ASM   STARTED

SQL> select instance_name,db_name,status from v$asm_client;

ASM实例上没有数据库连接

no rows selected

SQL> select name,state from v$asm_diskgroup;

ASM磁盘组已经挂载

NAME          STATE

------------------------------ -----------

DG          MOUNTED

第二步,修改目标数据库(WM)的参数文件(spfile)

[oracle@oracle ~]$ echo $ORACLE_SID WM

[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Tue Jan 18 13:33:59 2011 Copyright (c) 1982, 2010, Oracle.  All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter control_files;

NAME         TYPE  VALUE

------------------------------------ ----------- ------------------------------

control_files        string  /u01/app/oracle/oradata/WM/conrol01.ctl, /u01/app/oracle/or        adata/WM/control02.ctl, /u01/app/oracle/oradata/WM/control03.ctl

SQL> show parameter db_create_file_dest;

NAME         TYPE  VALUE

------------------------------------ ----------- ------------------------------

db_create_file_dest       string

SQL> create pfile from spfile;

File created.

SQL> alter system set control_files='+DG' scope=spfile;在spfile中把控制文件的路径修改为ASM磁盘组

System altered.

SQL> alter system set db_create_file_dest='+DG' scope=spfile;同上,修改数据文件的创建路径

System altered.

SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down.

第三步,利用RMAN迁移目标数据库(WM)的控制文件和数据文件

[oracle@oracle ~]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Tue Jan 18 13:38:22 2011 Copyright (c) 1982, 2007, Oracle.  All rights reserved. connected to target database (not started)

RMAN> startup nomount;

Oracle instance started Total System Global Area     285212672 bytes Fixed Size                     1273276 bytes Variable Size                 92275268 bytes Database Buffers             188743680 bytes Redo Buffers                   2920448 bytes

RMAN> restore controlfile from '/u01/app/oracle/oradata/WM/control01.ctl';利用文件系统上的控制文件重建控制文件到ASM磁盘组DG上

Starting restore at 18-JAN-11 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy output filename=+DG/wm/controlfile/current.256.740756507 Finished restore at 18-JAN-11

RMAN> alter database mount;

database mounted released channel: ORA_DISK_1

RMAN> run{  

 allocate channel c1 device type disk;

 allocate channel c2 device type disk;

 backup as copy database format '+DG';

}  利用RMAN复制数据文件到ASM磁盘组DG上

allocated channel: c1 channel c1: sid=156 devtype=DISK

allocated channel: c2 channel c2: sid=152 devtype=DISK

Starting backup at 18-JAN-11 channel c1: starting datafile copy input datafile fno=00001 name=/u01/app/oracle/oradata/WM/system01.dbf channel c2: starting datafile copy input datafile fno=00003 name=/u01/app/oracle/oradata/WM/sysaux01.dbf output filename=+DG/wm/datafile/sysaux.258.740756731 tag=TAG20110118T134523 recid=2 stamp=740757197 channel c2: datafile copy complete, elapsed time: 00:07:58 channel c2: starting datafile copy input datafile fno=00005 name=/u01/app/oracle/oradata/WM/example01.dbf output filename=+DG/wm/datafile/system.257.740756727 tag=TAG20110118T134523 recid=3 stamp=740757268 channel c1: datafile copy complete, elapsed time: 00:09:09 channel c1: starting datafile copy input datafile fno=00002 name=/u01/app/oracle/oradata/WM/undotbs01.dbf output filename=+DG/wm/datafile/example.259.740757205 tag=TAG20110118T134523 recid=4 stamp=740757287 channel c2: datafile copy complete, elapsed time: 00:01:30 channel c2: starting datafile copy input datafile fno=00004 name=/u01/app/oracle/oradata/WM/users01.dbf output filename=+DG/wm/datafile/undotbs1.260.740757277 tag=TAG20110118T134523 recid=6 stamp=740757304 channel c1: datafile copy complete, elapsed time: 00:00:32 output filename=+DG/wm/datafile/users.261.740757299 tag=TAG20110118T134523 recid=5 stamp=740757303 channel c2: datafile copy complete, elapsed time: 00:00:12 Finished backup at 18-JAN-11

Starting Control File and SPFILE Autobackup at 18-JAN-11 piece handle=/u01/app/oracle/flash_recovery_area/WM/autobackup/2011_01_18/o1_mf_s_737250559_6mbbsvw6_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 18-JAN-11 released channel: c1 released channel: c2

RMAN> switch database to copy; 利用RMAN的SWITCH 命令修改控制文件内数据文件的指针,使其指向新位置

datafile 1 switched to datafile copy "+DG/wm/datafile/system.257.740756727" datafile 2 switched to datafile copy "+DG/wm/datafile/undotbs1.260.740757277" datafile 3 switched to datafile copy "+DG/wm/datafile/sysaux.258.740756731" datafile 4 switched to datafile copy "+DG/wm/datafile/users.261.740757299" datafile 5 switched to datafile copy "+DG/wm/datafile/example.259.740757205"

RMAN> recover database;

Starting recover at 18-JAN-11 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK

starting media recovery media recovery complete, elapsed time: 00:00:01

Finished recover at 18-JAN-11

RMAN> alter database open;

database opened

第四步,迁移tempfile到ASM磁盘组DG上

[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Tue Jan 18 14:01:09 2011 Copyright (c) 1982, 2010, Oracle.  All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select instance_name,status from v$instance;

INSTANCE_NAME  STATUS

---------------- ------------

WM   OPEN

SQL> select name,status,enabled from v$tempfile;

NAME      STATUS  ENABLED

---------------------------------------- ------- ----------

/u01/app/oracle/oradata/WM/temp01.dbf  ONLINE  READ WRITE

SQL> alter tablespace temp add tempfile '+DG';

Tablespace altered.

SQL> alter tablespace temp drop tempfile '/u01/app/oracle/oradata/WM/temp01.dbf';

Tablespace altered.

SQL> select name,status,enabled from v$tempfile;

NAME      STATUS  ENABLED

---------------------------------------- ------- ----------

+DG/wm/tempfile/temp.262.740757907  ONLINE  READ WRITE

第五步,迁移redo logfile到ASM磁盘组DG上

SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;

    GROUP#  SEQUENCE# NAME           STATUS  ARC

---------- ---------- ---------------------------------------- ---------------- ---

  3     6 /u01/app/oracle/oradata/WM/redo03.log    CURRENT  NO

  2     5 /u01/app/oracle/oradata/WM/redo02.log    INACTIVE  YES

  1     4 /u01/app/oracle/oradata/WM/redo01.log    INACTIVE  YES

SQL> alter database add logfile '+DG' size 10M;

Database altered.

SQL> alter database add logfile '+DG' size 10M;

Database altered.

SQL> alter database add logfile '+DG' size 10M; 添加三个redolog组到ASM磁盘组DG上

Database altered.

SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;

    GROUP#  SEQUENCE# NAME           STATUS  ARC

---------- ---------- ---------------------------------------- ---------------- ---

  3     6 /u01/app/oracle/oradata/WM/redo03.log    CURRENT  NO

  2     5 /u01/app/oracle/oradata/WM/redo02.log    INACTIVE  YES

  1     4 /u01/app/oracle/oradata/WM/redo01.log    INACTIVE  YES

  4     0 +DG/wm/onlinelog/group_4.263.740758405   UNUSED  YES

  5     0 +DG/wm/onlinelog/group_5.264.740758423   UNUSED  YES

  6     0 +DG/wm/onlinelog/group_6.265.740758425   UNUSED  YES

6 rows selected.

 

SQL> alter database drop logfile '/u01/app/oracle/oradata/WM/redo02.log';

Database altered.

SQL> alter database drop logfile '/u01/app/oracle/oradata/WM/redo01.log';删除文件系统上的redolog组

Database altered.

SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;

    GROUP#  SEQUENCE# NAME           STATUS  ARC

---------- ---------- ---------------------------------------- ---------------- ---

  3     6 /u01/app/oracle/oradata/WM/redo03.log    CURRENT  NO

  4     0 +DG/wm/onlinelog/group_4.263.740758405   UNUSED  YES

  5     0 +DG/wm/onlinelog/group_5.264.740758423   UNUSED  YES

  6     0 +DG/wm/onlinelog/group_6.265.740758425   UNUSED  YES

SQL> alter system switch logfile;

System altered.

SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;

    GROUP#  SEQUENCE# NAME           STATUS  ARC

---------- ---------- ---------------------------------------- ---------------- ---

  3     6 /u01/app/oracle/oradata/WM/redo03.log    ACTIVE  NO

  4     7 +DG/wm/onlinelog/group_4.263.740758405   CURRENT  NO

  5     0 +DG/wm/onlinelog/group_5.264.740758423   UNUSED  YES

  6     0 +DG/wm/onlinelog/group_6.265.740758425   UNUSED  YES

SQL> alter system checkpoint;

System altered.

SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;

    GROUP#  SEQUENCE# NAME           STATUS  ARC

---------- ---------- ---------------------------------------- ---------------- ---

  3     6 /u01/app/oracle/oradata/WM/redo03.log    INACTIVE  NO

  4     7 +DG/wm/onlinelog/group_4.263.740758405   CURRENT  NO

  5     0 +DG/wm/onlinelog/group_5.264.740758423   UNUSED  YES

  6     0 +DG/wm/onlinelog/group_6.265.740758425   UNUSED  YES

SQL> alter database drop logfile group 3;

Database altered.

SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;

    GROUP#  SEQUENCE# NAME           STATUS  ARC

---------- ---------- ---------------------------------------- ---------------- ---

  4     7 +DG/wm/onlinelog/group_4.263.740758405   CURRENT  NO

  5     0 +DG/wm/onlinelog/group_5.264.740758423   UNUSED  YES

  6     0 +DG/wm/onlinelog/group_6.265.740758425   UNUSED  YES

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;

    GROUP#  SEQUENCE# NAME           STATUS  ARC

---------- ---------- ---------------------------------------- ---------------- ---

  4     7 +DG/wm/onlinelog/group_4.263.740758405   ACTIVE  NO

  5     8 +DG/wm/onlinelog/group_5.264.740758423   ACTIVE  NO

  6     9 +DG/wm/onlinelog/group_6.265.740758425   CURRENT  NO

第六步,删除文件系统上的数据文件

[oracle@oracle oradata]$ cd $ORACLE_BASE/oradata

[oracle@oracle oradata]$ ls WM

[oracle@oracle oradata]$ rm -rf WM/

[oracle@oracle oradata]$ ls

来源链接:https://www.cnblogs.com/luoyx/archive/2012/05/04/2482664.html

版权声明:
1、Java侠(https://www.javaxia.com)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaxia.com/server/124823.html

标签: unused variable
分享给朋友: