Zookeeper+kafka+kafka-eagle集群搭建实验

实验环境:

主机名IP地址安装软件操作系统
kafka-01192.168.3.1zookeeper-3.4.12 | kafka_2.11-2.4.0 | jdk-8u171-linux-x64 | kafka-eagle-bin-1.2.4Centos7.3
kafka-02192.168.3.2zookeeper-3.4.12 | kafka_2.11-2.4.0 | jdk-8u171-linux-x64Centos7.3
kafka-03192.168.3.3zookeeper-3.4.12 | kafka_2.11-2.4.0 | jdk-8u171-linux-x64Centos7.3

软件包地址:https://pan.baidu.com/s/1y4Kp_LRKtA68vOqdhfA9vA

kafka-eagle官网:https://www.kafka-eagle.org

配置准备环境:

#安装jdk,修改主机名,修改hosts文件

cat /etc/hosts

192.168.3.2 kafka-01
192.168.3.3 kafka-02
192.168.3.4 kafka-03

192.168.3.2 master

192.168.3.3 slave1

192.168.3.4 slave2

tar -zxvf jdk-8u171-linux-x64.tar.gz

mv jdk1.8.0_171 /usr/local/java

vim /etc/profile

export JAVA_HOME=/usr/local/java  #jdk安装目录
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
export JAVA_HOME JRE_HOME CLASS_PATH PATH

 source /etc/profile

部署Zookeeper集群 

tar -zxvf zookeeper-3.4.10.tar.gz

mv zookeeper-3.4.10 /usr/local/zookeeper

cd /usr/local/zookeeper/conf/

mv zoo_sample.cfg zoo.cfg

vim zoo.cfg

dataDir=/usr/local/zookeeper/data
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888 

cd /usr/local/zookeeper/

mkdir data && cd data

echo "1" > myid                         #这里注意后面的几台机器一次为2,3.......

cd /usr/local/zookeeper/bin

./zkServer.sh start

./zkServer.sh status

部署Kafka集群

tar -zxvf kafka_2.11-2.4.0.tgz

mv kafka_2.11-2.4.0 /usr/local/kafka

cd /usr/local/kafka

vim config/server.properties

# master为0修改
broker.id=0

#修改

advertised.host.name=kafka-01

listeners=PLAINTEXT://192.168.3.2:9092

advertised.listeners=PLAINTEXT://192.168.3.2:9092

num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs
num.partitions=40
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=24
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
# 连接
zookeeper.connect=kafka-01:2181,kafka-02:2181,kafka-03:2181  #修改
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
# 可删除topic
delete.topic.enable=true

bin/kafka-server-start.sh config/server.properties &

部署Kafka-eagle的WEB界面

tar -zxvf kafka-eagle-bin-1.2.4.tar.gz

cd kafka-eagle-bin-1.2.4/

tar -zxvf kafka-eagle-web-1.2.4-bin.tar.gz

mv kafka-eagle-web-1.2.4 /usr/local/kafka-eagle

vim /usr/local/kafka-eagle/conf/system-config.properties

######################################
# multi zookeeper&kafka cluster list
######################################
kafka.eagle.zk.cluster.alias=cluster1

#改
cluster1.zk.list=master:2181,slave1:2181,slave2:2181

######################################
# 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

######################################
# 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=mqslimczkdqabbbh
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=org.sqlite.JDBC

#改
kafka.eagle.url=jdbc:sqlite:/usr/local/kafka-eagle/db/ke.db
kafka.eagle.username=root 
kafka.eagle.password=testadad

cd /usr/local/kafka-eagle/bin/

vim ke.sh

KE_HOME=/usr/local/kafka-eagle                  #开头插入这段变量

chmod +x *

./ke.sh start 

 

访问“http://192.168.3.2:8048/ke”,账号密码“admin/123456”效果展示: 

测试集群

现在控制面版创建topic或者采用命令行

cd /usr/local/kafka/bin

./kafka-topics.sh --create --zookeeper 192.168.3.2:9092,192.168.3.3:9092,192.168.3.4:9092 --topic kafkatest --partitions 3 --replication-factor 1

生产数据

./kafka-console-producer.sh --broker-list 192.168.3.2:9092,192.168.3.3:9092,192.168.3.4:9092 --topic kafkatest 

> helloword

> this is test

ctrl+d结束

消费数据

./kafka-console-consumer.sh --bootstrap-server 192.168.3.2:9092 --topic kafkatest --from-beginning

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值