专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

Kafka集群搭建

1、 启动Server

http://kafka.apache.org/quickstart

For Kafka, a single broker is just a cluster of size one, so nothing much changes other than starting a few more broker instances.

# 下载kafka
[root@localhost kafka]# tar -xzf kafka_2.11-2.0.0.tgz
[root@localhost kafka]# cd kafka_2.11-2.0.0
[root@localhost kafka_2.11-2.0.0]# pwd
/usr/local/programs/kafka/kafka_2.11-2.0.0
[root@localhost kafka_2.11-2.0.0]# ls
bin  config  libs  LICENSE  logs  NOTICE  site-docs
[root@localhost kafka_2.11-2.0.0]#

# 启动zookeeper
[root@localhost kafka_2.11-2.0.0]# bin/zookeeper-server-start.sh config/zookeeper.properties &

# 启动一个Kafka Server
[root@localhost kafka_2.11-2.0.0]# bin/kafka-server-start.sh config/server.properties

# 创建包含多个broker(Kafka Server)的集群
[root@localhost kafka_2.11-2.0.0]# cp config/server.properties config/server-1.properties
[root@localhost kafka_2.11-2.0.0]# cp config/server.properties config/server-2.properties
[root@localhost kafka_2.11-2.0.0]# vim config/server-1.properties
    broker.id=1
    listeners=PLAINTEXT://:9093
    log.dirs=/tmp/kafka-logs-1
    zookeeper.connect=localhost:2181
[root@localhost kafka_2.11-2.0.0]# vim config/server-2.properties
    broker.id=2
    listeners=PLAINTEXT://:9094
    log.dirs=/tmp/kafka-logs-2
    zookeeper.connect=localhost:2181
[root@localhost kafka_2.11-2.0.0]# bin/kafka-server-start.sh config/server-1.properties &
[root@localhost kafka_2.11-2.0.0]# bin/kafka-server-start.sh config/server-2.properties &
[root@localhost kafka_2.11-2.0.0]# netstat -tnlp | grep 909
tcp6       0      0 :::9092                 :::*                    LISTEN      18663/java          
tcp6       0      0 :::9093                 :::*                    LISTEN      18998/java          
tcp6       0      0 :::9094                 :::*                    LISTEN      19332/java

# 创建一个主题
[root@localhost kafka_2.11-2.0.0]# bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

# 查看主题
[root@localhost kafka_2.11-2.0.0]# bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test
Topic:test      PartitionCount:1        ReplicationFactor:3     Configs:
        Topic: test     Partition: 0    Leader: 2       Replicas: 2,0,1 Isr: 2,1,0

# 发送消息
[root@localhost kafka_2.11-2.0.0]# bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
>Hello World
>Hello Java
>^C

# 接收消息
[root@localhost kafka_2.11-2.0.0]# bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic test
Hello World
Hello Java

2、 安装JDK

http://www.oracle.com/technetwork/java/javase/downloads/index.html

115_1.png

115_2.png

3、 Kafka Eagle

http://download.smartloli.org/

https://ke.smartloli.org/2.Install/2.Installing.html

https://ke.smartloli.org/3.Manuals/1.Dashboard.html

3.1、 设置KE_HOME环境变量

115_3.png

3.2、 修改配置文件

[root@localhost conf]# vim $KE_HOME/conf/system-config.properties
######################################
# multi zookeeper&kafka cluster list
######################################
kafka.eagle.zk.cluster.alias=cluster1
cluster1.zk.list=localhost:2181
#cluster2.zk.list=xdn10:2181,xdn11:2181,xdn12:2181

######################################
# zk client thread limit
######################################
kafka.zk.limit.size=25

######################################
# kafka eagle webui port
######################################
kafka.eagle.webui.port=8048

######################################
# kafka offset storage
######################################
kafka.eagle.offset.storage=kafka

######################################
# enable kafka metrics
######################################
kafka.eagle.metrics.charts=false

######################################
# alarm email configure
######################################
kafka.eagle.mail.enable=true
kafka.eagle.mail.sa=alert_sa
kafka.eagle.mail.username=alert_sa@163.com
kafka.eagle.mail.password=mqslimczkdqabbbg
kafka.eagle.mail.server.host=smtp.163.com
kafka.eagle.mail.server.port=25

######################################
# delete kafka topic token
######################################
kafka.eagle.topic.token=keadmin

######################################
# kafka sasl authenticate
######################################
kafka.eagle.sasl.enable=false
kafka.eagle.sasl.protocol=SASL_PLAINTEXT
kafka.eagle.sasl.mechanism=PLAIN

######################################
# kafka jdbc driver address
######################################
kafka.eagle.driver=com.mysql.jdbc.Driver
kafka.eagle.url=jdbc:mysql://10.123.52.189:3306/oh_coupon
kafka.eagle.username=devdb
kafka.eagle.password=d^V$0Fu!/6-<

3、3、 启动Eagle

[root@localhost kafka-eagle-web-1.2.3]# cd bin/
[root@localhost bin]# ls
ke.bat  ke.pid  ke.sh
[root@localhost bin]# chmod +x ke.sh
[root@localhost bin]# ./ke.sh start

115_4.png

4、 演示

http://192.168.101.5:8048/ke/

115_5.png

文章永久链接:https://tech.souyunku.com/21191

未经允许不得转载:搜云库技术团队 » Kafka集群搭建

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们