kafka学习-环境搭建


1、几行命令

./kafka-console-consumer.sh --zookeeper 192.168.86.133:2181,192.168.86.132:2181,192.168.86.134:2181 --topic shuaige --from-beginning

./kafka-console-producer.sh --broker-list 192.168.86.133:9092,192.168.86.132:9092,192.168.86.134:9092 --topic shuaige

./kafka-topics.sh --create --zookeeper 192.168.86.133:2181,192.168.86.132:2181,192.168.86.134:2181 --replication-factor 1  --partitions 1 --topic shuaigeck


2、几个错误

A          [2017-06-23 12:31:29,338] WARN Bootstrap broker 192.168.86.133:9092 disconnected (org.apache.kafka.clients.NetworkClient)  

原因不知

B        kafka.common.KafkaException: Failed to acquire lock on file .lock in /opt/kafka/kafka-logs. A Kafka instance in another process or thread is using this directory.

没有创建log文件夹

C        ERROR kafka.admin.AdminOperationException: replication factor: 1 larger than available brokers: 0

/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties &  &命令必须


3、几个结果

[root@slave2 kafka-logs]# ll
总用量 12
-rw-r--r--. 1 root root  0 6月  23 12:10 cleaner-offset-checkpoint
-rw-r--r--. 1 root root 54 6月  23 12:10 meta.properties
-rw-r--r--. 1 root root 29 6月  23 12:49 recovery-point-offset-checkpoint
-rw-r--r--. 1 root root 29 6月  23 12:50 replication-offset-checkpoint
drwxr-xr-x. 2 root root 72 6月  23 12:48 shuaigeck-0

[root@slave2 shuaigeck-0]# ll
总用量 4
-rw-r--r--. 1 root root 10485760 6月  23 12:48 00000000000000000000.index
-rw-r--r--. 1 root root       92 6月  23 12:50 00000000000000000000.log

查看下:

日志:

[root@slave2 shuaigeck-0]# ../../bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files 00000000000000000000.log --print-data-log
Dumping 00000000000000000000.log
Starting offset: 0
offset: 0 position: 0 isvalid: true payloadsize: 7 magic: 1 compresscodec: NoCompressionCodec crc: 3388553551 payload: walasla
offset: 1 position: 41 isvalid: true payloadsize: 17 magic: 1 compresscodec: NoCompressionCodec crc: 879170540 payload: ssssssssssssssssss
索引:

[root@slave2 shuaigeck-0]# ../../bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files 00000000000000000000.index --print-data-log
Dumping 00000000000000000000.index
offset: 0 position: 0


几个配置

service.properties:


# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
host.name=192.168.86.133
############################# Socket Server Settings ############################## The address the socket server listens on. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = security_protocol://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://:9092# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://192.168.86.133:9092# The number of threads handling network requests
num.network.threads=3# The number of threads doing disk I/O
num.io.threads=8# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600############################# Log Basics ############################## A comma seperated list of directories under which to store log files
log.dirs=/opt/kafka/kafka-logs# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=1# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1############################# Log Flush Policy ############################## Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
#    1. Durability: Unflushed data may be lost if you are not using replication.
#    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to exceessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000
message.max.byte=5242880
default.replication.factor=2
replica.fetch.max.bytes=5242880
############################# Log Retention Policy ############################## The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.# The minimum age of a log file to be eligible for deletion
log.retention.hours=168# A size-based retention policy for logs. Segments are pruned from the log as long as the remaining
# segments don't drop below log.retention.bytes.
#log.retention.bytes=1073741824# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=300000############################# Zookeeper ############################## Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=192.168.86.132:2181,192.168.86.133:2181,192.168.86.134:2181# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000

一个问题:

为什么所有的topic都不在我建立topic的机器上,这些topic都出现在其他节点?




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

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

相关文章

java基础之HashTable和HashMap的区别

1、类继承关系 public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable public class Hashtable<K,V> extends Dictionary<K,V> implements Map<K,V>, Cloneable, java.io.Serializable …

java基础之ConcurrentHashMap

1、基础不牢固&#xff0c;请问接口里面怎么有方法&#xff1f; 这个和一般的方法有啥区别&#xff1f; public interface ConcurrentMap<K, V> extends Map<K, V> {/*** {inheritDoc}** implNote This implementation assumes that the ConcurrentMap cannot* con…

java基础之java内存模型

1、原子性 问题&#xff1a;i是原子性没&#xff1f; 不是&#xff01; 我理解原子性是针对计算机指令而言的&#xff0c;i包含读、加和写操作&#xff0c;包含三指令&#xff01; 除此之外&#xff0c;32位计算机读取64位的也不是原子性&#xff01; 2、有序性 并发时 可能…

Java基础之GC回收

非常好的文章&#xff0c;说明了GC的深入的东西 力荐&#xff01; GC是如何判断一个对象为"垃圾"的&#xff1f;被GC判断为"垃圾"的对象一定会被回收吗&#xff1f; http://blog.csdn.net/canot/article/details/51037938 JVM垃圾回收GC原理http://bl…

Eureka源码分析

Eureka源码分析 Eureka server入口: Spring.factories PS: 意味着如果加载EurekaServerAutoConfiguration成功,需要 ConditionalOnBean(EurekaServerMarkerConfiguration.Marker.class)需加载成功. 通过Bean注入了很多类 本质上, eureka-server包含很多事件: EurekaInstanceC…

matlab程序中,如何解决矢量长度必须相同的问题

主要原因就是画图的x和y长度不一样&#xff0c;我用一个例子说明。 问题代码&#xff1a; clear all;close all;clc;x 0 : 1: 9;y sin(x);n 2*length(x);yi interpft(y, n);xi 0 : 0.5 : 10;hold on ;plot(x, y ,ro);plot(xi, yi, b.-);plot(x, sin(x),m--);legend(原始…

matlab 功率谱分析函数psd用法

psd简介 PSD(power spectrum analysis)功率谱分析&#xff0c;PSD在给定频带上的积分计算信号在该频带上的平均功率。与均值-平方谱相反&#xff0c;这个光谱中的峰值并没有反映出给定频率的能量。 单边PSD包含了信号的总功率在频率间隔从DC到一半的奈奎斯特速率。双侧PSD包含…

linux tar (打包、压缩、解压)命令

打包程序&#xff1a;tar c: 创建文档t&#xff1a; 列出存档内容x&#xff1a;提取存档f&#xff1a; filename 要操作的文档名v&#xff1a;详细信息 一&#xff1a;打包 打包&#xff1a;是指把文件整合在一起&#xff0c;不压缩 1.将文件打包&#xff1a;tar cf a.tar…

虚拟机添加硬盘扩容

1.设置→添加→硬盘 2.选择磁盘类型 3.开启虚拟机 4.用ls 命令查看&#xff1a;ls /dev/sd* 5.最后就可以对sdb进行分区操作 这里好麻烦&#xff0c;等我有空&#xff0c;在补上&#xff01; . . .

利用matlab将三维数据画成三维立体图

首先先分析对象。将数据利用matlab画出图&#xff0c;最开始是导入数据&#xff0c;然后处理数据&#xff0c;最后将处理的数据画出来。 所以我将它分为三个步骤。 第一步&#xff1a;导入数据 如果是mat数据。可以直接load如果是txt数据。可以用txtread如果是excel数据。可…

世界坐标、相机坐标、图像坐标、像素坐标的原理、关系,并用matlab仿真

世界坐标、相机坐标、图像坐标、像素坐标的原理、关系&#xff0c;并用matlab仿真 照相机是日常生活中最常见的。它能把三维的空间图片等比例缩小投影在照片上&#xff0c;称为一个二维图像。 以下我们就讲一讲原理&#xff0c;并相应的进行matlab仿真。 在学之前&#xff0…

matlab 三维高程根据图片颜色给对应点赋予颜色

目录 1. 问题分析 2. 技术分析 3. 程序代码 4. 代码运行结果 1. 问题分析 日常工作尤其是测绘、地质、遥感行业&#xff0c;需要画DEM模型&#xff0c;并在这个模型的基础上&#xff0c;进行着色、渲染。比如&#xff0c;地质分析地面三维地表形变之时&#xff0c;需要根据D…

DirectX11中XNA数据库常见的几个函数

本博客的例子来自于《基于DirectX11的3D图形程序设计案例教程》 矩阵转换函数XMStoreFloat*x*&#xff08;*表示正数&#xff0c;**矩阵&#xff09; 如&#xff1a;XMStoreFloat4x4&#xff08;以44矩阵为例&#xff09; 函数定义&#xff1a; VOID XMStoreFloat4x4([out]…

电磁波谱详细划分

电磁波波段名字 波长范围(单位/m) 频率范围(单位/Hz) γ射线 <10-12 X射线 10-11~10-8 紫外线 10-8~3.8-7 可见光 (8.310-7~7.610-7m) 紫 3.810-7~4.310-7 蓝 4.310-7~4.710-7 青 4.710-7~5.010-7 绿 5.010-7~5.610-7 黄 5.610-7~5…

matlab 计算N天前(后)的日期

注意时间的格式&#xff1a;是字符串、数字还是日期&#xff1f; 下面是计算明天、今天、昨天的日期。 day1 datetime(datestr(now,yyyy-mm-dd))caldays(1)%tomorrowday0 datetime(datestr(now,yyyy-mm-dd))%todayday_1 datetime(datestr(now,yyyy-mm-dd))-caldays(1)%yest…

CAT arguments dimensions are not consistent.CAT参数的维度不一致。

错误实例&#xff1a; 在写符号矩阵的时候常常会出现下面错误&#xff1a; 错误&#xff1a;CAT arguments dimensions are not consistent. CAT参数的维度不一致。 举个栗子&#xff1a; clear; close all; clc; syms A_0 B_0 B C D E F G H ;T_3 [2*A_0 C-D*1i H G*1i;C…

传感器尺寸、像素、DPI分辨率、英寸、毫米的关系

虽然网上有很多这种资料&#xff0c;但是太过于复杂&#xff0c;每个人的说法都不一样&#xff0c;看的让人云里雾里的&#xff0c;我总结了一下&#xff0c;不知道对不对&#xff01; 1. 1英寸25.4mm 2. 传感器尺寸&#xff1a;传感器的尺寸是指传感器的大小&#xff0c;一般…

利用PS将n张图制作成动态GIF图

第一步&#xff1a;打开PS,导入图片&#xff0c;文件→脚本→将文件载入堆栈… 数据量大的话&#xff0c;就耐心等待一下。 第二步&#xff1a; 创建祯动画 如果没有这个&#xff0c;可以点击窗口→时间轴 如果祯排列顺序反了&#xff0c;这样 最后按照自己要求设置祯动画时间&…

matlab padarray函数详解

本文来自于matlab帮助页面&#xff0c;命令&#xff1a;help padarray 语法&#xff1a; B padarray(A,padsize) B padarray(A,padsize,padval) B padarray(A,padsize,padval,direction) gpuarrayB padarray(gpuarrayA,___) 描述&#xff1a; B padarray(A,padsize…

matlab 三维画图函数错误提示:数据维度必须一致

用三维画图软件经常会出现下面错误 以mesh(x,y,z)为例&#xff1a; 主要原因是因为没有注意Z数据格式&#xff0c;Z必须是矩阵形式。而且Z矩阵的m*n必须与y,x相关&#xff0c; mesh(X,Y,Z) 使用 Z 确定的颜色绘制线框网格&#xff0c;因此其颜色与曲面高度成比例。如果 X 和 …