1) Prerequisites
    ----------------

- The copy of the datafiles must be done with the database closed or the database must be in ARCHIVELOG  mode.
     To determine the Database is in Archivemode or Noarchivemode use:

       SQL> select name, log_mode from v$database;

2) Init<sid>.ora or Spfile<sid>.ora and Controlfile
     ----------------------------------------------------
   - You need to copy the init.ora or spfile file to the target host
     and locate it in ORACLE_HOME\dbs

- Copy the
        Controlfile(s),
        all the Datafiles  
        all the Archivelogs generated,
     to the target host.

# To copy the Controlfile,
    - either do a clean shutdown the Database, then take a cold copy of the controlfile
    - or if database is open and Online Backup is taken do:

       SQL> alter database backup controlfile to '/path/cf_name.ctl' ;   -- this takes a binary copy of the controlfile

-- Hint:
          Do this to get a creation script for the controlfile, in case needed.
          The following statement writes a tracefile to the 'trace' directory containing 'Create Controlfile' Statements
          .
           SQL> alter database backup controlfile to trace ;

# To backup the Database if database is open then, you need to put all the tablespaces in BACKUP MODE,
      before starting the copy of the database/datafiles :

     SQL> select tablespace_name from dba_tablespaces;

SQL> ALTER TABLESPACE <TABLESPACE_NAME> BEGIN BACKUP;
        .
         > copy all the tablespace 'datafiles'
        .
    SQL> ALTER TABLESPACE <TABLESPACE_NAME> END BACKUP;

# ==> Do this copy for 'ALL THE TABLESPACES/Datafiles'  in the Database !!

# Comment: Starting with Oracle 10g:
               you can use the BEGIN BACKUP on 'database' level, instead of 'tablespace' level :

SQL> alter DATABASE begin backup;
                .
                 > copy all the tablespace 'datafiles'
                .
            SQL> alter DATABASE end backup;

3) Set the oracle environment
   -------------------------

    C:\> set ORACLE_SID=<SID>
    C:\> sqlplus "sys/password as sysdba"

- Check the init<sid>.ora  parameters that reference 'path/dir' location
    
    control_files                   = <duplicate db control file(s)>
    background_dump_dest  = bdump>
    core_dump_dest            = cdump>
    user_dump_dest            = udump>
    log_archive_dest_1        = <duplicate db arch dump location>

4) Set up a password file for the duplicated database

    $ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=<...>

If Windows Platform, create a new NT service for the 'cloned' duplicated database  using oradim.

   C:\> oradim -new -sid -intpwd -maxusers 10 -startmode manual -spfile  ''

# or

C:\> oradim -new -sid -intpwd -maxusers 10 -startmode manual -pfile   ''

 sample:

1) orapwd file=C:\app\oracle\product\12.1.0\dbhome_1\database\orapwtestUAT12C.ora password=oracle123

2)oradim -new -sid testUAT12C -SYSPWD oracle123 -maxusers 10 -startmode manual -pfile  'C:\app\oracle\product\12.1.0\dbhome_1\database\INITtestUAT12C.ORA'

3) copy network from source to destination

6)  Startup the database in mount status

    SQL> startup mount

-- Rename any of the datafiles to the new location, if necessary:

SQL> ALTER DATABASE RENAME FILE
               '/FULL_PATH_OF_OLD_LOCATION/AND_DATAFILE_NAME.DBF'
               TO
               '/FULL_PATH_OF_NEW_LOCATION/AND_DATAFILE_NAME.DBF';

-- Rename the logfiles to the new location if necessary

SQL> alter database rename file '<host A location>' to '<host B location>';

7)  Check that all the datafiles are in the right location and ONLINE:

SQL> SELECT FILE#, STATUS, NAME FROM V$DATAFILE;

8) Perform incomplete recovery:

SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;

Forward the database applying archived redo log files until you decide
    to stop recovery by typing 'CANCEL' at the prompt
    (assuming that you have  required archived redo log files in the log_archive_dest directory)
    .
    You may archive the source database redo log files and apply them at
    the target database if required.

SQL> ALTER DATABASE OPEN RESETLOGS;

9) In Windows platforms, if you want that the database will start automatically then edit the registry:

     regedit
       go to
       HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEX
       .
       change the key :  ORA_<SID>_AUTOSTART=TRUE
 
 
sample 2: clone cold backup from prod to uat . 

1.make file and modfiy file:
'C:\app\Administrator\product\11.2.0\dbhome_1\database\initdmprod.ora'

2.
orapwd file=C:\app\Administrator\product\11.2.0\dbhome_1\database\PWDDMSPROD.ora password=oracle123
oradim -new -sid dmsprod -SYSPWD oracle123 -maxusers 10 -startmode manual -pfile 'C:\app\Administrator\product\11.2.0\dbhome_1\database\initdmsprod.ora'

3.
C:\app\Administrator\admin
set ORACLE_SID=dmprod
sqlplus "sys/oralce as sysdba"

startup mount

##change data file location to 'D:\dmsprod'
rman nocatalog target /
catalog start with 'D:\dmsprod';
switch database to copy;

sqlplus "sys/oralce as sysdba"

select 'alter database rename file '||''''||member||''''||' to '||chr(39)||replace(member,'F:\ORA11GDATA\DMSPROD\','D:\dmsprod\')||''';' from v$logfile;

shutdown immediate
startup

ALTER TABLESPACE TEMP ADD TEMPFILE 'D:\DMSPROD\TEMP01.DBF' REUSE;
ALTER TABLESPACE TEMP drop TEMPFILE 'F:\ORA11GDATA\DMSPROD\TEMP01.DBF';

4.
add service_names='DMSUAT,DMSPROD’
select service_id,name from v$services;

windows 迁移数据库的更多相关文章

  1. 如丝般顺滑地从Windows迁移SQLServer数据库到Linux

    老鸟看过菜鸟的上一篇<MSSQL On Linux备份与还原>文章后,很满意,但是还是忍不住发问:"这篇文章讲的是MSSQL在Linux系统上的备份与还原,如果我之前是Windo ...

  2. 正确把mysql数据库从windows迁移到linux系统上的方法

    (一)用mysqldump命令导出数据库文件: 在windows下cd到Mysql的bin目录: c:/data.txt这个目录和导出的文本名可以自己随便取,-B 后面的是表名,我要导出的表明叫use ...

  3. MySQL数据库从windows迁移到linux

    前几天搭建了lamp环境,想把之前写的小东西迁到linux上运行,涉及到把mysql数据库的文件迁移到linux上,直接用fileZilla传过去应该不行,我试了下,反正没成功.下面是我采用的方法: ...

  4. windows clone 迁移数据库

    windows clone 迁移数据库可行.(c 盘底成复制)

  5. 我将系统从Windows迁移至Linux下的点点滴滴

    一.写在最前 由于本人的技术水平有限,难免会出现错误.本文对任何一个人有帮助都是我莫大的荣幸,任何一个大神对我的点拨,我都会感激不尽. 二.技术选型 在2013年8月低的时候,公司中了XXX市场监督局 ...

  6. 跨平台迁移数据库windows-Linux

    将10.10.1.127服务器的数据库ORCL(WINDOWS)迁移到VM 10.10.10.168LINUX平台 操作系统:Windows server 2008r2 64bit CentOS  L ...

  7. 使用数据泵(expdp、impdp)迁移数据库流程

    转载原文地址为:http://blog.itpub.net/26736162/viewspace-2652256/ 使用数据泵迁移数据库流程 How To Move Or Copy A Databas ...

  8. 全自动迁移数据库的实现 (Fluent NHibernate, Entity Framework Core)

    在开发涉及到数据库的程序时,常会遇到一开始设计的结构不能满足需求需要再添加新字段或新表的情况,这时就需要进行数据库迁移. 实现数据库迁移有很多种办法,从手动管理各个版本的ddl脚本,到实现自己的mig ...

  9. 使用rman迁移数据库到异机

    迁移数据库的方法有多种,较为常用的则是使用RMAN来迁移.使用RMAN迁移数据库属于数据库的物理备份与恢复范畴,整个过程中数据库的相关信息是完整地镜像.因此,基于此种方式还原恢复的数据库用于测试会使得 ...

随机推荐

  1. Cocostudio 1.4 实现的DemoShop

    开发环境是CocoStudio 1.4 + Cocos2dx 2.2  把项目文件放到Cocos2dx下的projects文件夹下就可以执行了 压缩包里面包括了 源码 和资源文件 执行效果: 初始化界 ...

  2. Windows环境下QWT安装及配置

    ** 1.QWT下载路径 **:https://sourceforge.net/projects/qwt/ 主要下载这三个文件:qwt-6.1.2.zip.qwt-6.1.2.pdf,qwt-6.1. ...

  3. hi3531 SDK已编译文件系统制作jffs2文件系统镜像并解决这个问题 .

    一, 安装SDK 1.Hi3531 SDK包位置 在"Hi3531_V100R001***/01.software/board"文件夹下,您能够看到一个 Hi3531_SDK_Vx ...

  4. I2C上拉电阻取值范围

    I2C总线是微电子通信控制领域中常用的一种总线标准,具备接线少,控制简单,速率高等优点.在I2C电路中常见的上拉电阻有1k.1.5k.2.2k.4.7k.5.1k.10k等等,但是应该如何根据开发要求 ...

  5. Oracle 模糊查询方法

           在这个信息量剧增的时代,怎样帮助用户从海量数据中检索到想要的数据.模糊查询是不可缺少的. 那么在Oracle中模糊查询是怎样实现的呢?   一.我们能够在where子句中使用likeke ...

  6. iOS 开发者中的个人账号与组织账号之间区别

    苹果对开发者主要分为3类:个人.组织(公司.企业).教育机构.即: 1.个人(Individual) 2.组织(Organizations) 组织类又分为2个小类: (1)公司(Company) (2 ...

  7. C++ 虚函数与纯虚函数 浅析

    [摘要] 在虚函数与纯虚函数的学习中.要求理解虚函数与纯虚函数的定义,了解虚函数与纯虚函数在实例化上的差异.掌握两者在实现上的必要性.熟悉纯虚函数在子类与孙类的函数类型.本文即针对上述问题展开阐述. ...

  8. 操作系统学习笔记:I/O输入系统

    计算机两大主要任务:IO操作和计算处理.许多情况下,主要是IO操作,计算处理只是附带的(而操作系统的两大任务是管理物理设备和为应用程序提供一个虚拟机器的抽象).操作系统在IO方面的作用是管理IO操作和 ...

  9. easyUI的tree

    前端使用easyUI,放了一个tree,搞死了. easyUI的tree,后端传过来的数据,是json格式:然后easyUI向后端提交.请求时,会自动将节点的id附在url后面. 主要有两个注意的地方 ...

  10. Cordova打包vue项目(Android)

    准备工作: 安装好必要环境: vue-cli,webpack,node.js,android环境 (http://cordova.axuer.com/docs/zh-cn/latest/guide/p ...