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

相關文章
相關標籤/搜索