pipelineDB集成kafka

官方文档说明
pipelineDB可通过插件安装的形式集成kafka, 根据本人测试, 插件会起多个线程解析kafka数据, 一旦某条数据解析出现异常, 解析解析线程就会挂起, 直到下个周期才会被重启拉起.

个人使用感觉: 该插件容错性有待提高, 对日志的规整性要求很高, 只适用于低流量且数据格式规整的业务场景中.

插件安装

librdkafka安装

librdkafka为pipeline_kafka的依赖, 可通过apt安装或编译安装

apt安装

apt install librdkafka-dev

编译安装

git clone https://github.com/edenhill/librdkafka.git ~/librdkafka
cd librdkafka

./configure
# Or, to automatically install dependencies using the system's package manager:
# ./configure --install-deps
# Or, build dependencies from source:
# ./configure --install-deps --source-deps-only
make
sudo make install

pipeline_kafka安装

编译安装

git clone https://github.com/pipelinedb/pipeline_kafka.git ~/pipeline_kafka
cd pipeline_kafka

make
make install

修改postgres配置并重启

vim /etc/postgresql/11/main/postgresql.conf

# 修改配置
......
shared_preload_libraries = 'pipelinedb,pipeline_kafka'

# 重启postgres
service postgresql restart

# 创建插件
sudo -u postgres -i psql -c "CREATE EXTENSION pipeline_kafka;"

插件使用

添加broker

select pipeline_kafka.add_broker('broker1:9092,broker2:9092[,broker:port]');

消费topic中的数据到foreign table

-- 假定kafka中的数据为json格式, 消费topic中的数据到foreign table, 设置并行度为4
select pipeline_kafka.consume_begin('kafka_topic_name', 'topic_stream', format := 'json', parallelism := 4);


启动/停止

select pipeline_kafka.consume_begin();
select pipeline_kafka.consume_end();
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值