【oracle官网】 Restoring a Database on a New Host

本文详细介绍了如何在新主机上恢复Oracle数据库,包括准备步骤、磁盘备份恢复、测试恢复流程及注意事项,适用于灾难恢复演练或永久迁移场景。

Restoring a Database on a New Host

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 device
      ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS '...';
    
      # rename the data files and online redo logs
      SET 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 logs
      SET UNTIL SCN 123456;
      # restore the database and switch the data file names
      RESTORE DATABASE;
      SWITCH DATAFILE ALL;
    
      # recover the database
      RECOVER 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/,如需转载,请注明出处,否则将追究法律责任。

【源码免费下载链接】:https://renmaiwang.cn/s/dr27a 编程环境设置如下: 1. 操作系统:Windows XP SP2 开发语言:C++ / MFC 编译环境:MS Visual C++6.0 参数配置分为三部分: - 第一参数为接收窗口大小控制,由于帧序列号采用四位编码方式,因此其设定范围限定在1至8之间。其中设置为1时将采用后退N帧的滑动窗口协议机制;当大于1时则采用选择性重传策略的滑动窗口协议。 - 第二参数为接收速率调节器,用户可在编辑框中输入定时器间隔时间值(单位:ms),例如数值表示每秒处理一个数据包的能力。特别地,设定值为1000时即意味着接收速率为每秒处理1个包。 - 第三参数为辅助定时器设置项,该参数决定了在接收到数据包后无反向流量应答的情况下,发送方需等待应答包的时间延迟(单位:ms)。 异常处理界面提供以下功能: - 用户可在此区手动输入丢失的响应帧,并以帧序列号形式填写具体内容。各参数之间使用空格分隔以便于识别和编辑。 - 当前状态显示接收窗口运行状况,包括当前接收到的数据包范围、令牌计数等关键指标信息。 - 输出界面用于实时展示接收方系统的运行情况及协议交互过程。 用户需在所有相关参数配置完毕后,点击"开始接收"按钮以进入数据接收模式。发送程序界面如图2所示,其功能分区与上文描述一致。
内容概要:本文介绍了基于dq0变换的三相串联有源电力滤波器(SAPF)的Simulink仿真模型,重点利用dq0坐标变换实现对谐波和无功电流的精确检测与补偿,提升电力系统的电能质量。文档还涵盖了中间直流环节的三相电力电子变压器(PET)建模、固定电容器与可控基于dq0变换的三相串联有源电力滤波器的Simulink模型SAPF晶闸管无功补偿装置(FCTCR)等配套设备的仿真设计,形成完整的电力系统仿真体系。此外,文中整合了多种先进仿真案例,包括基于现代智能算法的优化控制、故障诊断、路径规划及信号处理等内容,展示了MATLAB/Simulink在电力电子与电力系统领域的广泛应用能力。; 适合人群:电气工程、自动化及相关专业的研究生、科研人员及从事电力系统仿真与控制的工程技术人员;具备一定MATLAB/Simulink使用基础和电力电子背景知识的开发者;; 使用场景及目标:① 掌握dq0变换在有源滤波器中的应用原理与建模方法;② 学习SAPF系统的设计思路与仿真调试技巧;③ 借鉴文中提供的多种电力系统仿真模型与优化算法实现方案,用于科研项目或实际工程开发;④ 结合智能优化算法与深度学习技术开展电能质量治理与故障诊断研究; 阅读建议:建议读者按照文档结构循序渐进地学习,重点关注dq0变换的数学原理及其在Simulink中的模块化实现,动手搭建模型并进行参数调试。同时可参考文中提供的网盘资源获取完整代码与模型文件,结合实际需求进行二次开发与创新研究。
<think>我们正在处理用户报告的Lsight错误:'value not retrieved from database: 子程序 runs do not support restoring from database'。需要分析错误原因并提供解决方案。 首先,从错误信息中我们可以分解出两个关键部分: 1. "value not retrieved from database":表示从数据库获取值失败。 2. "子程序 runs do not support restoring from database":明确说明子程序运行(runs)不支持从数据库恢复。 结合引用内容,我们注意到引用[2]提到事务的原子性(要么全部提交,要么全部回滚),引用[4]提到使用闪回事务查询来审计事务。但错误信息中提到的“restoring from database”可能暗示了某种恢复操作。 错误信息中的“runs”可能指的是Lsight中的某个特定功能(如运行子程序),而该功能不支持从数据库恢复状态。这可能是由于设计限制或配置错误。 可能的原因: 1. **功能限制**:Lsight的子程序运行(runs)在设计上不支持从数据库恢复。这可能是为了避免状态不一致或性能问题。 2. **事务处理问题**:在尝试恢复时,可能涉及未完成的事务(如引用[2]和[3]提到的),导致恢复操作被拒绝。 3. **配置错误**:可能错误地配置了Lsight,使其试图从不支持的数据库服务中恢复(引用[1]提到了一些服务,如SYS$BACKGROUND和SYS$USERS,以及XDB服务)。 4. **缓存组操作冲突**:引用[3]提到,在XA事务活动时不能执行缓存组操作。如果Lsight在尝试恢复时涉及缓存组操作,而同时有XA事务在运行,则可能被阻止。 解决方案: 1. **检查文档**:查阅Lsight文档,确认子程序运行(runs)是否支持从数据库恢复。如果不支持,则避免进行此类操作。 2. **避免恢复操作**:如果设计上不支持,那么应该确保工作流中不包含对子程序运行的恢复操作。 3. **检查事务状态**:确保在尝试恢复之前,所有相关事务都已正确提交或回滚(引用[2])。 4. **检查数据库服务配置**:确保使用的数据库服务是允许操作的(引用[1]),避免使用系统保留的服务(如XDB服务)。 5. **分离冲突操作**:如果涉及XA事务和缓存组操作,确保它们不在同一时间运行(引用[3])。 由于错误信息明确指出“runs do not support restoring from database”,最直接的解决方案是避免对子程序运行进行恢复操作。如果用户需要保存运行状态,可能需要使用其他机制,例如将状态保存在应用程序变量或文件中,而不是依赖数据库恢复。 此外,考虑检查Lsight的日志以获取更详细的错误信息,这有助于进一步定位问题。 最后,如果问题持续存在,建议联系Lsight的技术支持,提供详细的错误信息和操作步骤。 相关问题: 1. Lsight中子程序运行(runs)的功能限制有哪些? 2. 如何正确配置Lsight以避免数据库恢复操作失败? 3. 在Lsight中,如何保存和恢复子程序运行的状态?</think>### Lsight错误分析:`value not retrieved from database: 子程序 runs do not support restoring from database` 该错误表明Lsight在尝试从数据库恢复子程序运行状态时遇到限制。结合Oracle数据库特性和错误信息,可能原因及解决方案如下: #### 根本原因分析 1. **功能限制** Lsight的"runs"(运行实例)在设计上**不支持从数据库恢复状态**(明确提示"do not support restoring from database")。这可能是由于: - 运行实例包含临时内存状态(如未提交的事务数据) - 恢复操作可能破坏事务原子性(引用[2]:事务变更需完全提交或回滚) 2. **事务冲突** 当存在活动中的XA事务时(引用[3]),数据库会阻止某些操作。若运行实例涉及: - 未完成的XA事务(如分布式事务) - 缓存组操作(cache groups) 则恢复操作会被拒绝。 3. **服务配置问题** 使用了不兼容的数据库服务(引用[1]): - 系统服务(如`SYS$BACKGROUND`/`SYS$USERS`)仅限内部使用 - XML DB服务(`*XDB`)不可管理 - 未正确配置用户自定义服务 #### 解决方案 1. **避免恢复操作** ```python # 修改工作流:直接启动新运行实例而非恢复 new_run = lsight.start_run(workflow_id="wf_123") # 代替restore_run() ``` 2. **检查并提交事务** - 查询活动事务(引用[4]): ```sql SELECT xid, status FROM v$transaction; ``` - 提交或回滚未完成事务: ```sql COMMIT; -- 或 ROLLBACK; ``` 3. **验证数据库服务** - 确认使用自定义服务(非系统服务): ```sql SELECT name FROM v$services WHERE name NOT LIKE 'SYS%'; ``` - 在Lsight连接配置中指定有效服务名 4. **分离冲突操作** 若涉及XA事务和缓存组(引用[3]): - 先完成所有XA事务再尝试恢复 - 或暂停缓存组操作 #### 预防措施 - 重要状态保存到应用层变量而非依赖数据库恢复 - 定期清理孤立事务:`ALTER SYSTEM KILL SESSION 'sid,serial#';` - 使用Oracle Flashback查询历史数据(引用[4])替代状态恢复 > **关键提示**:此错误通常由工作流设计引起,而非数据库故障。检查Lsight文档确认`runs`子程序是否支持持久化操作。 [^1]: Oracle系统服务限制 [^2]: 事务原子性要求 [^3]: XA事务与缓存组冲突 [^4]: 闪回事务查询
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AiDBA宝典

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值