使用 sqlplus 或 rman 备份/恢复 Oracle 10g 测试数据库

发布于 2024-07-05 19:00:07 字数 301 浏览 9 评论 0原文

将 Oracle 10g 与我们的测试服务器结合使用,将数据库备份和恢复到静态点是最有效/最简单的方法,假设您总是希望在创建备份后返回到给定点。

示例用例如下:

  1. 安装并配置所有软件
  2. 将数据修改到基本测试点
  3. 以某种方式进行备份(这是问题的一部分,如何执行此操作)
  4. 进行测试
  5. 返回到步骤 3 状态(恢复回备份点,这是问题的另一半)

最好通过 sqlplus 或 rman 或其他一些可编写脚本的方法来完成。

Using Oracle 10g with our testing server what is the most efficient/easy way to backup and restore a database to a static point, assuming that you always want to go back to the given point once a backup has been created.

A sample use case would be the following

  1. install and configure all software
  2. Modify data to the base testing point
  3. take a backup somehow (this is part of the question, how to do this)
  4. do testing
  5. return to step 3 state (restore back to backup point, this is the other half of the question)

Optimally this would be completed through sqlplus or rman or some other scriptable method.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

冷夜 2024-07-12 19:00:07

您无需在基准时间进行备份。 只需启用闪回数据库,创建有保证的还原点,运行测试并闪回到之前创建的还原点。

其步骤如下:

  1. 在装载模式下启动实例。

    启动强制挂载;

  2. 创建还原点。

    before_test创建恢复点保证闪回数据库;

  3. 打开数据库。

    改变数据库打开;

  4. 运行您的测试。

  5. 关闭并挂载实例。

    立即关闭;
    启动挂载;

  6. 闪回至还原点。

    闪回数据库恢复到before_test点;

  7. 打开数据库。

    改变数据库打开;

You do not need to take a backup at your base time. Just enable flashback database, create a guaranteed restore point, run your tests and flashback to the previously created restore point.

The steps for this would be:

  1. Startup the instance in mount mode.

    startup force mount;

  2. Create the restore point.

    create restore point before_test guarantee flashback database;

  3. Open the database.

    alter database open;

  4. Run your tests.
  5. Shutdown and mount the instance.

    shutdown immediate;
    startup mount;

  6. Flashback to the restore point.

    flashback database to restore point before_test;

  7. Open the database.

    alter database open;

寒江雪… 2024-07-12 19:00:07

您可以使用 Oracle 中名为 闪回 的功能,该功能允许您创建一个还原点,完成测试后您可以轻松跳回该还原点。

引自该网站,

闪回数据库就像“倒带”
按钮'为您的数据库。 它提供
数据库时间点恢复
无需备份
首先要恢复的数据库。 什么时候
你消除了所需的时间
从磁带恢复数据库备份,
数据库恢复时间点是
快。

You could use a feature in Oracle called Flashback which allows you to create a restore point, which you can easily jump back to after you've done testing.

Quoted from the site,

Flashback Database is like a 'rewind
button' for your database. It provides
database point in time recovery
without requiring a backup of the
database to first be restored. When
you eliminate the time it takes to
restore a database backup from tape,
database point in time recovery is
fast.

微暖i 2024-07-12 19:00:07

根据我的经验,导入/导出可能是可行的方法。 导出会创建数据库的逻辑快照,因此您不会发现它对于大型数据库或严格的性能要求有用。 然而,它非常适合制作快照以及在多台机器上使用的东西。

我在 Rails 项目中使用它来获取产品快照,我们可以在开发人员之间交换该快照以进行集成测试,并且我们在 rake 脚本中完成了这项工作。 我们编写了一个小的 sqlplus 脚本来销毁数据库,然后在顶部导入转储文件。

您可能想查看的一些文章:
OraFAQ 备忘单
Oracle Wiki

Oracle 显然不喜欢 imp/当我们使用数据泵时,exp 更倾向于数据泵我们需要一些我们无法拥有的东西(即我们在共享环境中无法获得的 SYSDBA 权限)。 因此,请看一下,但如果数据泵不是您的包,请不要灰心,旧的 imp/exp 仍然存在:)

我不能推荐 RMAN 来做这种事情,因为 RMAN 需要大量设置并且需要配置在数据库中(它还有自己的用于备份的目录数据库,这对于裸机恢复来说是众所周知的痛苦)。

From my experience import/export is probably the way to go. Export creates a logical snapshot of your DB so you won't find it useful for big DBs or exacting performance requirements. However it works great for making snapshots and whatnot to use on a number of machines.

I used it on a rails project to get a prod snapshot that we could swap between developers for integration testing and we did the job within rake scripts. We wrote a small sqlplus script that destroyed the DB then imported the dump file over the top.

Some articles you may want to check:
OraFAQ Cheatsheet
Oracle Wiki

Oracle apparently don't like imp/exp any more in favour of data pump, when we used data pump we needed things we couldn't have (i.e. SYSDBA privileges we couldn't get in a shared environment). So take a look but don't be disheartened if data pump is not your bag, the old imp/exp are still there :)

I can't recommend RMAN for this kind of thing becuase RMAN takes a lot of setup and will need config in the DB (it also has its own catalog DB for backups which is a pain in the proverbial for a bare metal restore).

旧人哭 2024-07-12 19:00:07

如果您使用的文件系统支持写时复制快照,则可以将数据库设置为您想要的状态。 然后关闭一切并拍摄文件系统快照。 然后进行测试,当您准备好重新开始时,可​​以回滚快照。 假设您有一个支持快照的文件系统,这可能比其他选项更简单。

If you are using a filesystem that supports copy-on-write snapshots, you could set up the database to the state that you want. Then shut down everything and take a filesystem snapshot. Then go about your testing and when you're ready to start over you could roll back the snapshot. This might be simpler than other options, assuming you have a filesystem which supports snapshots.

沙与沫 2024-07-12 19:00:07

@Michael Ridley 解决方案是完全可编写脚本的,并且可以与任何版本的 Oracle 一起使用。

这正是我所做的,我有一个每周运行的脚本来

  1. 回滚文件系统
  2. 应用生产存档日志
  3. 获取新的“预数据屏蔽”FS 快照
  4. 重置日志
  5. 应用“预生产”数据屏蔽。
  6. 拍摄新的“数据屏蔽后”快照(允许回滚以发布屏蔽数据)
  7. 打开数据库

这使我们能够将开发数据库保持在靠近生产数据库的位置。

为此,我使用 ZFS。

此方法也可用于您的应用程序,甚至整个“环境”(例如,您可以使用单个(脚本化)命令“回滚”整个环境。

如果您运行的是 10g,那么您可能要做的第一件事是想要研究的是Flashback,因为它内置于数据库中。

@Michael Ridley solution is perfectly scriptable, and will work with any version of oracle.

This is exactly what I do, I have a script which runs weekly to

  1. Rollback the file system
  2. Apply production archive logs
  3. Take new "Pre-Data-Masking" FS snapshot
  4. Reset logs
  5. Apply "preproduction" data masking.
  6. Take new "Post-Data-Masking" snapshot (allows rollback to post masked data)
  7. Open database

This allows us to keep our development databases close to our production database.

To do this I use ZFS.

This method can also be used for your applications, or even you entire "environment" (eg, you could "rollback" your entire environment with a single (scripted) command.

If you are running 10g though, the first thing you'd probably want to look into is Flashback, as its built into the database.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文