librdkafka

.Net(c#)使用 Kafka 小结

六月ゝ 毕业季﹏ 提交于 2020-08-05 13:51:05
.Net(c#)使用 Kafka 小结 1.开篇 由于项目中必须使用 kafka 来作为消息组件,所以使用 kafka 有一段时间了。不得不感叹 kafka 是一个相当优秀的消息系统。下面直接对使用过程做一总结,希望对大家有用。 1.1.kafka 部署 kafka 的简单搭建我们使用 docker 进行,方便快捷单节点。生产环境不推荐这样的单节点 kafka 部署。 1.1.1.确保安装了 docker 和 docker-compose 网上很多教程,安装也简单,不作为重点赘述。 1.1.2.编写 docker-compose.yml 将以下内容直接复制到新建空文件 docker-compose.yml 中。 version: "3" services: zookeeper: image: wurstmeister/zookeeper ports: - "2181:2181" kafka: image: wurstmeister/kafka depends_on: [zookeeper] ports: - "9092:9092" environment: KAFKA_ADVERTISED_HOST_NAME: localhost KAFKA_CREATE_TOPICS: "test" KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 volumes:

PHP 消息队列 Kafka 使用

走远了吗. 提交于 2020-08-05 10:34:06
安装 Kafka 服务 直接到 kafka 官网 , 下载最新的 wget https://mirror.bit.edu.cn/apache/kafka/2.5.0/kafka_2.13-2.5.0.tgz    解压,进入目录 tar -zxvf kafka_2.13-2.5.0.tgz cd kafka_2.13-2.5.0    启动 Kafka 服务 使用安装包中的脚本启动单节点 Zookeeper 实例 bin/zookeeper-server-start.sh -daemon config/zookeeper.properties    使用 kafka-server-start.sh 启动 kafka 服务 bin/kafka-server-start.sh config/server.properties    创建 topic bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test    查看 topic 列表,检查是否创建成功 bin/kafka-topics.sh --list --zookeeper localhost:2181 $ test    生产者,发送消息 bin/kafka-console

python kafka client--confluent-kafka-python

扶醉桌前 提交于 2020-05-08 04:28:23
项目中需要使用python 向Kafka生产和消费数据,最初使用pykafka 。后来发现pykafka不支持client.id. 最后,终于找到confluent-kafka。 python kafka推荐使用confluent-kafka,官方推荐的。 Confluent's Apache Kafka Python client confluent-kafka-python is Confluent's Python client for Apache Kafka and the Confluent Platform. 安装和使用可参考github https://github.com/confluentinc/confluent-kafka-python 本文只针对笔者使用python2.7 + Linux环境介绍kafka包安装和使用。 安装python 可网上搜索教程,此处略过。 安装librdkafka For RedHat and RPM-based distros, add this YUM repo and then do sudo yum install librdkafka-devel python-devel: http://docs.confluent.io/current/installation.html#rpm-packages-via-yum

Kafka生产者的客户端(PHP)开发

天涯浪子 提交于 2020-04-26 11:17:42
一、准备工作 虽然 Kafka 是用 Java/Scala 语言编写的,但这不妨碍它对多语言的支持。可以在 Kafka 官网的 CLIENTS 查看 Kafka 支持的语言,其中包括 C/C++、PHP、Python、Go 等语言。 PHP 操作 Kafka 需要安装 librdkafka 库和 kafka 的 PHP 扩展。 1.安装 librdkafka 库 git clone https://github.com/edenhill/librdkafka.git ./configure make sudo make install 2.安装 php-kafka 扩展 $ git clone https://github.com/arnaud-lb/php-rdkafka.git $ cd librdkafka/ $ phpize $ ./configure $ make $ sudo make install #在php.ini 文件中配置 rdkafka扩展 extension=rdkafka.so #查看扩展是否生效 php -m | grep kafka 二、代码实现 demo 来源于 https:// github.com/arnaud-lb/ph p-rdkafka#examples 正常的生产逻辑如下: 1.配置生产者客户端参数及创建相应的生产者实例; /** *

Build Golang Application with librdkafka in a Debian Docker Image?

白昼怎懂夜的黑 提交于 2020-03-21 06:10:47
问题 With Alpine, Alpine fully supports recent versions of librdkafka, I can just do apk add in my Dockerfile, and the following works: FROM golang:1.13-alpine3.10 as builder WORKDIR /app COPY go.mod go.sum ./ COPY src ./src/ RUN set -eux; \ apk add --no-cache gcc git libc-dev librdkafka-dev; \ go build -o ./ ./... Now, for a particular project, I need to make Debian friendly binaries, that will run on Debian/Ubuntu servers. The problem is that: The official Debian repositories only support really

Build Golang Application with librdkafka in a Debian Docker Image?

谁说我不能喝 提交于 2020-03-21 06:10:17
问题 With Alpine, Alpine fully supports recent versions of librdkafka, I can just do apk add in my Dockerfile, and the following works: FROM golang:1.13-alpine3.10 as builder WORKDIR /app COPY go.mod go.sum ./ COPY src ./src/ RUN set -eux; \ apk add --no-cache gcc git libc-dev librdkafka-dev; \ go build -o ./ ./... Now, for a particular project, I need to make Debian friendly binaries, that will run on Debian/Ubuntu servers. The problem is that: The official Debian repositories only support really

LibRdKafka: commited_offset always at -1001

吃可爱长大的小学妹 提交于 2020-02-05 03:54:08
问题 When I run my consumer group I have always this kind of statistics: 2016-10-15 13:56:17.925: "STATS": { "name": "debian-meox#producer-2", "type": "producer", "ts":16768436761, "time":1476532577, "replyq":0, "msg_cnt":75428, "msg_size":29314007, "msg_max":100000, "msg_size_max":4096000000, "simple_cnt":0, "brokers":{ "localhost:9092/bootstrap": { "name":"localhost:9092/bootstrap", "nodeid":-1, "state":"UP", "stateage":4989561, "outbuf_cnt":0, "outbuf_msg_cnt":0, "waitresp_cnt":0, "waitresp_msg

How does librdkafka producer learn about new topic partitions in Kafka

跟風遠走 提交于 2019-12-24 07:36:24
问题 I'm running rdkafka_simple_producer.c to produce messages to a Kafka cluster. I have one topic and 30 partitions. Using the default round-robin partitioner. While the producer is working and generating messages to Kafka, I add more partitions to Kafka kafka/bin/kafka-topics.sh --alter --zookeeper server2:2181 --topic demotest --partitions 40 I'd expect the producer to realize about the change and eventually begin to produce to all 40 topics. However, at the end I only see data was produced to

Linux下librdkafka客户端的编译运行

前提是你 提交于 2019-12-20 10:45:15
Linux下librdkafka 客户端的编译运行    librdkafka是一个开源的 Kafka客户端 C/C++实现,提供了Kafka生产者、消费者接口。   由于项目需要,我要将Kafka生产者接口封装起来给别人调用,所以先安装了librdkakfa,然后在demo上进行修改封装一个生产者接口。 [一] 安装librdkafka    首先在github上下载 librdkafka 源码,解压后进行编译;    cd librdkafka-master    chmod 777 configure lds-gen.py    ./configure    make    make install    在make的时候,如果是64位Linux会报下面这个异常    /bin/ld:librdkafka.lds:1: syntax error in VERSION script    只要 Makefile.config里面的 WITH_LDS=y这一行注释掉就不会报错了。 [二] 封装librdkafka的生产者接口 #include <ctype.h> #include <signal.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <syslog.h> #include

Ubuntu16.04安装php kafka扩展

妖精的绣舞 提交于 2019-12-03 09:00:32
一.安装librdkafka git clone https://github.com/edenhill/librdkafka.git cd librdkafka/ ./configure make sudo make install //甚至不用这一步 cd /usr/local/lib/ sudo ln -sf librdkafka++.so.1 librdkafka++.so 二.安装扩展 git clone https://github.com/arnaud-lb/php-rdkafka.git cd php-rdkafka phpize ./configure --with-php-config=/usr/bin/php-config make all -j 5 make test sudo make install 来源: 51CTO 作者: dfwasds 链接: https://blog.51cto.com/rhino/2445783