当前位置: 首页 > java >正文

openGauss新特性 | DataKit支持PostgreSQL到openGauss的迁移能力

Postgresql-\>openGauss迁移工具debezium-connector-postgres

可获得性

本特性自openGauss 7.0.0-RC1版本开始引入。

特性简介

debezium-connector-postgres工具是一个基于Java语言的Postgresql到openGauss的复制工具。该工具提供了初始全量数据及对象(视图、触发器、函数、存储过程)和增量数据(DML)的复制能力,可实现数据及对象从Postgresql迁移至openGauss。对于数据的全量迁移,支持Postgresql中各种数据类型的迁移,同时对于Postgresql中的浮点数据类型,包括decimal、numeric、double precision、real数据类型,可保证迁移后数据精度不丢失。对于数据的增量迁移,可以将Postgresql数据迁移期间(包括全量和增量迁移)产生的数据迁移至openGauss端。

客户价值

通过使用debezium-connector-postgres工具,可完成数据从Postgresql搬迁至openGauss数据库。基于sysbench测试模型,2路鲲鹏920 CPU、openEuler操作系统下,Postgresql数据库20张表(无索引)单表数据量在500万以上时,gs_mysync使用20并发迁移数据至openGauss,整体全量迁移性能可达300M/s以上。增量迁移按表回放,针对混合IUD场景,50张表50个线程(insert-30线程,update-10线程,delete-10线程),性能可达3w tps。

特性描述

debezium-connector-postgres工具提供数据全量和增量复制功能,使得数据可以从Postgresql迁移至openGauss数据库。debezium-connector-postgres工具中存储了Postgresql数据类型与openGauss数据类型之间的映射关系,可支持Postgresql中各种数据类型的迁移。

debezium-connector-postgres工具支持在指定版本和架构的系统(包括CentOS7、openEuler20.03、openEuler22.03系统版本,x86_64和aarch64架构)上进行离线安装,无需连接外部网络。

debezium-connector-postgres工具采用debezium connector结构,全量迁移时,source端使用pgjdbc驱动查询postgresql数据库并导出数据至csv文件中,sink端使用ogjdbc驱动将csv文件导入至openGauss数据库。增量迁移时,source端将数据推送至指定topic下,同时sink端配置topics为合并后的topic,用于从kafka抽取数据,从而可保证事务的顺序。数据复制过程中,debezium-connector-postgres工具会针对不同的类型进行相应的转换。

特性约束

- 支持postgresql 9.4以上版本。

- PostgreSQL版本低于10.x,仅支持使用wal2json插件创建逻辑复制槽;

- PostgreSQL版本大于10.x,支持使用wal2json和pgoutput插件创建逻辑复制槽(推荐使用pgoutput插件)。

依赖关系

debezium-connector-postgres工具依赖kafka、zookeeper和schema-registry三方组件。

使用说明

下载依赖

- [kafka](https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/)

  (以kafka_2.13-3.6.1为例)

 wget -c https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/3.6.1/kafka_2.13-3.6.1.tgz  tar -zxf kafka_2.13-3.6.1.tgz 

​​​​​- [confluent community](https://packages.confluent.io/archive/5.5/confluent-community-5.5.1-2.12.zip)

 wget -c  https://packages.confluent.io/archive/5.5/confluent-community-5.5.1-2.12.zipunzip confluent-community-5.5.1-2.12.zip

- [debezium-connector-postgres](https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/tools/replicate-postgresql2openGauss-7.0.0rc1.tar.gz)

 wget -c https://opengauss.obs.cn-south-1.myhuaweicloud.com/latest/tools/replicate-postgresql2openGauss-7.0.0rc1.tar.gztar -zxvf replicate-postgresql2openGauss-7.0.0rc1.tar.gz

修改配置文件

默认配置文件的地址均为localhost,若需修改为具体ip,请同步修改下列所有文件中参数涉及localhost的均改为实际ip。

- zookeeper

  配置文件位置:/kafka_2.13-3.6.1/config/zookeeper.properties

  zookeeper的默认端口号为2181,对应参数clientPort=2181。

  若端口冲突,需要修改端口号,则同步修改以下文件对应参数:

  kafka_2.13-3.6.1/config/zookeeper.properties------clientPort=2181kafka_2.13-3.6.1/config/server.properties------zookeeper.connect=localhost:2181confluent-5.5.1/etc/schema-registry/schema-registry.properties------kafkastore.connection.url=localhost:2181

- kafka

  配置文件位置:/kafka_2.13-3.6.1/config/server.properties

  注意topic的分区数必须为1,因此需设置参数num.partitions=1,该参数默认值即为1,因此无需单独修改该参数。

  kafka的默认端口是9092,对应参数listeners=PLAINTEXT://:9092。

  若端口冲突,需要修改端口号,则同步修改以下文件对应参数:

  kafka_2.13-3.6.1/config/server.properties------listeners=PLAINTEXT://:9092confluent-5.5.1/etc/schema-registry/schema-registry.properties------kafkastore.bootstrap.servers=PLAINTEXT://localhost:9092confluent-5.5.1/etc/schema-registry/connect-avro-standalone.properties------bootstrap.servers=localhost:9092confluent-5.5.1/etc/kafka/postgres-source.properties------database.history.kafka.bootstrap.servers=127.0.0.1:9092

- schema-registry​​​​​​​

  配置文件位置:/confluent-5.5.1/etc/schema-registry/schema-registry.properties

  schema-registry的默认端口是8081,对应参数listeners=http://0.0.0.0:8081。

  若端口冲突,需要修改端口号,则同步修改以下文件对应参数:​​​​​​​

  confluent-5.5.1/etc/schema-registry/schema-registry.properties------listeners=http://0.0.0.0:8081confluent-5.5.1/etc/schema-registry/connect-avro-standalone.properties------key.converter.schema.registry.url=http://localhost:8081confluent-5.5.1/etc/schema-registry/connect-avro-standalone.properties------value.converter.schema.registry.url=http://localhost:8081若需查看kafka topic内容,需修改confluent-5.5.1/bin/kafka-avro-console-consumer------DEFAULT_SCHEMA_REGISTRY_URL="--property schema.registry.url=http://192.168.0.219:8081"

- connect-standalone

配置文件位置:/confluent-5.5.1/etc/schema-registry/connect-avro-standalone.properties

注意在plugin.path配置项中增加debezium-connector-postgres所在的路径

若debezium-connector-postgres所在路径为:/data/debezium_kafka/plugin/debezium-connector-postgres

则配置其上一层目录,即plugin.path=share/java,/data/debezium_kafka/plugin

connect-standalone的默认端口是8083,对应参数rest.port=8083。

若端口冲突,需要修改端口号,则同步修改以下文件对应参数:

confluent-5.5.1/etc/schema-registry/connect-avro-standalone.properties------rest.port=8083

- postgres-source.properties

配置文件位置:/confluent-5.5.1/etc/kafka/postgres-source.properties

示例详见[postgres-source.properties](https://gitee.com/opengauss/debezium/blob/master/debezium-connector-postgres/patch/postgres-source.properties)

- postgres-sink.properties

配置文件位置:/confluent-5.5.1/etc/kafka/postgres-sink.properties

示例详见[postgres-sink.properties](https://gitee.com/opengauss/debezium/blob/master/debezium-connector-postgres/patch/postgres-sink.properties)

启动命令

(1)启动zookeeper​​​​​​​

cd kafka_2.13-3.6.1./bin/zookeeper-server-start.sh ./config/zookeeper.properties

(2)启动kafka​​​​​​​

cd kafka_2.13-3.6.1./bin/kafka-server-start.sh ./config/server.properties

(3)注册schema​​​​​​​

cd confluent-5.5.1./bin/schema-registry-start etc/schema-registry/schema-registry.properties

(4)启动kafka-connect source端​​​​​​​

cd confluent-5.5.1./bin/connect-standalone etc/schema-registry/connect-avro-standalone.properties etc/kafka/postgres-source.properties

(5)启动kafka-connect sink端​​​​​​​

cd confluent-5.5.1./bin/connect-standalone etc/schema-registry/connect-avro-standalone-1.properties etc/kafka/postgres-sink.properties

说明:source端和sink端的两个配置文件connect-avro-standalone.properties和connect-avro-standalone-1.properties的差异点在于rest.port参数的不同,默认为8083,即两个文件中设置不同的端口号,即可启动多个kafka-connect,实现sink端和source端独立工作。

步骤(4)和(5)示例source端和sink端分开启动,推荐分开启动方式。两者也可以同时启动,同时启动的命令为:​​​​​​​

cd confluent-5.5.1./bin/connect-standalone etc/schema-registry/connect-avro-standalone.properties etc/kafka/postgres-source.properties etc/kafka/postgres-sink.properties

其他命令:

(1)查看topic​​​​​​​

cd kafka_2.13-3.6.1./bin/kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --list

(2)查看topic的信息​​​​​​​

cd kafka_2.13-3.6.1./bin/kafka-topics.sh --bootstrap-server 127.0.0.1:9092 --describe --topic topic_name

(3)查看topic的内容​​​​​​​

cd confluent-5.5.1./bin/kafka-avro-console-consumer --bootstrap-server 127.0.0.1:9092 --topic topic_name --from-beginning

参考文档

debezium-connector-postgres详细说明和使用文档参考:<a href="https://gitee.com/opengauss/debezium/blob/master/README.md#debezium-postgres-connector">debezium-connector-postgres.md</a>

官网资料:https://docs.opengauss.org/zh/docs/5.0.0/docs/DataMigrationGuide/DataMigrationGuide.html

http://www.xdnf.cn/news/2717.html

相关文章:

  • Matplotlib练习代码
  • CentOS 7环境配置DHCP服务器
  • 【软件工程】面向对象编程(OOP)概念详解
  • 【神经网络与深度学习】五折交叉验证(5-Fold Cross-Validation)
  • 新一代质量管理QMS系统,产品质量全追溯
  • 除了Object.freeze(),JavaScript中还有哪些优化性能的对象限制方法?
  • 如何定义命名空间
  • STM32的Flash映射双重机制
  • x-cmd install | Orbiton:极简至上的终端文本编辑器与轻量级 IDE
  • 高性价比手机如何挑选?
  • 复合模式(Composite Pattern)
  • 佛山大旺高新区3650 M5 ERP服务器维修案例
  • 在 Conda 中,包的安装路径在电脑的哪里
  • IIS服务器提示ERR_HTTP2 PROTOCOL ERROR解决方案
  • 在 Spring Boot 中实现异常处理的全面指南
  • 【广州华锐视点】AR 远程协同:突破时空限制的利器
  • Java 的创新与变革之路:从 JDK 7 到 JDK 23
  • DELL R740服务器闪黄灯不开机故障案例
  • 基于单片机的游泳馆智能管理系统设计与实现
  • 2025年绿色材料与制造技术国际学术会议(GMMT 2025)
  • 爬虫学习笔记(一)
  • 云原生--核心组件-容器篇-6-Docker核心之-镜像仓库(公共仓库,私有仓库,第三方仓库)
  • AI智能体开发新范式:多智能体协作与自进化系统的构建之道
  • jenkins容器提示磁盘空间过低
  • 大模型的scaling laws:Scaling Laws for Neural Language Models
  • 一文了解无人机系统
  • 集成学习详解
  • 03 构造与析构
  • 【OSG学习笔记】Day 13: 事件处理——响应键盘与鼠标
  • 12前端项目----添加购物车1.0