kafka 集群管理工具 cmak

CMAK 是管理Kafka集群的常用工具,之前的名字叫Kafka Manager。CMAK功能很强大,它可以管理多个Kafka集群,查看集群内部状态,如:topic、broker、consumer、partition,也可用于创建topic,迁移分区等.
官方镜像地址:https://github.com/yahoo/CMAK
下载当前最新版本:

cd /data/soft
wget https://github.com/yahoo/CMAK/releases/download/3.0.0.6/cmak-3.0.0.6.zip

解压缩

unzip cmak-3.0.0.6.zip -C /data/soft
mv cmak-3.0.0.6 cmak
cd cmak
mkdir logs

调整参数
CMAK主要有两个配置文件需要修改,都位于conf目录下,分别是application.conf和consumer.properties

application.conf

cd /data/soft/cmak/conf
vim application.conf
#最主要修改的就是cmak.zkhosts参数,这两个是连接zookeeper的
cmak.zkhosts="192.168.30.136:2181,192.168.30.136:2182,192.168.30.136:2183"
#接下来是用户认证相关参数,支持2种认证方式
第一种是设置用户名密码
basicAuthentication.enabled=true

basicAuthentication.username="admin"
basicAuthentication.password="password"

第二种是LDAP认证,需要配置LDAP服务器,但是basicAuthentication.enabled也需要设置为true
basicAuthentication.enabled=true
basicAuthentication.ldap.enabled=true

basicAuthentication.ldap.server=${?KAFKA_MANAGER_LDAP_SERVER}
basicAuthentication.ldap.port=389
basicAuthentication.ldap.username=${?KAFKA_MANAGER_LDAP_USERNAME}
basicAuthentication.ldap.password=${?KAFKA_MANAGER_LDAP_PASSWORD}
basicAuthentication.ldap.search-base-dn=${?KAFKA_MANAGER_LDAP_SEARCH_BASE_DN}
basicAuthentication.ldap.search-filter=${?KAFKA_MANAGER_LDAP_SEARCH_FILTER}
basicAuthentication.ldap.group-filter=${?KAFKA_MANAGER_LDAP_GROUP_FILTER}

consumer.properties

cd /data/soft/cmak/conf
vim consumer.properties
security.protocol=SASL_PLAINTEXT
sasl.mechanism=PLAIN
key.deserializer=org.apache.kafka.common.serialization.ByteArrayDeserializer
value.deserializer=org.apache.kafka.common.serialization.ByteArrayDeserializer

在conf目录下新建一个文件kafka_client_jaas.conf,用来指定kafka的用户名密码,其内容如下,用户名密码应与kafka配置中的一致:

cd /data/soft/cmak/conf
vim kafka_client_jaas.conf
KafkaClient {
        org.apache.kafka.common.security.plain.PlainLoginModule required
        username="admin"
        password="0123456789";
};

启动CMAK

cd /data/soft/cmak
nohup /data/soft/cmak/bin/cmak -java-home /data/soft/jdk11/jdk11 -Dconfig.file=/data/soft/cmak/conf/application.conf -Dhttp.port=9000 > /data/soft/cmak/logs/cmak.log 2>/data/soft/cmak/logs/cmak-error.log &  
#java_home需要指定JDK11以上的环境;
#端口默认9000,可以按照参数修改。

登录网页
http://192.168.30.136:9000/