1.環境說明
服務器資源規劃如下表:
| IP | hostname | 部署資源 |
|---|---|---|
| 192.168.162.201 | m162p201 | zookeeper,kafka |
| 192.168.162.202 | m162p202 | zookeeper,kafka |
| 192.168.162.203 | m162p203 | zookeeper,kafka |
作業系統版本(三個節點均相同):
[root@m162p201 software]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.7.1908 (Core)
Release: 7.7.1908
Codename: Core
2.環境準備
2.1 依賴軟體下載
計劃安裝的軟體:
| 軟體 | 版本 | 安裝節點 | 下載地址 |
|---|---|---|---|
| jdk | jdk-8u311-linux-x64.rpm | m162p201,m162p202,m162p203 | https://www.oracle.com/java/technologies/downloads/#java8 |
| zookeeper | apache-zookeeper-3.5.6-bin.tar.gz | m162p201,m162p202,m162p203 | https://archive.apache.org/dist/zookeeper/zookeeper-3.5.6/ |
| kafka | kafka_2.12-3.0.0.tgz | m162p201,m162p202,m162p203 | https://kafka.apache.org/downloads#3.0.0 |
| eagle | kafka-eagle-bin-1.4.8.tar.gz | m162p201 | http://download.kafka-eagle.org/ |
將上述軟體上傳到對應服務器的/opt/software目錄,
2.2 jdk安裝
由于下載的是rpm包,因此直接執行rpm安裝命令即可:
[root@m161p114 software]# rpm -ivh jdk-8u311-linux-x64.rpm
warning: jdk-8u311-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:jdk1.8-2000:1.8.0_311-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@m161p114 software]#
2.3 zookeeper安裝
在每臺服務器都新建一個zookeeper用戶:
useradd -d /opt/zookeeper zookeeper
在 /etc/security/limit.conf中增加如下內容:
zookeeper soft nproc 16384
zookeeper hard nproc 16384
zookeeper soft nofile 65535
zookeeper hard nofile 65536
切換到zookeeper用戶 su - zookeeper
建立軟鏈接,便于以后切換版本:
ln -s /opt/zookeeper/zookeeper-3.4.10 /opt/zookeeper/zookeeper
由于采用rpm安裝了jdk,因此并不需要重新配置jdk的環境變數,
為了便于后續操作,將zookeeper的環境變數配置上,修改.bash_profile檔案,
export ZOOKEEPER_HOME=/opt/zookeeper/apache-zookeeper
export PATH=$ZOOKEEPER_HOME/bin:$PATH
之后重新加載環境變數:
soure .bash_profile
zookeeper組態檔:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.162.201:2888:3888
server.2=192.168.162.202:2888:3888
server.3=192.168.162.203:2888:3888
之后建立data目錄:
mkdir /opt/zookeeper/data
echo 1 > /opt/zookeeper/data/myid
同樣在另外兩臺服務器將myid配置為 2和3.
上述操作完成之后,可以啟動zookeeper:
zkServer.sh start
2.安裝kafka
2.1 建立用戶并修改環境變數
useradd -d /opt/kafka kafka
在 /etc/security/limit.conf中增加如下內容:
kafka soft nproc 16384
kafka hard nproc 16384
kafka soft nofile 65535
kafka hard nofile 65536
切換到kafka 用戶 su - kafka
建立軟鏈接,便于以后切換版本:
tar -zxvf /opt/soft/kafka_2.12-3.0.0.tar.gz
ln -s /opt/kafka/kafka_2.12-3.0.0 /opt/kafka/apache-kafka
修改環境變數 .bash_profile檔案增加如下內容:
KAFKA_HOME=/opt/kafka/apache-kafka
export PATH=$KAFKA_HOME/bin:$PATH
alias acdconf='cd /opt/kafka/apache-kafka/config/'
2.2 修改kafka組態檔
配置/opt/kafka/apache-kafka/config/server.properties
要修改的引數如下:
m162p201:
broker.id=1
listeners=PLAINTEXT://192.168.162.201:9092
log.dirs=/opt/kafka/kafka-logs
zookeeper.connect=192.168.162.201:2181,192.168.162.202:2181,192.168.162.203:2181
m162p202:
broker.id=2
listeners=PLAINTEXT://192.168.162.202:9092
log.dirs=/opt/kafka/kafka-logs
zookeeper.connect=192.168.162.201:2181,192.168.162.202:2181,192.168.162.203:2181
m162p203:
broker.id=3
listeners=PLAINTEXT://192.168.162.203:9092
log.dirs=/opt/kafka/kafka-logs
zookeeper.connect=192.168.162.201:2181,192.168.162.202:2181,192.168.162.203:2181
2.3 啟動kafka
cd /opt/kafka/apache-kafka
bin/kafka-server-start.sh -daemon config/server.properties
3.安裝管理工具eagle
eagle安裝在kafka用戶下,不用重新創建目錄,此外eagle只需要在一個節點安裝即可,
切換到kafka用戶:
sudo su - kafka
tar -zxvf kafka-eagle-bin-1.4.8.tar.gz
建立軟鏈接,便于后續切換版本:
ln -s /opt/kafka/kafka-eagle-web-1.4.8 /opt/kafka/kafka-eagle
在環境變數中增加eagle的相關內容:
KE_HOME=/opt/kafka/kafka-eagle
export KE_HOME
重新加載環境變數:
source .bash_profile
修改期組態檔:
vim /opt/kafka/kafka-eagle/conf/system-config.properties
修改為如下內容:
######################################
# multi zookeeper & kafka cluster list
######################################
kafka.eagle.zk.cluster.alias=cluster1
cluster1.zk.list=192.168.162.201:2181,192.168.162.202:2181,192.168.162.203:2181
######################################
# broker size online list
######################################
cluster1.kafka.eagle.broker.size=20
######################################
# zk client thread limit
######################################
kafka.zk.limit.size=25
######################################
# kafka eagle webui port
######################################
kafka.eagle.webui.port=8048
######################################
# kafka offset storage
######################################
cluster1.kafka.eagle.offset.storage=kafka
cluster2.kafka.eagle.offset.storage=zk
######################################
# kafka metrics, 15 days by default
######################################
kafka.eagle.metrics.charts=false
kafka.eagle.metrics.retain=15
######################################
# kafka sql topic records max
######################################
kafka.eagle.sql.topic.records.max=5000
kafka.eagle.sql.fix.error=false
######################################
# delete kafka topic token
######################################
kafka.eagle.topic.token=keadmin
######################################
# kafka sasl authenticate
######################################
cluster1.kafka.eagle.sasl.enable=false
cluster1.kafka.eagle.sasl.protocol=SASL_PLAINTEXT
cluster1.kafka.eagle.sasl.mechanism=SCRAM-SHA-256
cluster1.kafka.eagle.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required username="kafka" password="kafka-eagle";
cluster1.kafka.eagle.sasl.client.id=
cluster1.kafka.eagle.sasl.cgroup.enable=false
cluster1.kafka.eagle.sasl.cgroup.topics=
cluster2.kafka.eagle.sasl.enable=false
cluster2.kafka.eagle.sasl.protocol=SASL_PLAINTEXT
cluster2.kafka.eagle.sasl.mechanism=PLAIN
cluster2.kafka.eagle.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="kafka" password="kafka-eagle";
cluster2.kafka.eagle.sasl.client.id=
cluster2.kafka.eagle.sasl.cgroup.enable=false
cluster2.kafka.eagle.sasl.cgroup.topics=
######################################
# kafka ssl authenticate
######################################
cluster3.kafka.eagle.ssl.enable=false
cluster3.kafka.eagle.ssl.protocol=SSL
cluster3.kafka.eagle.ssl.truststore.location=
cluster3.kafka.eagle.ssl.truststore.password=
cluster3.kafka.eagle.ssl.keystore.location=
cluster3.kafka.eagle.ssl.keystore.password=
cluster3.kafka.eagle.ssl.key.password=
cluster3.kafka.eagle.ssl.cgroup.enable=false
cluster3.kafka.eagle.ssl.cgroup.topics=
######################################
# kafka sqlite jdbc driver address
######################################
kafka.eagle.driver=org.sqlite.JDBC
kafka.eagle.url=jdbc:sqlite:/opt/kafka/kafka-eagle/db/ke.db
kafka.eagle.username=admin
kafka.eagle.password=123456
######################################
# kafka mysql jdbc driver address
######################################
#kafka.eagle.driver=com.mysql.jdbc.Driver
#kafka.eagle.url=jdbc:mysql://127.0.0.1:3306/ke?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
#kafka.eagle.username=root
#kafka.eagle.password=123456
由于服務器上沒有安裝mysql因此,用sqlite即可
kafka.eagle.username=admin
kafka.eagle.password=123456
則指定了eagle登陸的用戶名和密碼,
監聽8048埠,此外,為了eagle采集更多的kafka運行資訊,需要開啟kafka的jmx服務,修改每個節點kafka的啟動腳本
vim /opt/kafka/apache-kafka/bin/kafka-server-start.sh
增加30行內容
28 if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
29 export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
30 export JMX_PORT="7788"
31 fi
之后重啟即可,注意每個節點都需要修改,
現在啟動eagle
cd /opt/kafka/kafka-eagle/bin
[kafka@m162p201 kafka-eagle]$ cd bin/
[kafka@m162p201 bin]$ ls
ke.bat ke.pid ke.sh
[kafka@m162p201 bin]$ ./ke.sh
Usage: ./ke.sh {start|stop|restart|status|stats|find|gc|jdk|version|sdate}
[kafka@m162p201 bin]$ ./ke.sh start
[2021-11-03 16:58:07] INFO: Starting kafka eagle environment check ...
created: META-INF/
inflated: META-INF/MANIFEST.MF
created: WEB-INF/
created: WEB-INF/classes/
created: WEB-INF/classes/org/
created: WEB-INF/classes/org/smartloli/
created: WEB-INF/classes/org/smartloli/kafka/
created: WEB-INF/classes/org/smartloli/kafka/eagle/
... ...
created: META-INF/maven/org.smartloli.kafka.eagle/kafka-eagle-web/
inflated: META-INF/maven/org.smartloli.kafka.eagle/kafka-eagle-web/pom.xml
inflated: META-INF/maven/org.smartloli.kafka.eagle/kafka-eagle-web/pom.properties
[2021-11-03 16:58:13] INFO: Port Progress: [##################################################] | 100%
[2021-11-03 16:58:16] INFO: Config Progress: [##################################################] | 100%
[2021-11-03 16:58:19] INFO: Startup Progress: [##################################################] | 100%
[2021-11-03 16:58:07] INFO: Status Code[0]
[2021-11-03 16:58:07] INFO: [Job done!]
Welcome to
__ __ ___ ____ __ __ ___ ______ ___ ______ __ ______
/ //_/ / | / __/ / //_/ / | / ____/ / | / ____/ / / / ____/
/ ,< / /| | / /_ / ,< / /| | / __/ / /| | / / __ / / / __/
/ /| | / ___ | / __/ / /| | / ___ | / /___ / ___ |/ /_/ / / /___ / /___
/_/ |_| /_/ |_|/_/ /_/ |_| /_/ |_| /_____/ /_/ |_|\____/ /_____//_____/
Version 1.4.8 -- Copyright 2016-2020
*******************************************************************
* Kafka Eagle Service has started success.
* Welcome, Now you can visit 'http://192.168.162.201:8048/ke'
* Account:admin ,Password:123456
*******************************************************************
* <Usage> ke.sh [start|status|stop|restart|stats] </Usage>
* <Usage> https://www.kafka-eagle.org/ </Usage>
*******************************************************************
eagle啟動完畢,
可以通過如下地址訪問:
http://192.168.162.201:8048/ke
通過上面配置的用戶,admin / 123456登陸,
登陸后界面如下;

另外還提供了一個精美的BScreen:

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/348315.html
標籤:其他
下一篇:《kafka問答100例 -7》如果Topic洗掉程序中有某臺Broker宕機,洗掉流程會正常進行嗎 ? |文末送書
