Restoring a Database on a New Host

本文连接地址:http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmadvre.htm#i1007814

If your goal is to perform a test run of your disaster recovery procedures, or to permanently move a database to a new host, then you can use the procedure in this section. This procedure uses theRESTORE and RECOVER commands.

If you use the procedure in this section, then the DBID for the restored database equals the DBID for the original database. Do not register a test database created in this way in the same recovery catalog as the source database. Because the DBID of the two databases is the same, the metadata for the test database can interfere with RMAN's ability to restore and recover the source database.

If your goal is to create a new copy of your target database for ongoing use on a new host, then use the RMAN DUPLICATE command instead of this procedure. The DUPLICATE command assigns a new DBID to the database it creates, enabling it to be registered in the same recovery catalog as the original database.

See Also:

"Overview of RMAN Database Duplication" to learn how to duplicate a database

Preparing to Restore a Database on a New Host

To prepare for the restoration of the database to a new host, take the following steps:

  • Record the DBID for your source database. If you do not know the DBID for your database, then see "Determining the DBID of the Database" to learn how to determine the DBID.

  • Make the source database initialization parameter file accessible on the new host. Copy the file from the old host to a new host by using an operating system utility.

  • If you perform a test restore operation only, then ensure that RMAN is not connected to the recovery catalog. Otherwise, RMAN records metadata about the restored data files in the recovery catalog. This metadata interferes with future attempts to restore and recover the primary database.

    If you must use a recovery catalog because the control file is not large enough to contain the RMAN repository data on all of the backups that you must restore, then use Oracle Data Pump to export the catalog and import it into a different schema or database. Afterward, use the copied recovery catalog for the test restore. Otherwise, the recovery catalog considers the restored database as the current target database.

  • Ensure that backups used for the restore operation are accessible on the restore host. For example, if the backups were made with a media manager, then verify that the tape device is connected to the new host. If you are using disk copies, then use the procedure in the following section.

  • If you are performing a trial restore of the production database, then perform either of the following actions before restoring the database in the test environment:

    • If the test database uses a fast recovery area that is physically different from the recovery area used by the production database, then set DB_RECOVERY_FILE_DEST in the test database instance to the new location.

    • If the test database uses a fast recovery area that is physically the same as the recovery area used by the production database, then set DB_UNIQUE_NAME in the test database instance to a different name from the production database.

    If you do not perform either of the preceding actions, then RMAN assumes that you are restoring the production database and deletes flashback logs from the fast recovery area because they are considered unusable.

Restoring Disk Backups to a New Host

To move the database to a new host by using data file copies or backup sets on disk, you must transfer the files manually to the new host. This example assumes that RMAN is using a recovery catalog.

To restore backup files to a new host:

  1. Start RMAN and connect to a target database and recovery catalog.

  2. Run a LIST command to see a listing of backups of the data file and control file autobackups.

    For example, enter the following command to view data file copies:

    LIST COPY;
    

    For example, enter the following command to view control file backups:

    LIST BACKUP OF CONTROLFILE;
    

    The piece name of the autobackup must use the %F substitution variable, so the autobackup piece name includes the string c-IIIIIIIIII-YYYYMMDD-QQ, where IIIIIIIIII stands for the DBID, YYYYMMDD is a time stamp in the Gregorian calendar of the day the backup is generated, and QQ is the sequence in hexadecimal.

  3. Copy the backups to the new host with an operating system utility.

    Enter a command such as the following to copy all data file copies to the ?/oradata/trgt directory on the new host:

    % cp -r /disk1/*dbf /net/new_host/oracle/oradata/trgt
    

    Enter a command such as the following to copy the autobackup backup piece to the /tmp directory on the new host:

    % cp -r /disk1/auto_bkp_loc/c-1618370911-20070208-00 /net/new_host/tmp
    

    As explained in "Restoring the Server Parameter File from a Control File Autobackup", you must use the SET CONTROLFILE AUTOBACKUP FORMAT command when restoring an autobackup from a nondefault location.

Testing the Restore of a Database on a New Host

This scenario assumes that you want to test whether you can restore your database to a new host. In this scenario, you have two networked Linux hosts, hosta and hostb. A target database named trgta is on hosta and is registered in recovery catalog catdb. You want to test the restore and recovery of trgta on hostb, while keeping database trgta up and running onhosta.

Now, assume that the directory structure of hostb is different from hosta. The target database is located in /net/hosta/dev3/oracle/dbs, but you want to restore the database to/net/hostb/oracle/oradata/test. You have tape backups of data files, control files, archived redo logs, and the server parameter file on a media manager accessible by both hosts. TheORACLE_SID for the trgta database is trgta and does not change for the restored database.

Caution:

If you are restoring the database for test purposes, then never connect RMAN to the test database and the recovery catalog.

To restore the database on a new host:

  1. Ensure that the backups of the target database are accessible on the new host.

    To test disaster recovery, you must have a recoverable backup of the target database. When preparing your disaster recovery strategy, ensure that the backups of the data files, control files, and server parameter file are restorable on hostb. Thus, you must configure the media management software so that hostb is a media manager client and can read the backup sets created on hosta. Consult the media management vendor for support on this issue.

  2. Configure the ORACLE_SID on hostb.

    This scenario assumes that you want to start the RMAN client on hostb and authenticate yourself through the operating system. However, you must be connected to hostb either locally or through a net service name.

    After logging in to hostb with administrator privileges, edit the /etc/group file so that you are included in the DBA group:

    dba:*:614:

    Set the ORACLE_SID environment variable on hostb to the same value used on hosta:

    % setenv ORACLE_SID trgta
    
  3. Start RMAN on hostb and connect to the target database without connecting to the recovery catalog.

    For example, enter the following command:

    % rman NOCATALOG
    RMAN> CONNECT TARGET /
    
  4. Set the DBID and start the database instance without mounting the database.

    For example, run SET DBID to set the DBID, then run STARTUP NOMOUNT:

    SET DBID 1340752057;
    STARTUP NOMOUNT
    

    RMAN fails to find the server parameter file, which has not yet been restored, but starts the instance with a "dummy" file. Sample output follows:

    startup failed: ORA-01078: failure in processing system parameters
    LRM-00109: could not open parameter file '/net/hostb/oracle/dbs/inittrgta.ora'trying to start the Oracle instance without parameter files ...
    Oracle instance started
    
  5. Restore and edit the server parameter file.

    Because you enabled the control file autobackup feature when making your backups, the server parameter file is included in the backup. If you are restoring an autobackup that has a nondefault format, then use the SET CONTROLFILE AUTOBACKUP FORMAT command to indicate the format.

    Allocate a channel to the media manager, then restore the server parameter file as a client-side parameter file and use the SET command to indicate the location of the autobackup (in this example, the autobackup is in /tmp):

    RUN
    {ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...';SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/tmp/%F';RESTORE SPFILE TO PFILE '?/oradata/test/inittrgta.ora' FROM AUTOBACKUP;SHUTDOWN ABORT;
    }
    
  6. Edit the restored initialization parameter file.

    Change any location-specific parameters, for example, those ending in _DEST, to reflect the new directory structure. For example, edit the following parameters:

      - IFILE- LOG_ARCHIVE_DEST_1- CONTROL_FILES
    
  7. Restart the instance with the edited initialization parameter file.

    For example, enter the following command:

    STARTUP FORCE NOMOUNT PFILE='?/oradata/test/inittrgta.ora';
    
  8. Restore the control file from an autobackup and then mount the database.

    For example, enter the following command:

    RUN
    {ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...';RESTORE CONTROLFILE FROM AUTOBACKUP;ALTER DATABASE MOUNT;
    }
    

    RMAN restores the control file to whatever locations you specified in the CONTROL_FILES initialization parameter.

  9. Catalog the data file copies that you copied in "Restoring Disk Backups to a New Host", using their new file names or CATALOG START WITH (if you know all the files are in directories with a common prefix easily addressed with a CATALOG START WITH command). For example, run:

    CATALOG START WITH '/oracle/oradata/trgt/';
    

    If you want to specify files individually, then you can execute a CATALOG command as follows:

    CATALOG DATAFILECOPY'/oracle/oradata/trgt/system01.dbf', '/oracle/oradata/trgt/undotbs01.dbf', '/oracle/oradata/trgt/cwmlite01.dbf', '/oracle/oradata/trgt/drsys01.dbf','/oracle/oradata/trgt/example01.dbf', '/oracle/oradata/trgt/indx01.dbf', '/oracle/oradata/trgt/tools01.dbf', '/oracle/oradata/trgt/users01.dbf';
    
  10. Start a SQL*Plus session on the new database and query the database file names recorded in the control file.

    Because the control file is from the trgta database, the recorded file names use the original hosta file names. You can query V$ views to obtain this information. Run the following query in SQL*Plus:

    COLUMN NAME FORMAT a60
    SPOOL  LOG '/tmp/db_filenames.out'
    SELECT FILE# AS "File/Grp#", NAME
    FROM   V$DATAFILE
    UNION
    SELECT GROUP#,MEMBER
    FROM   V$LOGFILE;
    SPOOL OFF
    EXIT
    
  11. Write the RMAN restore and recovery script. The script must include the following steps:

    1. For each data file on the destination host that is restored to a different path than it had on the source host, use a SET NEWNAME command to specify the new path on the destination host. If the file systems on the destination system are set up to have the same paths as the source host, then do not use SET NEWNAME for those files restored to the same path as on the source host.

    2. For each online redo log that is to be created at a different location than it had on the source host, use SQL ALTER DATABASE RENAME FILE commands to specify the path name on the destination host. If the file systems on the destination system are set up to have the same paths as the source host, then do not use ALTER DATABASE RENAME FILE for those files restored to the same path as on the source host.

    3. Perform a SET UNTIL operation to limit recovery to the end of the archived redo logs. The recovery stops with an error if no SET UNTIL command is specified.

    4. Restore and recover the database.

    5. Run the SWITCH DATAFILE ALL command so that the control file recognizes the new path names as the official new names of the data files.

    Example 20-3 shows the RMAN script reco_test.rman that can perform the restore and recovery operation.

    Example 20-3 Restoring a Database on a New Host

    RUN
    {# allocate a channel to the tape deviceALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...';# rename the data files and online redo logsSET NEWNAME FOR DATAFILE 1 TO '?/oradata/test/system01.dbf';SET NEWNAME FOR DATAFILE 2 TO '?/oradata/test/undotbs01.dbf';SET NEWNAME FOR DATAFILE 3 TO '?/oradata/test/cwmlite01.dbf';SET NEWNAME FOR DATAFILE 4 TO '?/oradata/test/drsys01.dbf';SET NEWNAME FOR DATAFILE 5 TO '?/oradata/test/example01.dbf';SET NEWNAME FOR DATAFILE 6 TO '?/oradata/test/indx01.dbf';SET NEWNAME FOR DATAFILE 7 TO '?/oradata/test/tools01.dbf';SET NEWNAME FOR DATAFILE 8 TO '?/oradata/test/users01.dbf';SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo01.log''TO ''?/oradata/test/redo01.log'' ";SQL "ALTER DATABASE RENAME FILE ''/dev3/oracle/dbs/redo02.log''TO ''?/oradata/test/redo02.log'' ";# Do a SET UNTIL to prevent recovery of the online logsSET UNTIL SCN 123456;# restore the database and switch the data file namesRESTORE DATABASE;SWITCH DATAFILE ALL;# recover the databaseRECOVER DATABASE;
    }
    EXIT
    

  12. Execute the script created in the previous step.

    For example, start RMAN to connect to the target database and run the @ command:

    % rman TARGET / NOCATALOG
    RMAN> @reco_test.rman
    
  13. Open the restored database with the RESETLOGS option.

    From the RMAN prompt, open the database with the RESETLOGS option:

    ALTER DATABASE OPEN RESETLOGS;
    

    Caution:

    When you re-open your database in the next step, do not connect to the recovery catalog. Otherwise, the new database incarnation created is registered automatically in the recovery catalog, and the file names of the production database are replaced by the new file names specified in the script.

  14. Optionally, delete the test database with all of its files.

    Note:

    If you used an ASM disk group, then the DROP DATABASE command is the only way to safely remove the files of the test database. If you restored to non-ASM storage then you can also use operating system commands to remove the database.

    Use the DROP DATABASE command to delete all files associated with the database automatically. The following example deletes the database files:

    STARTUP FORCE NOMOUNT PFILE='?/oradata/test/inittrgta.ora';
    DROP DATABASE;
    

    Because you did not perform the restore and recovery operation when connected to the recovery catalog, the recovery catalog contains no records for any of the restored files or the procedures performed during the test. Likewise, the control file of the trgta database is completely unaffected by the test.

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

【oracle官网】 Restoring a Database on a New Host相关推荐

  1. 2018年Oracle官网下载Oracle 11g安装包

    1. 在搜索栏上输入 www.oracle.com/ ,进入Oracle官网. 2. 在Oracle官网上,点击"Trials  and Downloads" 3. 进入新的页面后 ...

  2. linux上传oracle压缩包,Linux中从oracle官网下载jdk文件不是标准的gzip格式文件问题...

    http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-lin ...

  3. 如何在oracle官网下载ojdbc8,想不想在maven里直接下载ojdbc这个jar?

    不知道你们开发项目的时候,这个jar一般都是从什么途径获得的. 从旧项目?从oracle安装文件里找?下载别人上传到csdn的?在oracle官网下载? 就不想堂堂正正从官网直接maven回来吗? 强 ...

  4. Oracle官网登录账号

    可以在Oracle官网下载资料时使用 用户名:541509124@qq.com 密码:LR4ever.1314 查看全文 http://www.taodudu.cc/news/show-4295737 ...

  5. 如何通过Oracle官网下载jdk历史版本

    1.登录Oracle官网,网址为:https://www.oracle.com/index.html 2.点击屏幕下方的Trials and Downloads 如下图 2.向下滑动屏幕 选择Java ...

  6. JDK Oracle 官网下载地址

    JDK Oracle 官网下载地址 1.JDK6 http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downlo ...

  7. oracle官网下载教程

    1.百度搜索oracle   也可以直接点击进入   oracle官网   或直接进入   下载页面 2.选择中文,看的更容易些 3.拉到最下面,选择所有下载和试用 4.选择数据库下载 5.点击下载对 ...

  8. Oracle 官网登录账号

    Oracle 官网下载 JDK需要账号登录方可下载,如果不想麻烦注册一个账号,可以免费借用别人的账户 老外记录的一些 oracle 账号,亲测可用,提供给大家避免注册账号的麻烦. http://bug ...

  9. oracle官网免登录下载jdk8

    oracle官网免登录下载jdk8 没见过有人写这个文章,我就把我所发现的分享给大家,避免想下载jdk还要登录("'▽'") 终于让我找到了这个免登录下载官网jdk的方法,本文以下 ...

最新文章

  1. WebBrowserProgramming - Python Wiki
  2. 面试官问:为什么MySQL的索引不采用Kafka的索引机制
  3. java代码_阿里资深工程师教你如何优化 Java 代码!
  4. 使用keras构建LSTM分类器
  5. Ubuntu下使用GDB断点Go程序
  6. centos下性能分析工具perf的安装和简单使用
  7. 帮助你更好理解javascript中easing功能的网站 - Easings.net
  8. LeetCode 104二叉树的最大深度-简单
  9. jmeter跨线程组传多个值_jmeter多用户登录跨线程组操作传值
  10. matlab第六章课后答案,matlab作业第6章
  11. 【开发工具】【i2c-tools】I2C总线调试工具(i2c-tools)的安装与使用
  12. Jvisualvm简单使用教程
  13. 电量统计(1)-原理
  14. MAC小技巧|Mac屏幕截图去除窗口阴影
  15. 使用Tibco项目docker部署报错异常
  16. Centos6.8系统镜像下载
  17. 小米应用市场隐私政策
  18. Pandas-时间(二)-数据类型:DatetimeIndex(其中每个元素的类型为:Timestamp)【创建方式:①pd.DatetimeIndex([]);②pd.to_datetime()】
  19. java递归1加到10,递归1-初识递归
  20. [心电图] 贺银成视频笔记

热门文章

  1. 区块链概念股是骗局吗
  2. 怎么用爱问转换工具在线拆分PDF文件
  3. 自考专升本拿证需要多久 几年能毕业
  4. 上万代码——室内自主巡检无人机项目攻城战(一)
  5. php趣味成语答题,题库生成.
  6. 程序填空题——压缩BCD码调整指令
  7. HttpServlet 会话管理(一)(URL重写 表单隐藏域 简单示例)
  8. grafana 画拓扑图 能不能_干货|告诉你标准漂亮的网络拓扑图是怎么画出来的?...
  9. 南京java换工作几月份最好,想换工作是年前好,还是年后比较好?资深HR告诉你答案...
  10. Cadence Allegro页面连接符后面跟着页码