ASM数据库迁移(数据库从文件系统迁移到ASM)

 迁移前检查

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                    2257800 bytes

Variable Size                  536874104 bytes

Database Buffers          285212672 bytes

Redo Buffers                    6586368 bytes

Database mounted.

Database opened.

SQL> select name,open_mode,log_mode from v$database;

 

NAME          OPEN_MODE               LOG_MODE

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

ENMOEDU   READ WRITE               NOARCHIVELOG

SQL> show parameter pfile;

 

NAME                                     TYPE         VALUE

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

spfile                                     string         /u01/app/oracle/product/11.2.0

 .db_1/dbs/spfileenmoedu.ora

SQL> select name from v$controlfile

  2  union all

  3  select name from v$datafile

  4  union all

  5  select member from v$logfile;

 

NAME

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

/u01/app/oracle/oradata/enmoedu/control01.ctl

/u01/app/oracle/fast_recovery_area/enmoedu/control02.ctl

/u01/app/oracle/oradata/enmoedu/system01.dbf

/u01/app/oracle/oradata/enmoedu/sysaux01.dbf

/u01/app/oracle/oradata/enmoedu/undotbs01.dbf

/u01/app/oracle/oradata/enmoedu/users01.dbf

/u01/app/oracle/oradata/enmoedu/example01.dbf

/u01/app/oracle/oradata/enmoedu/redo03.log

/u01/app/oracle/oradata/enmoedu/redo02.log

/u01/app/oracle/oradata/enmoedu/redo01.log

 

10 rows selected.

SQL> show parameter db_recovery_file_dest;

 

NAME                                     TYPE         VALUE

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

db_recovery_file_dest                     string         /u01/app/oracle/fast_recovery_

 area

db_recovery_file_dest_size             big integer 4182M

003 迁移前检查

检查以下ASM相关设置

 

[grid@enmoedu grid]$ oracleasm querydisk -p data

Disk "DATA" does not exist or is not instantiated不存在,似乎是因为disk是由两个磁盘分区组成的,所以没显示出来,下同

[grid@enmoedu grid]$ oracleasm querydisk -p fls

Disk "FLS" does not exist or is not instantiated

 

[grid@enmoedu grid]$ asmcmd -p lsct

[grid@enmoedu grid]$ asmcmd -p lsdg

State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name

MOUNTED  NORMAL  N         512   4096  1048576      6134     6014                0            3007              0             N  DATA/

MOUNTED  NORMAL  N         512   4096  1048576      6134     6028                0            3014              0             N  FLS/

当前ASM磁盘组已经分配完毕,使用率0%,没有分配空间给任何实例。

数据库参数更改

SQL> alter system set control_files='+data','+fls' scope=spfile;控制文件位置

 

System altered.

 

SQL> alter system set db_create_file_dest='+data';数据文件位置

 

System altered.

  DB_CREATE_FILE_DEST specifies the default

location for Oracle-managed datafiles. This location is also used as the default location for Oracle-managed control files and online redo logs if none

of the DB_CREATE_ONLINE_LOG_DEST_n initialization parameters are specified.

SQL> alter system set db_create_online_log_dest_1='+data';联机重做日志文件位置1

 

System altered.

 

SQL> alter system set db_create_online_log_dest_2='+fls'; 联机重做日志文件位置2

System altered.

SQL> alter system set db_recovery_file_dest='+fls'; 快速恢复区的位置

System altered.

System altered.

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

004 实施迁移

[oracle@enmoedu ~]$ rman

 

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Feb 26 16:31:33 2016

 

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

 

RMAN> connect target

 

connected to target database (not started)

 

RMAN> startup nomount

 

Oracle instance started

 

Total System Global Area     830930944 bytes

 

Fixed Size                     2257800 bytes

Variable Size                536874104 bytes

Database Buffers             285212672 bytes

Redo Buffers                   6586368 bytes

RMAN> restore controlfile from '/u01/app/oracle/oradata/enmoedu/control01.ctl';

 

Starting restore at 26-FEB-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=137 device type=DISK

 

channel ORA_DISK_1: copied control file copy

output file name=+DATA/enmoedu/controlfile/current.256.904840405

output file name=+FLS/enmoedu/controlfile/current.256.904840405

Finished restore at 26-FEB-16

RMAN> alter database mount;

database mounted

released channel: ORA_DISK_1

RMAN> backup as copy database format '+data';

 

Starting backup at 26-FEB-16

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=137 device type=DISK

channel ORA_DISK_1: starting datafile copy

input datafile file number=00001 name=/u01/app/oracle/oradata/enmoedu/system01.dbf

output file name=+DATA/enmoedu/datafile/system.257.904840489 tag=TAG20160226T163448 RECID=2 STAMP=904840507

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25

channel ORA_DISK_1: starting datafile copy

input datafile file number=00002 name=/u01/app/oracle/oradata/enmoedu/sysaux01.dbf

output file name=+DATA/enmoedu/datafile/sysaux.258.904840515 tag=TAG20160226T163448 RECID=3 STAMP=904840524

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15

channel ORA_DISK_1: starting datafile copy

input datafile file number=00005 name=/u01/app/oracle/oradata/enmoedu/example01.dbf

output file name=+DATA/enmoedu/datafile/example.259.904840529 tag=TAG20160226T163448 RECID=4 STAMP=904840535

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07

channel ORA_DISK_1: starting datafile copy

input datafile file number=00003 name=/u01/app/oracle/oradata/enmoedu/undotbs01.dbf

output file name=+DATA/enmoedu/datafile/undotbs1.260.904840537 tag=TAG20160226T163448 RECID=5 STAMP=904840538

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting datafile copy

copying current control file

output file name=+DATA/enmoedu/controlfile/backup.261.904840541 tag=TAG20160226T163448 RECID=6 STAMP=904840541

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting datafile copy

input datafile file number=00004 name=/u01/app/oracle/oradata/enmoedu/users01.dbf

output file name=+DATA/enmoedu/datafile/users.262.904840543 tag=TAG20160226T163448 RECID=7 STAMP=904840543

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

including current SPFILE in backup set

channel ORA_DISK_1: starting piece 1 at 26-FEB-16

channel ORA_DISK_1: finished piece 1 at 26-FEB-16

piece handle=+DATA/enmoedu/backupset/2016_02_26/nnsnf0_tag20160226t163448_0.263.904840545 tag=TAG20160226T163448 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03

Finished backup at 26-FEB-16

 

RMAN> switch database to copy;等同于在sqlplus中执行的alter database rename file

 

datafile 1 switched to datafile copy "+DATA/enmoedu/datafile/system.257.904840489"

datafile 2 switched to datafile copy "+DATA/enmoedu/datafile/sysaux.258.904840515"

datafile 3 switched to datafile copy "+DATA/enmoedu/datafile/undotbs1.260.904840537"

datafile 4 switched to datafile copy "+DATA/enmoedu/datafile/users.262.904840543"

datafile 5 switched to datafile copy "+DATA/enmoedu/datafile/example.259.904840529"

 

 

 

RMAN> recover database;

 

Starting recover at 26-FEB-16

using channel ORA_DISK_1

 

starting media recovery

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

 

Finished recover at 26-FEB-16

 

RMAN> alter database open;

database opened

RMAN>

迁移临时表空间和联机重做日志文件

SQL> select name from v$tempfile;

 

NAME

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

/u01/app/oracle/oradata/enmoedu/temp01.dbf

SYS@ORCL> alter tablespace temp add tempfile '+data';

Tablespace altered.

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

 

Tablespace altered.

SQL> select name from v$tempfile;

 

NAME

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

+DATA/enmoedu/tempfile/temp.264.904841501

SQL> alter database add logfile '+data' size 50m;

 

Database altered.

 

SQL> alter database add logfile '+data' size 50m;

 

Database altered.

 

SQL> alter database add logfile '+data' size 50m;

 

Database altered.

SQL> set linesize 120;

SQL> col member for a50;

SQL> select k.member,j.status

  2  from v$logfile k,v$log j

  3  where k.group#=j.group#;

 

MEMBER                                                   STATUS

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

/u01/app/oracle/oradata/enmoedu/redo03.log           UNUSED

/u01/app/oracle/oradata/enmoedu/redo02.log           UNUSED

/u01/app/oracle/oradata/enmoedu/redo01.log           CURRENT

+DATA/enmoedu/onlinelog/group_4.265.904841853           UNUSED

+DATA/enmoedu/onlinelog/group_5.266.904841907           UNUSED

+DATA/enmoedu/onlinelog/group_6.267.904841961           UNUSED

SQL> alter database drop logfile '/u01/app/oracle/oradata/enmoedu/redo03.log';

 

Database altered.

 

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

 

Database altered.

 

SQL> select k.member,j.status

  2  from v$logfile k,v$logfile j

  3  where k.group#=j.group#;

 

MEMBER                                                   STATUS

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

/u01/app/oracle/oradata/enmoedu/redo01.log

+DATA/enmoedu/onlinelog/group_4.265.904841853

+DATA/enmoedu/onlinelog/group_5.266.904841907

+DATA/enmoedu/onlinelog/group_6.267.904841961

SYS@ORCL> alter system switch logfile;

System altered.

SQL> select k.member,j.status from v$logfile k,v$logfile j

  2  where k.group#=j.group#;

 

MEMBER                                                   STATUS

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

/u01/app/oracle/oradata/enmoedu/redo01.log

+DATA/enmoedu/onlinelog/group_4.265.904841853

+DATA/enmoedu/onlinelog/group_5.266.904841907

+DATA/enmoedu/onlinelog/group_6.267.904841961

SYS@ORCL> alter system checkpoint;

System altered.

SQL> select k.member,j.status

  2  from v$logfile k,v$logfile j

  3  where k.group#=j.group#;

 

MEMBER                                                   STATUS

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

/u01/app/oracle/oradata/enmoedu/redo01.log

+DATA/enmoedu/onlinelog/group_4.265.904841853

+DATA/enmoedu/onlinelog/group_5.266.904841907

+DATA/enmoedu/onlinelog/group_6.267.904841961

 

SQL> alter database drop logfile '/u01/app/oracle/oradata/enmoedu/redo01.log';

 

Database altered.

 

 

Database altered.

SQL> select k.member,j.status

  2  from v$logfile k,v$logfile j

  3  where k.group#=j.group#;

 

MEMBER                                                   STATUS

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

+DATA/enmoedu/onlinelog/group_4.265.904841853

+DATA/enmoedu/onlinelog/group_5.266.904841907

+DATA/enmoedu/onlinelog/group_6.267.904841961

迁移参数文件

SQL> create pfile from spfile;

File created.

SQL> create spfile='+data' from pfile='/u01/app/oracle/product/11.2.0.db_1/dbs/initenmoedu.ora';

 

File created.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> quit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

[oracle@enmoedu ~]$ rm /u01/app/oracle/product/11.2.0.db_1/dbs/spfileenmoedu.ora.bak

[oracle@enmoedu ~]$ cd /u01/app/oracle/product/11.2.0.db_1/dbs/

[oracle@enmoedu dbs]$ ls

hc_enmo.dat     hc_jj.dat        init.ora               lkENMOEDU

hc_enmoedu.dat  initenmoedu.ora  init.ora.125201623126  orapwenmoedu

 

[grid@enmoedu Desktop]$ asmcmd

ASMCMD> ls

DATA/

FLS/

ASMCMD> cd data

ASMCMD> ls

ASM/

ENMOEDU/

 

ASMCMD> cd enmoedu

ASMCMD> ls

BACKUPSET/

CONTROLFILE/

DATAFILE/

ONLINELOG/

PARAMETERFILE/

TEMPFILE/

ASMCMD> cd parameterfile

ASMCMD> ls

spfile.268.904845247

 

[oracle@enmoedu dbs]$ vi initenmoedu.ora

 

spfile='+data/enmoedu/parameterfile/spfile.268.904845247'

[oracle@enmoedu dbs]$ sqlplus / as sysdba

 

SQL*Plus: Release 11.2.0.4.0 Production on Fri Feb 26 18:30:53 2016

 

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

 

Connected to an idle instance.

 

SQL> startup

ORACLE instance started.

 

Total System Global Area  830930944 bytes

Fixed Size                    2257800 bytes

Variable Size                  536874104 bytes

Database Buffers          285212672 bytes

Redo Buffers                    6586368 bytes

Database mounted.

Database opened.

SQL> show parameter pfile;

 

NAME                                     TYPE         VALUE

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

spfile                                     string         +DATA/enmoedu/parameterfile/sp

 file.268.904845247

验证各文件存储位置

SQL> select name from v$datafile

  2  union all

  3  select name from v$tempfile

  4  union all

  5  select member from v$logfile

  6  union all

  7  select name from v$controlfile;

 

NAME

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

+DATA/enmoedu/datafile/system.257.904840489

+DATA/enmoedu/datafile/sysaux.258.904840515

+DATA/enmoedu/datafile/undotbs1.260.904840537

+DATA/enmoedu/datafile/users.262.904840543

+DATA/enmoedu/datafile/example.259.904840529

+DATA/enmoedu/tempfile/temp.264.904841501

+DATA/enmoedu/onlinelog/group_4.265.904841853

+DATA/enmoedu/onlinelog/group_5.266.904841907

+DATA/enmoedu/onlinelog/group_6.267.904841961

+DATA/enmoedu/controlfile/current.256.904840405

+FLS/enmoedu/controlfile/current.256.904840405

 

11 rows selected.

SQL> show parameter pfile;

 

NAME                                     TYPE         VALUE

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

spfile                                     string         +DATA/enmoedu/parameterfile/sp

 file.268.904845247

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30606702/viewspace-1995328/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30606702/viewspace-1995328/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值