知识点
相关文章
更多最近更新
更多Kafka 集群环境配置
2019-03-04 07:50|来源: 网路
下载解压
Kafka 0.9.0.1在下面的地址可以下载:
https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.1/kafka_2.10-0.9.0.1.tgz
tar -zxvf kafka_2.10-0.9.0.1.tgz
配置
[hadoop@master kafka_2.10-0.9.0.1]$ vim config/server.properties
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker. broker.id=1
############################# Socket Server Settings #############################
listeners=PLAINTEXT://192.168.56.101:9092
# The port the socket server listens on #port=9092
# Hostname the broker will bind to. If not set, the server will bind to all interfaces #host.name=master
# Hostname the broker will advertise to producers and consumers. If not set, it uses the # value for "host.name" if configured. Otherwise, it will use the value returned from # java.net.InetAddress.getCanonicalHostName(). #advertised.host.name=<hostname routable by clients> #这个是配置PRODUCER/CONSUMER连上来的时候使用的地址 advertised.host.name=master
# The port to publish to ZooKeeper for clients to use. If this is not set, # it will publish the same port that the broker binds to. #advertised.port=<port accessible by clients>
# 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 #kafka存放消息文件的路径 log.dirs=/opt/kafka/data/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. #topic的默认分区数 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
############################# 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 #kafka接收日志的存储目录(目前我们保存7天数据log.retention.hours=168) 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.56.101:2181
# Timeout in ms for connecting to zookeeper zookeeper.connection.timeout.ms=6000 |
集群
把配置好的kafla打包到其他两台机器
scp -r kafka_2.10-0.9.0.1 slave1:/opt/kafka/
scp -r kafka_2.10-0.9.0.1 slave2:/opt/kafka/
更改server.properties配置文件中的broker.id和listeners
启动
分别在三台机器上启动zookeeper、kafka
启动kafka命令:
/opt/kafka/kafka_2.10-0.9.0.1/bin/kafka-server-start.sh /opt/kafka/kafka_2.10-0.9.0.1/config/server.properties &
使用zkCli查看节点
[zk: localhost:2181(CONNECTED) 10] ls /brokers
[seqid, topics, ids]
[zk: localhost:2181(CONNECTED) 12] ls /brokers/ids
[3, 2, 1]
相关问答
更多-
kafka脱离了zookeeper可以集群吗[2023-07-28]
不可以,kafka必须要依赖一个zookeeper集群才能运行。kafka系群里面各个broker都是通过zookeeper来同步topic列表以及其它broker列表的,一旦连不上zookeeper,kafka也就无法工作。 -
kafka集群是否启动成功?[2022-06-18]
你的问题在于如何让一个程序一直在后台运行,还是只是窗口运行, (1)如果要kafka进程一直常驻并且在后台不关闭,启动如下: cd /home/kafka/kafka_2.10-0.9.0.0/ nohup bin/kafka-server-start.sh config/server.properties & (2)如果只是想窗口运行,启动如下: cd /home/kafka/kafka_2.10-0.9.0.0/ bin/kafka-server-start.sh config/server.prope ... -
kafka脱离了zookeeper可以集群吗[2022-04-23]
不可以,kafka必须要依赖一个zookeeper集群才能运行。kafka系群里面各个broker都是通过zookeeper来同步topic列表以及其它broker列表的,一旦连不上zookeeper,kafka也就无法工作。 -
当您运行> bin/kafka-console-consumer.sh命令时,kafka加载一个ConsoleConsumer ,它将尝试使用自动生成的消费者标识创建消费者。 Kafka生成消费者ID的方式是将本地主机的名称连接到它。 所以,在这个问题上,事实上,Java无法解决我正在使用的Open Stack VM上本地主机的IP地址。 所以答案是Open Stack VM将本地主机名解析为kafka ,这是VM的名称。 我把卡夫卡和Zookeeper实例中的所有设置都设置为kafka1 。 所以,当ja ...
-
假设 这是一个生产群集,您不希望任何数据丢失。 您有遍布代理的分区副本 对于每个分区,每个代理至少有一个副本 每个经纪人都可以访问所有zks 我就是这样做的 取消个别经纪人。 当其中一个代理关闭时,然后describe主题以检查是否只有未显示的副本属于被删除的代理。 重新启动代理并再次验证所有分区是否同步,然后再转到下一个代理。 然后单独停止启动每个zk,每次跟踪所有副本和分区是否同步。 这样,至少有一个zk可用于2个代理来维护其元数据 Assumptions This is a production cl ...
-
下载Confluent Platform tarball,解压缩,然后仅配置并运行REST代理。 如果您已经拥有现有的Kafka,我不建议使用YUM来安装整个汇合平台。 或者,备份现有的Kafka和Zookeeper属性文件,然后将Confluent Platform放在现有文件的顶部,保留原始文件。 如果您的Kafka是旧版本,请将此作为安排升级的好机会。 下载Confluent不会覆盖相应版本的上游Apache项目版本的任何内容。 如果有的话,这是一个扩展 Download the Confluent ...
-
主机名应该是您在“链接”中指定的名称,即。 “海边的卡夫卡”。 正如@dnephin所说,不需要主机名。 我想你想要的实际上是KAFKA_ADVERTISED_HOST_NAME环境变量。 你有什么版本的码头工具? 我在Mac OS上使用docker 1.12.3没有任何问题。 您可能还想尝试Confluent docker镜像: https://hub.docker.com/r/confluentinc/cp-kafka/ https://hub.docker.com/r/confluentinc/cp- ...
-
如何在Kafka集群上部署Kafka Streaming应用程序(How to deploy Kafka Streaming Application on Kafka Cluster)[2024-01-14]
Kafka流具有不同的体系结构 - 它不需要像Spark / Flink这样的集群编排 - 它们只是您可以启动和停止的正常应用程序,如果您启动 - 它们将按比例放大,如果您停止缩小它们。 在内部,他们使用Kafka协调数据处理,与其他Kafka消费者类似。 如果您有Kubernetes,Docker Swarm或其他类似平台,那么您可以将您的应用程序打包到Docker中,并使用该平台运行您的Kafka Streams应用程序。 Kafka streams has different architecture ... -
kafka - 可以将python程序连接到hadoop集群外的Kafka吗?(kafka - can python program connect to Kafka outside hadoop cluster?)[2023-12-03]
了解Kafka更多信息的最简单方法是使用http://landoop.com/docs/lenses/developers 您将需要运行1个docker - 在本地调出所有内容,然后开发Python应用程序,使用通过Kafka API连接到Kafka的相应Kafka库并向其生成消息 一旦你构建了你的应用程序 - 然后你可以打包它并对你的Hadoop的Kafka经纪人运行它 Easiest way to learn more about Kafka is to use http://landoop.com/d ... -
我可以指出几个起点,从这些起点到完全功能的东西会涉及到一些工作。 一种选择是使用docker镜像在Cloud Foundry(例如Pivotal Web Services)上部署kafka群集。 Spotify有Dockerized kafka和kafka-proxy (包括Zookeeper)。 要记住的一件事是PWS目前不支持具有持久性的应用程序(尽管这项工作正在开始 ),所以如果你现在就开始使用这条路线,那么在应用程序推出时你会丢失kafka中的数据。 看看Spotify的回购,看起来Docker图像 ...