整合Kafka

news2024/10/7 16:25:39

Main Concepts

一些服务器形成了存储层,被称为broker,其他服务器运行kafka连接去不断地导入和导出数据作为事件流,将kafka和关系型数据库等存在的系统集成。
Servers: Kafka is run as a cluster of one or more servers that can span multiple datacenters or cloud regions. Some of these servers form the storage layer, called the brokers. Other servers run Kafka Connect to continuously import and export data as event streams to integrate Kafka with your existing systems such as relational databases as well as other Kafka clusters. To let you implement mission-critical use cases, a Kafka cluster is highly scalable and fault-tolerant: if any of its servers fails, the other servers will take over their work to ensure continuous operations without any data loss.

KAFKA中的数据称为event
An event records the fact that “something happened” in the world or in your business. It is also called record or message in the documentation. When you read or write data to Kafka, you do this in the form of events. Conceptually, an event has a key, value, timestamp, and optional metadata headers.

Producers are those client applications that publish (write) events to Kafka, and consumers are those that subscribe to (read and process) these events.
In Kafka, producers and consumers are fully decoupled and agnostic of each other, which is a key design element to achieve the high scalability that Kafka is known for.
For example, producers never need to wait for consumers. Kafka provides various guarantees such as the ability to process events exactly-once.

events被有组织地持久化存储在topic中,topic类似于文件夹,event类似于文件夹中的文件。
These events are organized and stored in topics. Very simplified, a topic is similar to a folder in a filesystem, and the events are the files in that folder.
Events are organized and durably stored in topics. Very simplified, a topic is similar to a folder in a filesystem, and the events are the files in that folder. An example topic name could be “payments”. Topics in Kafka are always multi-producer and multi-subscriber: a topic can have zero, one, or many producers that write events to it, as well as zero, one, or many consumers that subscribe to these events. Events in a topic can be read as often as needed—unlike traditional messaging systems, events are not deleted after consumption. Instead, you define for how long Kafka should retain your events through a per-topic configuration setting, after which old events will be discarded. Kafka’s performance is effectively constant with respect to data size, so storing data for a long time is perfectly fine.

一个topic的跨度是多个broker节点(比如一个文件夹中的东西放在多个机器上)。
Topics are partitioned, meaning a topic is spread over a number of “buckets” located on different Kafka brokers. This distributed placement of your data is very important for scalability because it allows client applications to both read and write the data from/to many brokers at the same time. When a new event is published to a topic, it is actually appended to one of the topic’s partitions. Events with the same event key (e.g., a customer or vehicle ID) are written to the same partition, and Kafka guarantees that any consumer of a given topic-partition will always read that partition’s events in exactly the same order as they were written.

为了容错性和高可靠,每个topic都可被复制。
To make your data fault-tolerant and highly-available, every topic can be replicated, even across geo-regions or datacenters, so that there are always multiple brokers that have a copy of the data just in case things go wrong, you want to do maintenance on the brokers, and so on. A common production setting is a replication factor of 3, i.e., there will always be three copies of your data. This replication is performed at the level of topic-partitions.
在这里插入图片描述

# 启动zookeeper
docker pull zookeeper
docker run -d --restart=always --name zookeeper -p 2181:2181 -v /etc/localtime:/etc/localtime zookeeper

# 下载安装kafka 
curl -O https://mirrors.aliyun.com/apache/kafka/3.3.1/kafka_2.12-3.3.1.tgz
tar -zxvf kafka_2.12-3.3.1.tgz -C /usr/local/src
vim /usr/local/src/kafka_2.12-3.3.1/config/server.properties
# 修改三处
# broker.id // 唯一
# zookeeper.connect=kafka100:2181,kafka200:2181/kafka
# log.dirs=/root/kafka-logs
vim /etc/profile	# 配置kafka环境变量

# 启动(启动之前需先启动zookeeper)
kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
# 看是否启动成功
jps
# 列出已有topic
kafka-topics.sh --bootstrap-server kafka100:9092 --list
# 创建topic,名字为fistTopic,分区为1,复制因子为2(分区数量可以大于broker节点数量, 复制因子不能大于broker节点数量)
kafka-topics.sh --bootstrap-server kafka100:9092 --topic fistTopic --create --partitions 1 --replication-factor 2
kafka-topics.sh --bootstrap-server kafka100:9092 --topic secondTopic --create --partitions 3 --replication-factor 2
# 关闭kafka
kafka-server-stop.sh

在这里插入图片描述
在这里插入图片描述

# 向firstTopic主题写入数据
kafka-console-producer.sh --bootstrap-server kafka100:9092 --topic firstTopic
# 消费firstTopic主题的数据
kafka-console-consumer.sh --bootstrap-server kafka100:9092 --topic firstTopic
# 删除fistTopic主题
kafka-topics.sh --bootstrap-server kafka100:9092 --topic fistTopic --delete

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/125258.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

高手不用Redis内存数据库一

不是说Redis不好,不用Redis用别的(比如:Memcached 2、VoltDB 3、MongoDB 4、Hazelcast 5、Aerospike) No! No! No!!! Redis 很好,我不拦着您用…… 而是说,我们的水平更高了以后,您一定会感受到 内存数据库 不够用、不够灵活、不…

JavaScript基础篇2之日期时间函数

一、计算机中时间字母表示的预知识储备: G(age,时代年龄等意思):时代标志,如AD(Anno Domini公元)、BC(Before Christ公元前)。 y(year&#xff…

zabbix安装使用

1.1 Zabbix概述 Zabbix是一款能够监控各种网络参数以及服务器健康性和完整性的软件。Zabbix使用灵活的通知机制,允许用户为几乎任何事件配置基于邮件的告警。这样可以快速反馈服务器的问题。基于已存储的数据,Zabbix提供了出色的报告和数据可视化功能。…

基于python的turtle实现圣诞树的绘制

文章目录一、前言二、基于turtle实现绘制圣诞树三、效果展示四、实现步骤代码实现分步骤1. 导入库2. 配置圣诞树高度等信息3. 定义函数get_color()可获取随机颜色4. 定义函数snow() 绘制一朵雪花5. 定义函数name()可随机写一些文字6. 定义函数koc() 绘制星星7.定义函数tree()绘…

Qt中调用thrift

thrift是一个Apache公司开源的一款RPC(Remote Procedure Call)框架,让不同语言构建的服务可以做到远程调用无缝对接。 thrift库分两部分: libthrift - 核心库文件,需要依赖OpenSSL、boost libthriftnb - 包含thrift非阻…

内网穿透基本使用

内网穿透基本使用 文章目录内网穿透基本使用前言一、内网穿透二、工具1.FRP2.LCX3.NPS4.Sunny-Ngork三、Sunny-ngork使用四、Frp内网穿透代理1.一层代理2.二层代理总结前言 之前零零碎碎接触过不少关于内网渗透测试、内网穿透的知识,但是不得不说渗透测试很吃基础、…

初学Java web(十一)AjaxAxiosJSON

Ajax&Axios&JSON 概念:AJAX(Asynchronous JavaScript And XML):异步的JavaScript和XML AJAX作用:1.与服务器进行数据交换:通过AJAX可以给服务器发送请求,并获取服务器响应的数据 使用了AJAX和服务器进行通信,就可以使用HTMLAJAX来替…

ArcGIS基础实验操作100例--实验10绘制带空洞的面要素

本实验专栏来自于汤国安教授《地理信息系统基础实验操作100例》一书 实验平台:ArcGIS 10.6 实验数据:请访问实验1(传送门) 基础编辑篇--实验10 绘制带空洞的面要素 目录 一、实验背景 二、实验数据 三、实验步骤 方法一&…

【JavaScript】飞机大战简单网页版(源码下载)

文章目录一、效果演示设计思路二、鼠标版飞机大战代码展示1.HTML结构代码2.CSS样式代码3.JavaScript代码js.js文件plane.js文件三、键盘版飞机大战代码展示1.HTML结构代码2.CSS样式代码3.JavaScript代码四、代码资源分享一、效果演示 利用html,css,js制…

qt QCustomplot 用QCPItemStraightLine画参考线,阈值线,水平线

想要在两个坐标系下都画上如下参考线(阈值线,或者 水平线), 这个参考线随着坐标轴的拖拽能够一直显示 我们找到了QCPItemStraightLine,该类能够画一条无限延伸的直线,通过下面的代码能够实现在A坐标系画一条水平线,但不…

[CF-EDU]Segment Tree - part 1 - Step 1 - Practice

练习名称&#xff1a;ITMO Academy: pilot course Segment Tree 练习链接&#xff1a;Segment Tree, part 1, Step1, Practice cf官方的线段树专题练习 A. Segment Tree for the Sum 单点修改&#xff0c;区间和查询 #include <bits/stdc.h> #define lson (u <&l…

P1825 [USACO11OPEN]Corn Maze S

题目描述 This past fall, Farmer John took the cows to visit a corn maze. But this wasnt just any corn maze: it featured several gravity-powered teleporter slides, which cause cows to teleport instantly from one point in the maze to another. The slides work…

Docker安装镜像,并运行成为容器

1.Docker作用 一个项目中&#xff0c;部署时需要依赖于node.js、Redis、RabbitMQ、MySQL等&#xff0c;这些服务部署时所需要的函数库、依赖项各不相同&#xff0c;甚至会有冲突。给部署带来了极大的困难。 而Docker确巧妙的解决了这些问题, Docker为了解决依赖的兼容问题的…

关于两种单菌种发酵的豆瓣酱代谢组学方面差异研究

生活离不开柴米油盐酱醋茶&#xff0c;其中酱油是中国传统的调味品&#xff0c;主要是由大豆经过发酵酿造而成。酱油由酱演变而来&#xff0c;早在三千多年前&#xff0c;中国就有制作酱的记载了。 本期百趣代谢组学文献分享为大家分享的文献是百趣生物协助客户发表的关于两种…

Git cherry-pick

Git cherry-pick 当有多个分支&#xff0c;想将一个分支 A 的提交合并到另一个分支 B 一&#xff1a;将分支A的所有提交合并到分支B&#xff0c;执行合并即可 二&#xff1a;将分支A 的某一次提交合并到分支 B&#xff0c;需要使用 git cherry-pick commit 命令 如下图&#…

随机森林-sklearn

随机森林 1.概述 1.1 集成算法概述 本身并不是一个单独的机器学习算法&#xff0c;而是通过在数据上构建多个模型&#xff0c;集成所有模型的建模结果。以此来获得最好的结果。 集成算法的目标&#xff1a; 集成算法会考虑多个评估器的建模结果&#xff0c;汇总之后得到一个…

物联网低功耗蓝牙核心配置技术: 赋能智能家居和智能工业场景

蓝牙我们都不陌生&#xff0c;早已成为深入我们生活的一项科技。不过&#xff0c;我们所知所用的还只是蓝牙的一部分。而蓝牙目前作为物联网中的一项重要通信技术&#xff0c;其应用还远远不止这些&#xff0c;今天就为大家讲讲蓝牙技术中的低功耗技术的应用及分类。 蓝牙低功耗…

原神私服搭建教程 (最新版)

搭建教程 1.准备阶段 1.请先确保电脑内有这些安装环境&#xff0c;否则私服无法运行&#xff01;&#xff01;&#xff01; MongoDB Python3.8 java17 mitmproxy 没有请在群文件下载安装环境&#xff0c;安装即可。特别强调&#xff1a;java17直接放在C:\Program Files目录下即…

初识Kubernetes:(4)Kubernetes实战入门

初识Kubernetes&#xff1a;&#xff08;4&#xff09;Kubernetes实战入门1 前言2 Namespace2.1 概述2.2 应用示例3 Pod3.1 概述3.2 语法及应用示例1 前言 介绍如何在kubernetes集群中部署一个Nginx服务&#xff0c;并且能够对其访问。 2 Namespace 2.1 概述 Namespace是ku…

写给Java程序员的GRPC入门系列(2)

点击上方GRPC专栏看完整系列 文章目录Abstract前置依赖本文初始状态编写protobuffer文件生成代码下一步Abstract 网上有很多GRPC的例子&#xff0c;但是却没有能够写给普通Java开发人员手把手入门少走弯路的教程。 本教程保证按照步骤一步步来你就可以完成GRPC从0到1的构建。 …