6、多节点集群环境下Kafka的Confluent Platform的下载安装配置手册

1、简介

本主题提供使用复制的 ZooKeeper ensemble在多节点环境中安装可用于生产的Confluent平台配置的说明。

使用这种安装方法,您可以手动连接到每个节点,下载归档文件,并运行Confluent Platfrom安装命令。

注:您必须为集群中的每个节点完成这些步骤。

前提条件
在安装Confluent平台之前,您的环境必须具备以下软件和硬件需求

2、获取软件

1、进入下载页面,选择您的存档包,或者使用curl直接下载

Confluent Platform
ZIP

curl -O http://packages.confluent.io/archive/5.4/confluent-5.4.0-2.12.zip

TAR

curl -O http://packages.confluent.io/archive/5.4/confluent-5.4.0-2.12.tar.gz

Confluent Platform仅使用Confluent社区组件
ZIP

curl -O http://packages.confluent.io/archive/5.4/confluent-community-5.4.0-2.12.zip

TAR

curl -O http://packages.confluent.io/archive/5.4/confluent-community-5.4.0-2.12.tar.gz

注:包名包含Confluent平台版本和Scala版本。例如,5.4.0-2.12.zip表示Confluent平台版本5.4.0和Scala版本2.12。

提取存档的内容。对于ZIP文件,在终端中运行此命令:

unzip confluent-5.4.0-2.12.zip

对于tar文件:

tar xzf confluent-5.4.0-2.12.tar.gz

3、Confluent Platform的配置文件

使用各个组件属性文件配置Confluent平台。默认情况下,它们位于<path-to-confluent>/etc/。你必须最少配置以下组件:

(1)Zookeeper

这些说明假设您以复制模式运行ZooKeeper。复制模式至少需要三个服务器,故障转移必须有奇数个服务器。有关更多信息,请参见ZooKeeper文档

1、导航到ZooKeeper属性文件(/etc/kafka/ZooKeeper .properties)并按如下所示进行修改。

tickTime=2000
dataDir=/var/lib/zookeeper/
clientPort=2181
initLimit=5
syncLimit=2
server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888
autopurge.snapRetainCount=3
autopurge.purgeInterval=24

此配置用于三节点集成。这个配置文件在集成中的所有节点上应该是相同的。tickTime, dataDir, 和clientPort都被设置为典型的单服务器值。initLimitsyncLimit控制followingZooKeeper服务器初始化当前leader需要多长时间和leader不同步的时间需要多长时间。在这种配置中,一个following可以花费10000毫秒来初始化,并且可以根据设置为2000ms的tickTime在4000毫秒内不同步。

server.*属性是设置集合中的成员变量.,形式是:
server.<myid>=<hostname>:<leaderport>:<electionport>

  • myid是服务器标识号。有三个服务器,每个服务器都有不同的myid,分别为123。通过在dataDir中创建一个名为myid的文件来设置myid,该文件包含一个ASCII码编码的整数。这个值必须匹配配置文件中的一个myid值。如果另一个ensemble成员已经使用冲突的myid值启动,你将看到一个报错。
  • leaderportfollower用来连接到现存活的leader。此端口应该在所有Zookeeper集合成员之间打开
  • electionport用于展示在全体成员之间选取leader

autopurge.snapRetainCountautopurge.purgeInterval被设置为每24小时清除3个snapshots之外的所有快照。

2、导航到ZooKeeper日志目录(例如/var/lib/zookeeper/)并创建一个名为myid的文件。myid文件由一行组成,其中在<machine-id>中包含有格式为的机器ID。当ZooKeeper服务器启动时,它通过引用myid文件知道它是哪个服务器。例如,服务器1的myid值为1。

(2)Kafka

在生产环境中,需要多个broker。在启动期间,broker在ZooKeeper中注册自己,成为集群的成员。

导航到Apache Kafka®属性文件(/etc/ Kafka /server.properties),并自定义如下内容:

  • 通过将所有节点中的zookeeper.connect设置为相同的值来连接到相同的ZooKeeper ensemble。将localhost的所有实例替换为主机名或者为 FQDN(节点的完全限定域名)例如,如果你的主机名是zookeeper:
    zookeeper.connect=zookeeper:2181

  • 使用其中一种方法为集群中的每个节点配置broker id。
    动态生成broker id:添加broker.id.generation.enable=true并注释掉broker.id。例如

    ############################# Server Basics #############################
    
    # The ID of the broker. This must be set to a unique integer for each broker.
    #broker.id=0
    broker.id.generation.enable=true
    

    手动设置broker id:在每个节点上为broker.id设置一个唯一的值。配置其他broker和客户端如何使用listeners和(可选)advertised.listenersbroker通信。
    listeners:uri的Comma-separated list和要监听的侦听器名称。
    advertised.listeners:uri的Comma-separated list和其他broker和客户端要使用的监听器名称。advertised.listeners参数确保代理声明一个可以从本地和外部主机访问的地址。

    有关更多信息,请参见Production Configuration Options

  • 为您的环境配置安全性。
    有关一般安全指南,请参阅Security
    有关基于角色的访问控制(RBAC),请参阅Configure Metadata Service (MDS)
    有关SSL加密、SASL身份验证和授权,请参阅Security Tutorial

(3)Control Center

1、导航到Control Center属性文件(/etc/confluent-control-center/ Control - Center -production.properties),并定制以下内容:

# host/port pairs to use for establishing the initial connection to the Kafka cluster
bootstrap.servers=<hostname1:port1,hostname2:port2,hostname3:port3,...>

# location for Control Center data
confluent.controlcenter.data.dir=/var/lib/confluent/control-center

# the Confluent license
confluent.license=<your-confluent-license>

# ZooKeeper connection string with host and port of a ZooKeeper servers
zookeeper.connect=<hostname1:port1,hostname2:port2,hostname3:port3,...>

此配置用于一个三节点多节点集群。有关更多信息,Control Center configuration details.有关Confluent平台许可证的信息,请参见Managing Confluent Platform Licenses.

2、导航到Kafka服务器配置文件(/etc/ Kafka /server.properties)并启用Confluent Metrics报告器。

##################### Confluent Metrics Reporter #######################
# Confluent Control Center and Confluent Auto Data Balancer integration
#
# Uncomment the following lines to publish monitoring data for
# Confluent Control Center and Confluent Auto Data Balancer
# If you are using a dedicated metrics cluster, also adjust the settings
# to point to your metrics Kafka cluster.
metric.reporters=io.confluent.metrics.reporter.ConfluentMetricsReporter
confluent.metrics.reporter.bootstrap.servers=localhost:9092

#
# Uncomment the following line if the metrics cluster has a single broker
confluent.metrics.reporter.topic.replicas=1

3、将这些行添加到Kafka连接属性文件(/etc/ Kafka / Connect - distribution .properties)以添加对拦截器的支持。

# Interceptor setup
consumer.interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringConsumerInterceptor
producer.interceptor.classes=io.confluent.monitoring.clients.interceptor.MonitoringProducerInterceptor

(4)Schema Registry

导航到模式注册表属性文件(/etc/ Schema - Registry / Schema - Registry .properties)并指定以下属性

# Specify the address the socket server listens on, e.g. listeners = PLAINTEXT://your.host.name:9092
listeners=http://0.0.0.0:8081

# The host name advertised in ZooKeeper. This must be specified if your running Schema Registry
# with multiple nodes.
host.name=192.168.50.1

# List of Kafka brokers to connect to, e.g. PLAINTEXT://hostname:9092,SSL://hostname2:9092
kafkastore.bootstrap.servers=PLAINTEXT://hostname:9092,SSL://hostname2:9092

此配置用于一个三节点多节点集群。有关更多信息,请参见Running Schema Registry in Production.

4、开启Confluetn Platform

使用Kafka CLI命令安装Confluent平台。

注:ZooKeeper、Kafka和Schema Registry必须按照这个特定的顺序启动,并且必须在任何其他组件之前启动。

1、开启Zookeeper,在它自己的终端中运行这个命令

<path-to-confluent>/bin/zookeeper-server-start <path-to-confluent>/etc/kafka/zookeeper.properties

2、开启Kafka,在它自己的终端中运行这个命令

<path-to-confluent>/bin/kafka-server-start <path-to-confluent>/etc/kafka/server.properties

3、开启Schema Registry,在它自己的终端中运行这个命令

<path-to-confluent>/bin/schema-registry-start <path-to-confluent>/etc/schema-registry/schema-registry.properties

4、根据自己的需求启动其他Confluent Platform组件。
Control Center

<path-to-confluent>/bin/control-center-start <path-to-confluent>/etc/confluent-control-center/control-center.properties

Kafka Connect

<path-to-confluent>/bin/control-center-start <path-to-confluent>/etc/confluent-control-center/control-center.properties

Confluetn REST Proxy

<path-to-confluent>/bin/kafka-rest-start <path-to-confluent>/etc/kafka-rest/kafka-rest.properties

KSQL

<path-to-confluent>/bin/ksql-server-start <path-to-confluent>/etc/ksql/ksql-server.properties

5、卸载Confluent Platform

1、删除Confluent目录。例如,如果你已经安装了Confluent Platform 5.4.0

rm -rf confluent-5.4.0

2、删除Confluent Platfrom的数据文件

rm -rf /var/lib/<confluent-platform-data-files>

参考文档:Manual Install using ZIP and TAR Archives

其余参考文章:
Confluent完全分布式框架搭建

【大数据平台】——基于Confluent的Kafka Rest API探索(一)

Kafka Confluent安装部署

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

辰阳星宇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值