简体   繁体   English

如何同步两个DataBase Schema Oracle 10G?

[英]How to synchronize two DataBase Schemas Oracle 10G?

I am using Oracle 10G. 我正在使用Oracle 10G。

Let me explain to you. 让我向你解释一下。 I have one source database named (DB1) and Target Database named (DB2). 我有一个名为(DB1)的源数据库和名为(DB2)的目标数据库。

  • I have 2 schema's named dbs1 and dbs2 in the source database (DB1). 我在源数据库(DB1)中有2个名为dbs1和dbs2的模式。

  • I have exported both the database schemas in Source Database (DB1) and imported it successfully into the Target Database (DB2). 我已在源数据库(DB1)中导出了两个数据库模式,并将其成功导入到目标数据库(DB2)中。

  • Now I face a challenge in synchronizing these database schemas every time from Source DB (DB1) to Target DB (DB2). 现在,每次从源DB(DB1)到目标数据库(DB2)同步这些数据库模式时,我都面临着挑战。

Can anyone please help in letting me know how can achieve this synchronization? 任何人都可以帮助我告诉我如何实现这种同步?

Oracle has its own built-in function to handle this situation: it's called Streams. Oracle有自己的内置函数来处理这种情况:它叫做Streams。 Find out more . 了解更多 There is also Replication, but that uses materialized views rather than tables in the target database. 还有复制,但它使用物化视图而不是目标数据库中的表。 Find out more . 了解更多

Do not look at third party products or attempt to handroll your own implementation until you have considered the functionality you already have. 在考虑您已有的功能之前,请不要查看第三方产品或尝试手动执行您自己的实施。 Oracle licenses are expensive: be sure to get your money's worth. Oracle许可证价格昂贵:确保您的资金价值。

Setting up data integration between databases is a complex subject, and not one which I would choose to hand to a beginner. 在数据库之间建立数据集成是一个复杂的主题,而不是我选择交给初学者的主题。 However, you will find it easier to get yourself started if you use Oracle's standard functionality. 但是,如果您使用Oracle的标准功能,您会发现自己更容易入手。 The same applies to asking for help, here or in other forums. 这同样适用于在这里或在其他论坛中寻求帮助。

The three key issues you have to decide on are: 您必须决定的三个关键问题是:

  1. synchronicity Do you want the Target DB to be completely up-to-date with the Source database? 同步性您希望目标数据库与源数据库完全一致吗? Or is it sufficient to apply updates asynchronously, perhaps even in batches? 或者是否可以异步应用更新,甚至是批量应用更新? At the extreme case, synchronous updates result in distributed transactions, where two-phase commit means changes to data in Source DB must also be applied to Target DB as part of the same transaction. 在极端情况下,同步更新会导致分布式事务,其中两阶段提交意味着对源数据库中的数据的更改也必须作为同一事务的一部分应用于目标数据库。

  2. structural changes It's easy enough to propagate DML changes from one schema to another, but what about DDL - new columns, new tables, etc. 结构更改将DML更改从一个模式传播到另一个模式很容易,但是DDL - 新列,新表等等。

  3. directionality Will all the changes always go from Source DB to Target DB? 方向性所有的变化是否总是从Source DB到Target DB? Are there any prospects of data changes be propagated in the other direction? 是否有任何数据变化的前景会向另一个方向传播? In a related question, can the data in Target DB be changed independently of changes in the Source DB? 在相关问题中,目标数据库中的数据是否可以独立于源数据库中的更改而更改? Or is the Target DB read only? 或者目标数据库是只读的?

EDIT 编辑

The deprecated IMP/EXP utilities and the more modern DataPump functionality are intended for one-off operations. 不推荐使用的IMP / EXP实用程序和更现代的DataPump功能适用于一次性操作。 That is, importing structure and data into an empty schema, or importing data into empty objects. 也就是说,将结构和数据导入空模式,或将数据导入空对象。 They are not suitable for use in a rolling synchronization operation, one where we have to be apply incremental changes. 它们不适合用于滚动同步操作,我们必须应用增量更改。 The appropriate tools for that task are the ones I have already listed: Streams or Replication. 适合该任务的工具是我已经列出的工具:Streams或Replication。

EDIT 2 编辑2

"Can you please give an example for the same. I would be very thanful to you." “你能不能举一个例子。我会非常感谢你。”

Examples of both Replication and Streams? 复制流的示例? That would take a chunk of time, and to be quite frank I doubt you can afford my hourly rate. 这需要花费一大部分时间,坦率地说,我怀疑你能负担我的小时费率。 What I can do is point you to some handy resources on Das Interwebs. 我能做的就是为您提供Das Interwebs上的一些方便资源。 Martin Zahn has written a Replication Survival Guide which is pretty good. Martin Zahn编写了一份非常好的复制生存指南 Tim Hall has an introduction to Streams on his Oracle-Base site; Tim Hall在他的Oracle-Base网站上介绍了Streams ; that's for 9i but it remains a decent primer. 这是9i,但它仍然是一个不错的入门。 Neither of these is a substitute for the documentation, but they will help you get a handle on the different technologies. 这些都不是文档的替代品,但它们将帮助您掌握不同的技术。

You describe yourself as "new and very naive to Oracle DB". 您将自己描述为“对Oracle DB而言非常天真”。 So you must understand that this is no trivial task. 所以你必须明白这不是一件轻而易举的事。 Unfortunately you can't just cut'n'paste some example code and expect it to work. 不幸的是,你不能只是削减一些示例代码,并希望它能够正常工作。 You have a great deal of planning, designing and configuration ahead of you. 您需要进行大量的规划,设计和配置。 Start by answering the questions I listed above. 首先回答我上面列出的问题。 You need to know exactly where you are trying to reach before you make any decisions on how to get there. 在做出如何到达目的地之前,您需要确切地知道自己要到达的目的地。

您可以使用LiquiBase等“数据库更改管理”工具

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM