在一个位置管理两个关系数据库中的数据

Managing data in two relational databases in a single location

背景: 我们目前将数据拆分到两个关系数据库(Oracle 和 Postgres)中。需要 运行 涉及两个数据库中的表的临时查询。目前我们正在通过以下两种方式之一进行此操作:

  1. 从一个数据库到另一个数据库的 ETL。这需要大量的开发人员 时间。
  2. Oracle foreign data wrapper 在我们的 Postgres 服务器。这是可行的,但是查询 运行 极其 慢慢来。

我们已经使用了Google云平台(针对使用Postgres服务器的项目)。我们熟悉 Google BigQuery (BQ)。

我们想做的事情: 我们希望这两个数据库中的大部分表(按原样)在一个位置可用,因此查询它们既简单又快速。我们正在考虑将数据从两个数据库服务器复制到 BQ,而不进行任何转换。

看来我们需要定期(每天)对表进行完整转储并更新 BQ,因为 BQ 是 append-only. The recent availability of DML 在 BQ 中似乎非常有限。

我们知道按原样加载到BQ不是最优方案,我们需要反规范化以提高效率,但这是我们分析可行性后必须解决的问题。

我的问题是 BQ 对我们来说是否是一个好的解决方案,如果是,如何有效地使 BQ 与我们的数据库数据保持同步,或者我们是否应该看看其他东西(比如 Redshift)?

WePay 已经发布了一系列关于他们如何解决这些问题的文章。查看 https://wecode.wepay.com/posts/streaming-databases-in-realtime-with-mysql-debezium-kafka

为了保持一切同步,他们:

The flow of data starts with each microservice’s MySQL database. These databases run in Google Cloud as CloudSQL MySQL instances with GTIDs enabled. We’ve set up a downstream MySQL cluster specifically for Debezium. Each CloudSQL instance replicates its data into the Debezium cluster, which consists of two MySQL machines: a primary (active) server and secondary (passive) server. This single Debezium cluster is an operational trick to make it easier for us to operate Debezium. Rather than having Debezium connect to dozens of microservice databases directly, we can connect to just a single database. This also isolates Debezium from impacting the production OLTP workload that the master CloudSQL instances are handling.

然后:

The Debezium connectors feed the MySQL messages into Kafka (and add their schemas to the Confluent schema registry), where downstream systems can consume them. We use our Kafka connect BigQuery connector to load the MySQL data into BigQuery using BigQuery’s streaming API. This gives us a data warehouse in BigQuery that is usually less than 30 seconds behind the data that’s in production. Other microservices, stream processors, and data infrastructure consume the feeds as well.