KAFKA
先安装完zookeeper,小规模用可以用新版kafka自带的zookeeper。
下载
cd /usr/local
wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.7.0/kafka_2.12-2.7.0.tgz
#解压
tar -xzvf kafka_2.12-2.7.0.tgz
#重命名
mv kafka_2.12-2.7 kafka
修改配置
cd kafka/config
vim server.properties
advertised.listeners=PLAINTEXT://外网IP:9092
log.dirs=/usr/local/kafka/logs
启动(注意要先启动zk)
../bin/kafka-server-start.sh config/server.properties
常用命令:
#在kafka安装根目录
#启动
bin/kafka-server-start.sh -daemon config/server.properties
ps:-daemon是为了让在后台运行
#创建tocic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
#查询topic列表
bin/kafka-topics.sh --list --zookeeper localhost:2181
#启动 Producer
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
#启动 Consumer
bin/kafka-console-consumer.sh --bootstrap-server local:9092 --topic test --from-beginning
#topic的信息
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
KAFKA-EAGLE可视化界面
下载&解压
cd /usr/local
wget https://github.com/smartloli/kafka-eagle-bin/archive/v2.0.4.tar.gz
tar -xvf kafka-eagle-bin-1.2.4.tar.gz
mv kafka-eagle-bin-1.2.4 kafka-eagle
配置环境变量(需要配置java_home,yum安装看
https://blog.csdn.net/a704397849/article/details/103809206)
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64
export KE_HOME=/usr/local/kafka-eagle-bin-1.2.4/kafka-eagle-web-1.2.4
export PATH=$PATH:$KE_HOME/bin:$JAVA_HOME/bin
改好后更新配置
source /etc/profile
修改Kafka-Eagle配置文件
cd /usr/local/kafka-eagle/kafka-eagle-web-1.2.4
vi ./conf/system-config.properties
修改节点如下:
kafka.eagle.url=jdbc:sqlite:/usr/local/kafka-eagle/kafka-eagle-web-1.2.4/bin/db/ke.db
######################################
# multi zookeeper&kafka cluster list
######################################
#kafka.eagle.zk.cluster.alias=cluster1,cluster2
#cluster1.zk.list=tdn1:2181,tdn2:2181,tdn3:2181
#cluster2.zk.list=xdn10:2181,xdn11:2181,xdn12:2181
#单节点
kafka.eagle.zk.cluster.alias=cluster1
cluster1.zk.list=192.168.1.104:2181
创建数据库目录以及启动
cd /usr/local/kafka-eagle/kafka-eagle-web-1.2.4/bin
mkdir db
chmod +x ke.sh
./ke.sh start
启动成功打印日志如下;
*******************************************************************
* Kafka Eagle system monitor port successful...
*******************************************************************
[2020-02-07 17:05:57] INFO: Status Code[0]
[2020-02-07 17:05:57] INFO: [Job done!]
Welcome to
__ __ ___ ____ __ __ ___ ______ ___ ______ __ ______
/ //_/ / | / __/ / //_/ / | / ____/ / | / ____/ / / / ____/
/ ,< / /| | / /_ / ,< / /| | / __/ / /| | / / __ / / / __/
/ /| | / ___ | / __/ / /| | / ___ | / /___ / ___ |/ /_/ / / /___ / /___
/_/ |_| /_/ |_|/_/ /_/ |_| /_/ |_| /_____/ /_/ |_|\____/ /_____//_____/
Version 1.3.8
*******************************************************************
* Kafka Eagle Service has started success.
* Welcome, Now you can visit 'http://10.0.0.200:8048/ke'
* Account:admin ,Password:123456
*******************************************************************
* ke.sh [start|status|stop|restart|stats]
* https://www.kafka-eagle.org/
*******************************************************************
如果出现错误,请查看日志日志是否出问题
如果没问题,则直接登录
- http://host:8048/ke
- 默认用户名:admin
-
默认密码:123456
监控趋势图
Kafka系统默认是没有开启JMX端口的,所以Kafka Eagle的监控趋势图默认采用不启用的方式,即kafka.eagle.metrics.charts=false。如果需要查看监控趋势图,需要开启Kafka系统的JMX端口,设置该端口在$KAFKA_HOME/bin/kafka-server-start.sh脚本中,设置内容如下:
vim /opt/software/kafka-eagle/conf/system-config.properties
######################################
# enable kafka metrics
######################################
kafka.eagle.metrics.charts=true
开启JMX监控
eagle通过jmx收集一些指标,在使用jmx之前需要确保kafka开启了jmx监控
开启方法1:kafka启动时要添加JMX_PORT=9999
开启方法2:vim bin/kafka-server-start.sh
...
vi /opt/software/kafka/bin/kafka-server-start.sh
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
export KAFKA_HEAP_OPTS="-server -Xms2G -Xmx2G -XX:PermSize=128m -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:ParallelGCThreads=8 -XX:ConcGCThreads=5 -XX:InitiatingHeapOccupancyPercent=70"
# 这里的端口不一定非要设置成9999,端口只要可用,均可。
export JMX_PORT="9999"
#export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
fi
Kafka Eagle系统会自动获取这个JMX端口,采集结果如下:
配置文件参考链接:
https://www.cnblogs.com/weixiuli/p/6413109.html
集群部署
3台机器,分别是192.168.1.104,192.168.1.105,192.168.1.107
kafka配置文件加上
#三台机器必须不同
broker-id = 1
zookeeper.connect=192.168.88.21:2181,192.168.88.22:2181,192.168.88.23:2181
之后先启动zk集群,再启动kafka集群,启动完成后,登录eagle查看即可。