欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 艺术 > openGauss新特性 | DataKit支持PostgreSQL到openGauss的迁移能力

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

2025/4/29 5:43:14 来源:https://blog.csdn.net/GaussDB/article/details/147562552  浏览:    关键词: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

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词