1. 程式人生 > 實用技巧 >安裝Kafka-eagle時踩過的坑

安裝Kafka-eagle時踩過的坑

在安裝Kafka-eagle的時候遇見幾個坑,在這裡分享一下:

注意:版本問題,若按本文章不能解決,則著重檢視版本的問題;這裡只是提供解決針對問題的思路

Kafka版本:kafka_2.11-0.11.0.2

Kafka-eagle版本:kafka-eagle-bin-1.3.7

MySQL版本:5.7.28 MySQL

坑1:關於安裝成功之後返回狀態頁500

需要使用到JMX埠,配置Kafka/bin下的kafka-server-start.sh:

#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or 
more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http:
//www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
if [ $# -lt 1 ]; then echo "USAGE: $0 [-daemon] server.properties [--override property=value]*" exit 1 fi base_dir=$(dirname $0) if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties" fi # 注意:這裡是修改後的檔案 if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
  #新增程式碼如下: export JMX_PORT="9999" fi EXTRA_ARGS=${EXTRA_ARGS-'-name kafkaServer -loggc'} COMMAND=$1 case $COMMAND in -daemon) EXTRA_ARGS="-daemon "$EXTRA_ARGS shift ;; *) ;; esac exec $base_dir/kafka-run-class.sh $EXTRA_ARGS kafka.Kafka "$@"

解決:

  1. 進入eagle的bin目錄下,編輯檔案ke.sh

 # 註釋掉一下幾行程式碼
#
rm -rf $KE_HOME/kms/webapps/ke #rm -rf $KE_HOME/kms/work #mkdir -p $KE_HOME/kms/webapps/ke #cd $KE_HOME/kms/webapps/ke #${JAVA_HOME}/bin/jar -xvf $KE_HOME/kms/webapps/
ke.war

  2. 進入到 /export/servers/kafka-eagle-bin-1.3.7/eagle/kms/webapps/ke/WEB-INF/lib 刪除Jackson開頭的jar包

rm -fr jackson-*.jar

  3. 啟動 zk叢集和Kafka叢集,然後啟動eagle:

# 注意要配置好環境變數,並source
zk.sh start

坑2:連線org.sqlite.JDBC沒有問題,但是連線MySQL失敗,一直進不去Dashboard頁面

######################################
# 這裡配置自己的叢集,我這裡只有一套,刪除了原來的cluster2
######################################
kafka.eagle.zk.cluster.alias=cluster1
cluster1.zk.list=node01:2181,node02:2181,node03:2181

######################################
# 預設即可
######################################
kafka.zk.limit.size=25

######################################
# 預設即可
######################################
kafka.eagle.webui.port=8048

######################################
# 刪除了cluster2,保留1,為Kafka,0.96版本之後,offset資訊儲存在Kafka叢集中
######################################
cluster1.kafka.eagle.offset.storage=kafka

######################################
# 都設定為true
######################################
kafka.eagle.metrics.charts=true
kafka.eagle.sql.fix.error=true

######################################
# 預設即可
######################################
kafka.eagle.sql.topic.records.max=5000

######################################
# 預設即可,也可以設定為true
######################################
kafka.eagle.mail.enable=true
kafka.eagle.mail.sa=alert_sa@163.com
kafka.eagle.mail.username=alert_sa@163.com
kafka.eagle.mail.password=mqslimczkdqabbbh
kafka.eagle.mail.server.host=smtp.163.com
kafka.eagle.mail.server.port=25

######################################
# 預設
######################################
#kafka.eagle.im.dingding.enable=true
#kafka.eagle.im.dingding.url=https://oapi.dingtalk.com/robot/send?access_token=

#kafka.eagle.im.wechat.enable=true
#kafka.eagle.im.wechat.token=https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=xxx&corpsecret=xxx
#kafka.eagle.im.wechat.url=https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=
#kafka.eagle.im.wechat.touser=
#kafka.eagle.im.wechat.toparty=
#kafka.eagle.im.wechat.totag=
#kafka.eagle.im.wechat.agentid=

######################################
# 預設
######################################
kafka.eagle.topic.token=keadmin

######################################
# 預設
######################################
cluster1.kafka.eagle.sasl.enable=false
cluster1.kafka.eagle.sasl.protocol=SASL_PLAINTEXT
cluster1.kafka.eagle.sasl.mechanism=PLAIN

######################################
# kafka jdbc driver address
######################################
kafka.eagle.driver=com.mysql.jdbc.Driver
kafka.eagle.url=jdbc:mysql://你的IP:3306/ke?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
kafka.eagle.username=root
kafka.eagle.password=你的密碼

# 之前返回500報錯,使用sqlite測試 #kafka.eagle.driver
=org.sqlite.JDBC #kafka.eagle.url=jdbc:sqlite:/export/servers/kafka-eagle-bin-1.3.7/eagle/db/ke.db #kafka.eagle.username=root #kafka.eagle.password=你的密碼

解決:

  1. 測試MySQL是否能夠讓外界連線到

  2. 進入到你的MySQL:

-- 進入MySQL, 123456是你的密碼
mysql -u root -p123456

-- 使用mysql資料庫
use mysql

-- 檢視user表中的資料 root後面 有沒有跟%
select  User,Host from user;

-- 如果沒有,則使用以下命令 這裡的root是你的使用者名稱 123456是你的密碼
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

flush privileges;

-- 退出,最好使用Windows的MySQL工具連線一下測試

最後,啟動eagle,登入檢視是否成功!

如有問題,歡迎討論!!!