CentOS安装KafkaManager

1、下载

下载地址:github.com/yahoo/CMAK/…html

shell> wget https://codeload.github.com/yahoo/CMAK/tar.gz/2.0.0.2
复制代码

说明:以前叫Kafka Manager,如今更名叫CMAK(Cluster Manager for Apache Kafka)了,网页下载以后的压缩包名字是CMAK-2.0.0.2.tar.gz,wget下载后的压缩包名字是2.0.0.2.tar.gz(若是是2.0.0.0或更老版本,wget下载后的压缩包名字只有版本号,没有后缀名,可是也能够直接解压)java

2、解压

shell> tar -zxvf CMAK-2.0.0.2.tar.gz -C /usr/local/
复制代码

解压后的目录为CMAK-2.0.0.2node

3、sbt编译

kafka-manager须要sbt编译,因此若是没有安装sbt须要先安装下git

一、yum
shell> curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
shell> sudo yum install sbt
复制代码
二、手动安装

下载地址:www.scala-sbt.org/download.ht…github

shell> wget https://piccolo.link/sbt-1.3.8.tgz
shell> tar -zxvf sbt-1.3.8.tgz -C /usr/local/

复制代码

添加环境变量web

shell> vim /etc/profile
复制代码
export PATH=/usr/local/sbt/bin:$PATH
复制代码
shell> source /etc/profile
复制代码
三、修改仓库地址(sbt默认下载库很慢,这里添加aliyun仓库,相似使用maven时添加aliyun仓库提升速度)
shell> vim ~/.sbt/repositories
复制代码

添加如下内容shell

[repositories]
local
aliyun: http://maven.aliyun.com/nexus/content/groups/public/
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
sonatype-oss-releases
maven-central
sonatype-oss-snapshots
复制代码
四、编译

这个过程会很漫长,由于要下载不少依赖包,甚至开始看起来像是卡住了同样,耐心等待,再等待...vim

(若是真的要折腾,建议开个后台进程,不想等的下面有编译好的连接)api

编译成功后会在target/universal/目录下生成一个可用于部署的kafka-manager-2.0.0.2.zipbash

shell> cd
shell> ./sbt clean dist
[info] Loading settings for project cmak-2-0-0-2-build from plugins.sbt ...
[info] Loading project definition from /usr/local/CMAK-2.0.0.2/project
[info] Updating ProjectRef(uri("file:/usr/local/CMAK-2.0.0.2/project/"), "cmak-2-0-0-2-build")...
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Loading settings for project root from build.sbt ...
[info] Set current project to kafka-manager (in build file:/usr/local/CMAK-2.0.0.2/)
[success] Total time: 0 s, completed Mar 30, 2020 1:22:04 AM
[info] Packaging /usr/local/CMAK-2.0.0.2/target/scala-2.12/kafka-manager_2.12-2.0.0.2-sources.jar ...
[info] Done packaging.
Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js.
[info] Updating ...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.8/scala-compiler-2.12.8.jar ...
[info]  [SUCCESSFUL ] org.scala-lang#scala-compiler;2.12.8!scala-compiler.jar (1389309ms)
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Wrote /usr/local/CMAK-2.0.0.2/target/scala-2.12/kafka-manager_2.12-2.0.0.2.pom
[info] Main Scala API documentation to /usr/local/CMAK-2.0.0.2/target/scala-2.12/api...
[info] Compiling 131 Scala sources and 2 Java sources to /usr/local/CMAK-2.0.0.2/target/scala-2.12/classes ...
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.8. Compiling...
[info]   Compilation completed in 11.025s.
model contains 604 documentable templates
[info] Main Scala API documentation successful.
[info] Packaging /usr/local/CMAK-2.0.0.2/target/scala-2.12/kafka-manager_2.12-2.0.0.2-javadoc.jar ...
[info] Done packaging.
[info] LESS compiling on 1 source(s)
[info] Done compiling.
[info] Packaging /usr/local/CMAK-2.0.0.2/target/scala-2.12/kafka-manager_2.12-2.0.0.2-web-assets.jar ...
[info] Packaging /usr/local/CMAK-2.0.0.2/target/scala-2.12/kafka-manager_2.12-2.0.0.2.jar ...
[info] Done packaging.
[info] Done packaging.
[info] Packaging /usr/local/CMAK-2.0.0.2/target/scala-2.12/kafka-manager_2.12-2.0.0.2-sans-externalized.jar ...
[info] Done packaging.
[success] All package validations passed
[info] Your package is ready in /usr/local/CMAK-2.0.0.2/target/universal/kafka-manager-2.0.0.2.zip
[success] Total time: 1466 s, completed Mar 30, 2020 1:46:30 AM
复制代码

shell> cd /usr/local/CMAK-2.0.0.2/target/universal
shell> ll
total 94404
-rw-r--r-- 1 root root 96662556 Mar 30 01:46 kafka-manager-2.0.0.2.zip
drwxr-xr-x 3 root root     4096 Mar 30 01:46 scripts
复制代码

我这里时间看起来没有那么那么长,主要是由于以前编译过一次了,为了测试和截图又从新来了一遍...

若是有时间愿意折腾能够按照以上步骤尝试一下,若是不想经历着漫长的等待,推荐你们直接下载编译好的zip,这里我把本身编译过的几个版本分享下:

1.3.3.22:连接:pan.baidu.com/s/1PyRIckLk… 密码:7v8r

2.0.0.0:连接:pan.baidu.com/s/1lYvyrx0e… 密码:7wd9

2.0.0.2:连接:pan.baidu.com/s/1fiQvM1rb… 密码:hh4w

另外,3.0.0.2以后貌似已经提供了编译好的版本,不过我没有试,看大小和目录结构应该是,只是新版本要求JDK 11+,配置和启动部分名称都有所调整,须要稍微注意下(kafka-manager改为了cmak)有兴趣的能够尝试下

4、配置

shell> vim /usr/local/CMAK-2.0.0.2/conf/application.conf
复制代码

编辑kafka-manager.zkhosts

kafka-manager.zkhosts="my.zookeeper.host.com:2181"
复制代码

若是是集群:

kafka-manager.zkhosts="my.zookeeper.host.com:2181,other.zookeeper.host.com:2181"
复制代码

5、运行

kafka-manager默认使用9000端口,使用-Dhttp.port指定端口

shell> cp kafka-manager-2.0.0.2.zip /usr/local/
shell> unzip kafka-manager-2.0.0.2.zip
shell> cd /usr/local/kafka-manager-2.0.0.2
shell> bin/kafka-manager -Dconfig.file=conf/application.conf -Dhttp.port=9002
复制代码

后台启动

shell> nohup bin/kafka-manager -Dconfig.file=conf/application.conf -Dhttp.port=9002 >/dev/null 2>&1 &
复制代码

6、使用

添加Cluster

Cluster ZooKeeper Hosts:zk1:2181,zk2:2181,zk3:2181/NAMESPACE

勾选红框部分,前提是 kafka 启动时开启了 JMX_PORT才会生效

shell> cd /usr/local/kafka_2.12-2.2.0
shell> JMX_PORT=9999 bin/kafka-server-start.sh -daemon config/server.properties
复制代码
查看topic及Consumer

到目前为止,kafka-manager的安装和基本配置就完成了,更多详细用法能够参考开源项目:github.com/yahoo/CMAK

相关文章
相关标签/搜索