前置准备

基础环境规划

JDK版本11.x

Kafka-manager端口19099
 

firewall-cmd --zone=public --add-port=19099/tcp --permanent
firewall-cmd --reload

1、kafka-manager安装

1.1 程序安装

上传cmak-3.0.0.5.zip至该目录下并解压

cd /usr/local
unzip x cmak-3.0.0.5.zip
mv cmak-3.0.0.5 kafka-manager

1.2 修改配置文件

kafka-manager.zkhosts和cmak.zkhosts改为自己的zookeeper服务器地址

vi /usr/local/kafka-manager/conf/application.conf

1.3 启动kafka-manager

cd /usr/local/kafka-manager
./bin/cmak -Dconfig.file=/usr/local/kafka-manager/conf/application.conf -java-home /usr/java/jdk-11.0.9 -Dhttp.port=19099

1.4 状态检查

curl http://172.27.10.71:19099/api/health

kafka-manager进程启动成功!

2、Web配置

2.1 添加cluster

点击Add Cluster

配置Cluster Zookeeper Hosts和Kafka Version

配置完成后,点击save!

至此,kafka-manager搭建成功!

3、配置kafka-manager自启动

3.1 创建文件启动脚本

cat >/usr/lib/systemd/system/kafka-manager.service <<EOF
[Unit]

Description=kafka-manager server service
After=network.target

[Service]

WorkingDirectory=/usr/local/kafka-manager/
ExecStart=/usr/local/kafka-manager/bin/cmak -Dconfig.file=/usr/local/kafka-manager/conf/application.conf -java-home /usr/java/jdk-11.0.9 -Dhttp.port=19099

Restart=on-failure
RestartSec=60

[Install]

WantedBy=multi-user.target
EOF

添加为系统服务并配置自启动:

systemctl daemon-reload
systemctl enable --now kafka-manager
systemctl status kafka-manager

3.2 配置日志切割

cat >/etc/logrotate.d/kafka-manager <<EOF
/usr/local/kafka-manager/logs/application.log {

    daily

    rotate 10

    dateext

    missingok

    notifempty

}
EOF

4、异常解决

4.1 异常1:Timeout

Yikes! Ask timed out on [ActorSelection[Anchor(akka://kafka-manager-system/), Path(/user/kafka-manager)]] after [1000 ms] Try again.

异常原因可能为zookeeper端口配置错误

4.2 异常2:未创建kafka锁

Yikes! KeeperErrorCode = Unimplemented for /kafka-manager/mutex Try again.

CDH集成的ZK集群:

参考链接:https://github.com/yahoo/CMAK/issues/731icon-default.png?t=LA92https://github.com/yahoo/CMAK/issues/731

zookeeper-client

[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/mutex/locks

[zk: localhost:2181(CONNECTED) 3] create /kafka-manager/mutex/leases ""

Created /kafka-manager/mutex/leases
[zk: localhost:2181(CONNECTED) 4] ls /kafka-manager
[configs, mutex, deleteClusters, clusters]

原生kafka集群同样手动创建即可!

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐