11g数据库迁移ASM

简介: 1.
1.迁移参数文件

[oracle@PROD1 ~]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 2 20:34:02 2016


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




Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


SQL> show parameter pfile;


NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile     string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/spfilePROD1.ora
在+DATA磁盘组中创建对应的目录PROD1;PROD1/parameter/;
[oracle@PROD1 ~]$ su - grid
Password: 
[grid@PROD1 ~]$ asmcmd
ASMCMD> ls
DATA/
ASMCMD> cd DATA/
ASMCMD> ls
ASM/
DB_UNKNOWN/
PROD1/
ASMCMD> cd PROD1
ASMCMD> ls
parameter/
ASMCMD> cd parameter/  
ASMCMD> pwd
+DATA/PROD1/parameter
ASMCMD> ls

ASMCMD> cp /u01/app/oracle/product/11.2.0//dbhome_1/dbs/spfilePROD1.ora .

copying /u01/app/oracle/product/11.2.0//dbhome_1/dbs/spfilePROD1.ora -> +DATA/PROD1/parameter/spfilePROD1.ora

ASMCMD> exit

[grid@PROD1 ~]$ su - oracle
Password: 
[oracle@PROD1 ~]$ cd $ORACLE_HOME/dbs
[oracle@PROD1 dbs]$ ls
fls  hc_+ASM.dat  hc_PROD1.dat  init+ASM.ora  init.ora  lkPROD1  orapwPROD1  spfilePROD1.ora
[oracle@PROD1 dbs]$ ls
fls  hc_+ASM.dat  hc_PROD1.dat  init+ASM.ora  init.ora  lkPROD1  orapwPROD1  spfilePROD1.ora
[oracle@PROD1 dbs]$ mv spfilePROD1.ora spfilePROD1.ora.bak

[oracle@PROD1 dbs]$ vi initPROD1.ora
SPFILE='+data/prod1/parameter/spfilePROD1.ora'

[oracle@PROD1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 2 20:44:03 2016
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup nomount force;
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
SQL> show parameter pfile;


NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile     string +DATA/prod1/parameter/spfilepr
od1.ora

迁移控制文件
SQL> show parameter control_files;


NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files     string /u01/app/oracle/oradata/PROD1/
control01.ctl, /u01/app/oracle
/oradata/PROD1/control02.ctl
SQL> alter system set control_files='+data' scope=spfile;
System altered.
SQL> startup mount force;
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
ORA-00205: error in identifying control file, check alert log for more info

SQL> ho rman target /



Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 2 20:51:00 2016


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


connected to target database: PROD1 (not mounted)


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


Starting restore at 02-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=14 device type=DISK


channel ORA_DISK_1: copied control file copy
output file name=+DATA/prod1/controlfile/current.260.900103889
Finished restore at 02-JAN-16

RMAN> exit

Recovery Manager complete.

SQL> show parameter control_files;


NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files     string +DATA/prod1/controlfile/curren
t.260.900103889

迁移数据文件

SQL> alter database mount;

Database altered.
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD1/system01.dbf
/u01/app/oracle/oradata/PROD1/sysaux01.dbf
/u01/app/oracle/oradata/PROD1/undotbs01.dbf
/u01/app/oracle/oradata/PROD1/users01.dbf

SQL> ho rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 2 20:58:57 2016

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

connected to target database: PROD1 (DBID=2121445908, not open)

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

Starting backup at 02-JAN-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=136 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD1/system01.dbf
output file name=+DATA/prod1/datafile/system.269.900104401 tag=TAG20160102T205959 RECID=1 STAMP=900104464
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD1/sysaux01.dbf
output file name=+DATA/prod1/datafile/sysaux.257.900104465 tag=TAG20160102T205959 RECID=2 STAMP=900104509
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD1/undotbs01.dbf
output file name=+DATA/prod1/datafile/undotbs1.256.900104511 tag=TAG20160102T205959 RECID=3 STAMP=900104512
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/prod1/controlfile/backup.270.900104513 tag=TAG20160102T205959 RECID=4 STAMP=900104515
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/PROD1/users01.dbf
output file name=+DATA/prod1/datafile/users.271.900104517 tag=TAG20160102T205959 RECID=5 STAMP=900104516
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 02-JAN-16
channel ORA_DISK_1: finished piece 1 at 02-JAN-16
piece handle=+DATA/prod1/backupset/2016_01_02/nnsnf0_tag20160102t205959_0.272.900104517 tag=TAG20160102T205959 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-JAN-16

RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DATA/prod1/datafile/system.269.900104401"
datafile 2 switched to datafile copy "+DATA/prod1/datafile/sysaux.257.900104465"
datafile 3 switched to datafile copy "+DATA/prod1/datafile/undotbs1.256.900104511"
datafile 4 switched to datafile copy "+DATA/prod1/datafile/users.271.900104517"

RMAN> recover database;

Starting recover at 02-JAN-16
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 02-JAN-16

迁移临时表空间
SQL> alter database open RESETLOGS;

Database altered.

SQL> select name from v$tempfile;


NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD1/temp01.dbf

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

Tablespace altered.

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

Tablespace altered.

SQL> select name from v$tempfile;


NAME
--------------------------------------------------------------------------------
+DATA/prod1/tempfile/temp.273.900104921

迁移日志文件



SQL> select member from v$logfile;


MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/PROD1/redo03.log
/u01/app/oracle/oradata/PROD1/redo02.log
/u01/app/oracle/oradata/PROD1/redo01.log
SQL> show parameter create

NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
create_bitmap_area_size     integer 8388608
create_stored_outlines     string
db_create_file_dest     string
db_create_online_log_dest_1     string
db_create_online_log_dest_2     string
db_create_online_log_dest_3     string
db_create_online_log_dest_4     string
db_create_online_log_dest_5     string

SQL> alter system set db_create_online_log_dest_1='+data';

System altered.


SQL> ho vi redo.sql

SET SERVEROUTPUT ON;


DECLARE


   CURSOR rlc IS


      SELECT GROUP# GRP, THREAD# THR, BYTES, 'NO' SRL


      FROM   V$LOG


      UNION


      SELECT GROUP# GRP, THREAD# THR, BYTES, 'YES' SRL


      FROM   V$STANDBY_LOG


      ORDER BY 1;


   stmt     VARCHAR2(2048);


BEGIN


   FOR rlcRec IN rlc LOOP


      IF (rlcRec.srl = 'YES') THEN


         stmt := 'ALTER DATABASE ADD STANDBY LOGFILE THREAD ' ||


                 rlcRec.thr || ' SIZE ' || rlcRec.bytes;


         EXECUTE IMMEDIATE stmt;


         stmt := 'ALTER DATABASE DROP STANDBY LOGFILE GROUP ' || rlcRec.grp;


         EXECUTE IMMEDIATE stmt;


      ELSE


         stmt := 'ALTER DATABASE ADD LOGFILE THREAD ' ||


                 rlcRec.thr || ' SIZE ' ||  rlcRec.bytes;


         EXECUTE IMMEDIATE stmt;


         BEGIN


            stmt := 'ALTER DATABASE DROP LOGFILE GROUP ' || rlcRec.grp;


            DBMS_OUTPUT.PUT_LINE(stmt);


            EXECUTE IMMEDIATE stmt;


         EXCEPTION


            WHEN OTHERS THEN


               EXECUTE IMMEDIATE 'ALTER SYSTEM SWITCH LOGFILE';


               EXECUTE IMMEDIATE 'ALTER SYSTEM CHECKPOINT GLOBAL';


               EXECUTE IMMEDIATE stmt;


         END;


      END IF;


   END LOOP;


END;


/
SQL> @redo.sql
ALTER DATABASE DROP LOGFILE GROUP 1
ALTER DATABASE DROP LOGFILE GROUP 2
ALTER DATABASE DROP LOGFILE GROUP 3


PL/SQL procedure successfully completed.

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
--------------------------------------------------------------------------------
+DATA/prod1/controlfile/current.260.900103889
+DATA/prod1/datafile/system.269.900104401
+DATA/prod1/datafile/sysaux.257.900104465
+DATA/prod1/datafile/undotbs1.256.900104511
+DATA/prod1/datafile/users.271.900104517
+DATA/prod1/onlinelog/group_2.276.900105383
+DATA/prod1/onlinelog/group_1.275.900105377
+DATA/prod1/onlinelog/group_4.274.900105375


8 rows selected.
迁移完成;
























,
相关文章
|
3月前
|
弹性计算 关系型数据库 数据库
手把手带你从自建 MySQL 迁移到云数据库,一步就能脱胎换骨
阿里云瑶池数据库来开课啦!自建数据库迁移至云数据库 RDS原来只要一步操作就能搞定!点击阅读原文完成实验就可获得一本日历哦~
|
3月前
|
关系型数据库 MySQL 数据库
|
3月前
|
关系型数据库 MySQL 数据库
RDS MySQL灾备服务协同解决方案构建问题之数据库备份数据的云上云下迁移如何解决
RDS MySQL灾备服务协同解决方案构建问题之数据库备份数据的云上云下迁移如何解决
|
30天前
|
算法 大数据 数据库
云计算与大数据平台的数据库迁移与同步
本文详细介绍了云计算与大数据平台的数据库迁移与同步的核心概念、算法原理、具体操作步骤、数学模型公式、代码实例及未来发展趋势与挑战。涵盖全量与增量迁移、一致性与异步复制等内容,旨在帮助读者全面了解并应对相关技术挑战。
37 3
|
1月前
|
存储 Oracle 关系型数据库
数据库数据恢复—Oracle ASM磁盘组故障数据恢复案例
Oracle数据库数据恢复环境&故障: Oracle ASM磁盘组由4块磁盘组成。Oracle ASM磁盘组掉线 ,ASM实例不能mount。 Oracle数据库故障分析&恢复方案: 数据库数据恢复工程师对组成ASM磁盘组的磁盘进行分析。对ASM元数据进行分析发现ASM存储元数据损坏,导致磁盘组无法挂载。
|
2月前
|
存储 SQL 关系型数据库
一篇文章搞懂MySQL的分库分表,从拆分场景、目标评估、拆分方案、不停机迁移、一致性补偿等方面详细阐述MySQL数据库的分库分表方案
MySQL如何进行分库分表、数据迁移?从相关概念、使用场景、拆分方式、分表字段选择、数据一致性校验等角度阐述MySQL数据库的分库分表方案。
422 15
一篇文章搞懂MySQL的分库分表,从拆分场景、目标评估、拆分方案、不停机迁移、一致性补偿等方面详细阐述MySQL数据库的分库分表方案
|
2月前
|
SQL Java 数据库连接
数据库迁移不再难:Flyway 与 Liquibase 大比拼,哪个才是你的真命天子?
【9月更文挑战第3天】数据库迁移在软件开发中至关重要,尤其在使用 ORM 框架如 Hibernate 时。为确保部署时能顺利应用最新的数据库变更,开发者常使用自动化工具。Flyway 和 Liquibase 是当前流行的两种选择,均能有效管理数据库版本控制。Flyway 采用 SQL 脚本表示变更,简单易用;Liquibase 支持多种脚本格式,功能更强大,适合复杂项目。本文将对比这两种工具的特点,并通过示例展示各自的优缺点,帮助开发者根据项目需求做出合适的选择。
545 1
|
3月前
|
JSON NoSQL Ubuntu
在Ubuntu 14.04上如何备份、恢复和迁移MongoDB数据库
在Ubuntu 14.04上如何备份、恢复和迁移MongoDB数据库
93 1
|
3月前
|
API Java 开发框架
【从零到精通】如何用Play Framework快速构建RESTful API?看完这篇你就懂了!
【8月更文挑战第31天】《Play Framework快速入门:从零开始构建RESTful API》介绍了如何使用高性能Web开发框架Play Framework构建简单的RESTful API。从环境搭建到项目创建,再到实现用户列表的增删查功能,本文档详细指导每个步骤,并解释核心概念。适合初学者快速上手。首先确保已安装JDK和sbt,然后通过sbt创建Play项目,接着定义控制器、模型及路由,最后运行应用进行测试。通过本教程,你将掌握构建RESTful API的基础知识,为进一步学习Play Framework打下坚实基础。
52 0
|
3月前
|
SQL Oracle 关系型数据库
Entity Framework Core 实现多数据库支持超厉害!配置连接、迁移与事务,开启多元数据库之旅!
【8月更文挑战第31天】在现代软件开发中,为了满足不同业务需求及环境要求,常需支持多个数据库系统。Entity Framework Core(EF Core)作为一款强大的对象关系映射(ORM)框架,通过数据库提供程序与多种数据库如SQL Server、MySQL、PostgreSQL、Oracle等交互。开发者可通过安装相应NuGet包并配置`DbContextOptionsBuilder`来指定不同数据库连接,从而实现多数据库支持。
214 0
下一篇
无影云桌面