1. sbt編譯工具安裝配置
# 1.安裝
[admin@bdc01 ~]$ sudo wget -O /etc/yum.repos.d/bintray-sbt-rpm.repo https://bintray.com/sbt/rpm/rpm
[admin@bdc01 ~]$ sudo yum install sbt -y
# 2.配置,文件:/etc/sbt/sbtopts,未列出的保持默認(rèn)即可
-sbt-create
-sbt-dir /opt/sbt
-sbt-boot /opt/sbt/boot
-ivy /data/sbt/repo
-Dsbt.override.build.repos=true
-Dsbt.repository.config=/etc/sbt/repositories
-Dsbt.repository.secure=false
-Dfile.encoding=UTF8
-Dsbt.log.format=true
# 3.創(chuàng)建自定義的目錄
[admin@bdc01 ~]$ sudo mkdir -p /opt/sbt/boot
[admin@bdc01 ~]$ sudo mkdir -p /data/sbt/repo
[admin@bdc01 ~]$ sudo chown -R admin:admin /opt/sbt
[admin@bdc01 ~]$ sudo chown -R admin:admin /data/sbt
# 4.優(yōu)化倉庫地址,加速下載,文件:/etc/sbt/repositories
[repositories]
local
public: https://maven.aliyun.com/nexus/content/groups/public/
typesafe: https://dl.bintray.com/typesafe/ivy-releases/ , [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
ivy-sbt-plugin: https://dl.bintray.com/sbt/sbt-plugin-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
sonatype-oss-releases
sonatype-oss-snapshots
# 5.下載jar包
[admin@bdc01 ~]$ sbt sbtVersion
# 到這一行會卡住一會,耐心等待,之后下載會很快
[info] [launcher] getting org.scala-sbt sbt 1.4.2 (this may take some time)...
downloading https://maven.aliyun.com/nexus/content/groups/public/org/scala-sbt/sbt/1.4.2/sbt-1.4.2.jar ...
downloading https://maven.aliyun.com/nexus/content/groups/public/org/scala-lang/scala-library/2.12.12/scala-library-2.12.12.jar ...
[SUCCESSFUL ] org.scala-sbt#sbt;1.4.2!sbt.jar (528ms)
...
[info] welcome to sbt 1.4.2 (Oracle Corporation Java 1.8.0_251)
...
[info] Fetched artifacts of
[info] set current project to admin (in build file:/home/admin/)
[info] 1.4.2
2. cmak源碼編譯
# 1.下載源碼,解壓后進(jìn)入源碼根目錄
[admin@bdc01 ~]$ wget https://github.com/yahoo/CMAK/archive/3.0.0.5.tar.gz
[admin@bdc01 ~]$ tar -zxvf 3.0.0.5.tar.gz
[admin@bdc01 ~]$ cd CMAK-3.0.0.5/
# 2.編譯源碼
# 注意:是sbt clean dist,不是./sbt clean dist
[admin@bdc01 CMAK-3.0.0.5]$ sbt clean dist
# 我在執(zhí)行過程中遇到以下報(bào)錯(cuò)
[error] Caused by: lmcoursier.internal.shaded.coursier.cache.ArtifactError$WrongChecksum: wrong checksum: /home/admin/.cache/coursier/v1/https/maven.aliyun.com/nexus/content/groups/public/org/webjars/npm/entities/2.1.0/entities-2.1.0.jar (expected SHA-1 1bcaa0b8032c97dbad046323af72ff0213ebcac5 in /home/admin/.cache/coursier/v1/https/maven.aliyun.com/nexus/content/groups/public/org/webjars/npm/entities/2.1.0/entities-2.1.0.jar.sha1, got c36a3cc098a65d94b215834942e806fc8d1af23a)
[error] at lmcoursier.internal.shaded.coursier.cache.FileCache.$anonfun$validateChecksum$4(FileCache.scala:705)
[error] at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:659)
[error] at scala.util.Success.$anonfun$map$1(Try.scala:255)
...
# 這里是說,org/webjars/npm/entities/2.1.0/entities-2.1.0.jar這個(gè)jar包
# 目錄下有個(gè)entities-2.1.0.jar.sha1文件,其中記錄的sha1值為1bcaa0b8032c97dbad046323af72ff0213ebcac5
# 而通過sha1sum計(jì)算出來的值是c36a3cc098a65d94b215834942e806fc8d1af23a
# 這說明這個(gè)文件有問題
# 我驗(yàn)證了一下,果然sha1值對不上
# 于是我在maven的中央倉庫下載了該jar包,https://repo1.maven.org/maven2/org/webjars/npm/entities/2.1.0/entities-2.1.0.jar
# 使用sha1sum計(jì)算,得到的值是c36a3cc098a65d94b215834942e806fc8d1af23a
# 說明,阿里云倉庫下載下來的jar包與maven中央倉庫下載的jar包是一樣的
# 但是不知道什么原因,entities-2.1.0.jar.sha1文件中的值有問題
# 于是我把entities-2.1.0.jar.sha1文件中的值改成了c36a3cc098a65d94b215834942e806fc8d1af23a
# 再執(zhí)行,就沒有問題了
# 依賴的jar包下完之后,報(bào)了一推錯(cuò)
[error] /home/admin/CMAK-3.0.0.5/app/kafka/manager/actor/cluster/KafkaStateActor.scala:115:29: type mismatch;
[error] found : java.util.Map[_$1,_$2] where type _$2, type _$1
[error] required: java.util.Map[? <: Object, ? <: Object]
[error] Note: _$1 >: ? <: Object, but Java-defined trait Map is invariant in type K.
[error] You may wish to investigate a wildcard type such as `_ >: ? <: Object`. (SLS 3.2.10)
[error] Note: _$2 >: ? <: Object, but Java-defined trait Map is invariant in type V.
[error] You may wish to investigate a wildcard type such as `_ >: ? <: Object`. (SLS 3.2.10)
[error] cp => props.putAll(cp.asMap)
[error] ^
[error] /home/admin/CMAK-3.0.0.5/app/kafka/manager/actor/cluster/KafkaStateActor.scala:275:29: type mismatch;
[error] found : java.util.Map[_$1,_$2] where type _$2, type _$1
[error] required: java.util.Map[? <: Object, ? <: Object]
[error] Note: _$1 >: ? <: Object, but Java-defined trait Map is invariant in type K.
[error] You may wish to investigate a wildcard type such as `_ >: ? <: Object`. (SLS 3.2.10)
[error] Note: _$2 >: ? <: Object, but Java-defined trait Map is invariant in type V.
[error] You may wish to investigate a wildcard type such as `_ >: ? <: Object`. (SLS 3.2.10)
[error] cp => props.putAll(cp.asMap)
...
# 我的環(huán)境是JDK1.8,由于官網(wǎng)介紹cmak都是使用JDK11編譯的于是我嘗試使用JDK11再進(jìn)行一次編譯,這次編譯成功了
[admin@bdc01 CMAK-3.0.0.5]$ sbt -java-home /usr/java/jdk-11.0.9 clean dist
copying runtime jar...
[info] welcome to sbt 1.4.2 (Oracle Corporation Java 11.0.9)
[info] loading project definition from /home/admin/CMAK-3.0.0.5/project/project
[info] loading settings for project cmak-3-0-0-5-build from plugins.sbt ...
[info] loading project definition from /home/admin/CMAK-3.0.0.5/project
[info] loading settings for project root from build.sbt ...
[info] set current project to cmak (in build file:/home/admin/CMAK-3.0.0.5/)
[success] Total time: 0 s, completed Nov 6, 2020, 2:20:26 PM
[info] Wrote /home/admin/CMAK-3.0.0.5/target/scala-2.12/cmak_2.12-3.0.0.5.pom
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.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Main Scala API documentation to /home/admin/CMAK-3.0.0.5/target/scala-2.12/api...
[info] Non-compiled module 'compiler-bridge_2.12' for Scala 2.12.10. Compiling...
[info] compiling 136 Scala sources and 2 Java sources to /home/admin/CMAK-3.0.0.5/target/scala-2.12/classes ...
[info] Compilation completed in 11.645s.
model contains 632 documentable templates
[info] Main Scala API documentation successful.
[info] LESS compiling on 1 source(s)
[success] All package validations passed
[info] Your package is ready in /home/admin/CMAK-3.0.0.5/target/universal/cmak-3.0.0.5.zip
[success] Total time: 82 s (01:22), completed Nov 6, 2020, 2:21:48 PM
# 在CMAK-3.0.0.5/target/universal目錄下,有一個(gè)文件:cmak-3.0.0.5.zip
# 就是編譯好的安裝包
3. cmak安裝部署
cmak在github上有已經(jīng)編譯好的安裝包,我在JDK1.8環(huán)境中無法運(yùn)行,于是才有了上一步的源碼編譯,我想使用JDK1.8編譯,使得安裝包可以在JDK1.8環(huán)境中運(yùn)行,結(jié)果使用JDK1.8編譯都編譯不過,于是,只好老老實(shí)實(shí)的使用JDK11來安裝cmak了。
# 1.安裝JDK11
# cmak都是使用JDK11版本來編譯的,所以使用JDK8是無法運(yùn)行的
# 所以給cmak單獨(dú)部署JDK11環(huán)境
[admin@bdc01 java]$ ll /usr/java/
total 0
lrwxrwxrwx 1 root root 12 2020-06-10 14:16 jdk -> jdk1.8.0_251
drwxr-xr-x 8 root root 115 2020-11-06 14:17 jdk-11.0.9
drwxr-xr-x 7 root root 245 2020-03-12 14:37 jdk1.8.0_251
# 我的JAVA_HOME實(shí)際上為JDK1.8
[admin@bdc01 java]$ echo $JAVA_HOME
/usr/java/jdk
# 2.解壓
[admin@bdc01 opt]$ sudo unzip cmak-3.0.0.5.zip
[admin@bdc01 opt]$ sudo chown -R admin:admin cmak-3.0.0.5
# 3.修改配置文件
# 文件:cmak-3.0.0.5/conf/application.conf
application.home=/opt/cmak-3.0.0.5
cmak.zkhosts="bdc01:2181,bdc02:2181,bdc03:2181"
basicAuthentication.enabled=true
basicAuthentication.username="admin"
basicAuthentication.password="admin"
# 文件cmak-3.0.0.5/conf/logback.xml、cmak-3.0.0.5/conf/logger.xml
# 在根標(biāo)簽<configuration>下添加如下配置
<property name="application.home" value="/opt/cmak-3.0.0.5"/>
# 4.Kafka開啟JMX端口
# 文件:kafka/bin/kafka-run-class.sh
# 在文件開頭加入以下環(huán)境變量
export JMX_PORT=9988
# 同步配置后重啟Kafka集群
# 5.啟動(dòng)cmak
[admin@bdc01 cmak-3.0.0.5]$ nohup /opt/cmak-3.0.0.5/bin/cmak -Dhttp.port=9998 -java-home /usr/java/jdk-11.0.9 > /dev/null &
[1] 47282
# 6.進(jìn)入Zookeeper客戶端,創(chuàng)建/kafka-manager/mutex節(jié)點(diǎn)
# 如果zookeeper的版本是>3.4的,則這一步是不需要的
[admin@bdc01 cmak-3.0.0.5]$ zkCli.sh
[zk: localhost:2181(CONNECTED) 0] create /kafka-manager ""
Created /kafka-manager
[zk: localhost:2181(CONNECTED) 1] create /kafka-manager/mutex ""
Created /kafka-manager/mutex
[zk: localhost:2181(CONNECTED) 2] create /kafka-manager/mutex/locks ""
Created /kafka-manager/locks
[zk: localhost:2181(CONNECTED) 3] create /kafka-manager/mutex/leases ""
Created /kafka-manager/leases
[zk: localhost:2181(CONNECTED) 4] quit
訪問WEB-UI:


點(diǎn)擊頁面最下方的"Save"按鈕后:


查看Topic信息:

查看Broker信息:

到這里,cmak-3.0.0.5的安裝部署就完成了。