简介
截止至2021年9月1日,新版kafka manager(CMAK)
最新版本为v3.0.0.5(2020年6月21日发布),支持kafka v0.8.1.1~ v2.4.0之间的多个版本,但实测是可以支持kafka v2.7.1版本的。旧版kafka manager安装请参考我的文章《Kafka Manager部署和使用》
本教程所讲述的环境版本如下:
环境 | 版本 |
---|---|
操作系统 | centos 7 |
JDK | 11.0.12 |
zookeeper | 3.6.3 |
kafka | 2.7.1 |
kafka manager(CMAK) | 3.0.0.5 |
一.安装JDK11
注:CMAK v3.0.0.5需要JDK11以上,如果你想用JDK1.8去支持此版本是行不通的,会报错提示找不到有些class文件
1.下载安装JDK11
执行命令:
yum -y install java-11-openjdk-devel.x86_64
2.配置JAVA环境变量
修改/etc/profile
文件,在底部追加以下三行信息
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el7_9.x86_64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
3.应用环境变量
source /etc/profile
4.测试环境变量是否配置成功
输入命令:
java -version
如果出现以下版本信息,表示安装成功:
openjdk version "11.0.12" 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)
二.下载CMAK
CMAK版本 | 下载地址 |
---|---|
全部版本 | https://github.com/yahoo/CMAK/releases |
本教程使用3.0.0.5版本 | 点击下载 |
执行命令:
cd /usr/local
wget https://github.com/yahoo/CMAK/archive/refs/tags/3.0.0.5.tar.gz
三.解压
进入/user/local
目录解压,并重命名文件夹为cmak
cd /usr/local
unzip cmak-3.0.0.5.zip
mv cmak-3.0.0.5 ./cmak
四.修改CMAK配置文件
配置文件位置: /usr/local/cmak/conf/application.conf
1.仅需要修改以下内容:
如果用CMAK只读,不做修改操作,那么随便填写Zookeeper集群中的一个节点的IP地址即可
kafka-manager.zkhosts="10.39.88.58:2181"
cmak.zkhosts="10.39.88.58:2181"
如果要用cmak修改操作集群,可以填集群地址:
kafka-manager.zkhosts="10.39.88.57:2181,10.39.88.58:2181,10.39.88.59:2181"
cmak.zkhosts="10.39.88.57:2181,10.39.88.58:2181,10.39.88.59:2181"
2.完整的配置文件
# Copyright 2015 Yahoo Inc. Licensed under the Apache License, Version 2.0
# See accompanying LICENSE file.
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
play.crypto.secret="^<csmm5Fx4d=r2HEX8pelM3iBkFVv?k[mc;IZE<_Qoq8EkX_/7@Zt6dP05Pzea3U"
play.crypto.secret=${?APPLICATION_SECRET}
play.http.session.maxAge="1h"
# The application languages
# ~~~~~
play.i18n.langs=["en"]
play.http.requestHandler = "play.http.DefaultHttpRequestHandler"
play.http.context = "/"
play.application.loader=loader.KafkaManagerLoader
# Settings prefixed with 'kafka-manager.' will be deprecated, use 'cmak.' instead.
# https://github.com/yahoo/CMAK/issues/713
# kafka自带zk地址
kafka-manager.zkhosts="10.39.88.58:2181"
cmak.zkhosts="10.39.88.58:2181"
#kafka-manager.zkhosts=${?ZK_HOSTS}
#cmak.zkhosts=${?ZK_HOSTS}
pinned-dispatcher.type="PinnedDispatcher"
pinned-dispatcher.executor="thread-pool-executor"
application.features=["KMClusterManagerFeature","KMTopicManagerFeature","KMPreferredReplicaElectionFeature","KMReassignPartitionsFeature", "KMScheduleLeaderElectionFeature"]
akka {
loggers = ["akka.event.slf4j.Slf4jLogger"]
loglevel = "INFO"
}
akka.logger-startup-timeout = 60s
basicAuthentication.enabled=false
basicAuthentication.enabled=${?KAFKA_MANAGER_AUTH_ENABLED}
basicAuthentication.ldap.enabled=false
basicAuthentication.ldap.enabled=${?KAFKA_MANAGER_LDAP_ENABLED}
basicAuthentication.ldap.server=""
basicAuthentication.ldap.server=${?KAFKA_MANAGER_LDAP_SERVER}
basicAuthentication.ldap.port=389
basicAuthentication.ldap.port=${?KAFKA_MANAGER_LDAP_PORT}
basicAuthentication.ldap.username=""
basicAuthentication.ldap.username=${?KAFKA_MANAGER_LDAP_USERNAME}
basicAuthentication.ldap.password=""
basicAuthentication.ldap.password=${?KAFKA_MANAGER_LDAP_PASSWORD}
basicAuthentication.ldap.search-base-dn=""
basicAuthentication.ldap.search-base-dn=${?KAFKA_MANAGER_LDAP_SEARCH_BASE_DN}
basicAuthentication.ldap.search-filter="(uid=$capturedLogin$)"
basicAuthentication.ldap.search-filter=${?KAFKA_MANAGER_LDAP_SEARCH_FILTER}
basicAuthentication.ldap.group-filter=""
basicAuthentication.ldap.group-filter=${?KAFKA_MANAGER_LDAP_GROUP_FILTER}
basicAuthentication.ldap.connection-pool-size=10
basicAuthentication.ldap.connection-pool-size=${?KAFKA_MANAGER_LDAP_CONNECTION_POOL_SIZE}
basicAuthentication.ldap.ssl=false
basicAuthentication.ldap.ssl=${?KAFKA_MANAGER_LDAP_SSL}
basicAuthentication.ldap.ssl-trust-all=false
basicAuthentication.ldap.ssl-trust-all=${?KAFKA_MANAGER_LDAP_SSL_TRUST_ALL}
basicAuthentication.username="admin"
basicAuthentication.username=${?KAFKA_MANAGER_USERNAME}
basicAuthentication.password="password"
basicAuthentication.password=${?KAFKA_MANAGER_PASSWORD}
basicAuthentication.realm="Kafka-Manager"
basicAuthentication.excluded=["/api/health"] # ping the health of your instance without authentification
kafka-manager.consumer.properties.file=${?CONSUMER_PROPERTIES_FILE}
五.启动CMAK
启动时,需要指定端口,本例端口为9000,注意不要与其他应用端口冲突。
cd /usr/local/cmak/bin
nohup ./cmak -Dconfig.file=../conf/application.conf -Dhttp.port=9000 &
六.页面访问CMAK
浏览器通过访问:cmak安装服务器的ip地址:9000
如:10.39.88.58:9000
七.页面配置CMAK,连接kafka集群
总结
本文介绍了最新版的kafka manager(CMAK)的下载和安装,相比于之前的版本,安装步骤要简化了很多,最起码不需要自己编译了。喜欢本文请点赞收藏。
本文涉及的Kafka 系列教程:
教程 | 内容 |
---|---|
《Centors下搭建Zookeeper v3.6.3集群(支持kafka集群)教程》 | Zookeeper集群配置 |
《Centors下搭建Kafka集群教程(v2.7.1)》 | kafka 集群配置 |
《Kafka Manager部署和使用》 | 旧版kafka manager的下载和安装 |