标签:from 节点配置 stat 其他 producer style tran 生产 centos7
https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/
?
kafka同样依赖Java环境,由于和zookeeper在相同的机器上,之前已经安装过了,所有可以直接跳过Java环境安装
?
https://www.cnblogs.com/panwenbin-logs/p/10369402.html
?
系统版本 | centos7.7 |
kafka版本 | kafka_2.12-2.4.0.tgz |
zookeeper版本 | apache-zookeeper-3.5.6-bin.tar.gz |
jdk版本 | openjdk1.8 |
?
wget https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.4.0/kafka_2.12-2.4.0.tgz
tar xf kafka_2.12-2.4.0.tgz
mv kafka_2.12-2.4.0 /usr/local/kafka_2.12-2.4.0
cd /usr/local/
ln -s /usr/local/kafka_2.12-2.4.0 kafka
?
echo ‘export PATH=$PATH:/usr/local/kafka/bin/‘ >>/etc/profile
source /etc/profile
?
cd kafka/config/
mkdir /usr/local/kafka/data
cp server.properties server.properties-bak
vim server.properties
主要需要修改:
broker.id
listeners
log.dirs
zookeeper.connect
broker.id=1 #唯一
listeners=PLAINTEXT://172.16.150.154: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=/usr/local/kafka/data/kafka-logs #数据目录,kafka-logs会自动采集
num.partitions=3
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=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=172.26.103.56:2181,172.26.103.57:2181,172.26.103.58:2181 #zokeeper连接地址,以","为分割,如果是单点就写一个就行
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
?
kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties #后台运行
ss -lntup|grep 9092
jps
?
?
登录zookeeper验证
cd /usr/local/zookeeper/bin
登录zookeeper服务端
./zkCli.sh -server 127.0.0.1:2181
查看节点配置文件server.properties的 broker id的信息
get /brokers/ids/1
?
?
?
?
?
?
?
?
?
echo ‘export PATH=$PATH:/usr/local/kafka/bin/‘ >>/etc/profile
?
cd kafka/config/
cp server.properties server.properties-bak
vim server.properties
broker.id=1 #唯一
listeners=PLAINTEXT://172.16.150.154: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=/usr/local/kafka/data/kafka-logs #数据目录,kafka-logs会自动采集
num.partitions=3
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=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=172.26.103.56:2181,172.26.103.57:2181,172.26.103.58:2181 # zokeeper连接地址,以","为分割,如果是单点就写一个就行
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
?
其他节点配置相同,除以下内容:
broker.id=1 #唯一
listeners=PLAINTEXT://172.16.150.154:9092 #修改为本机地址
?
cd /usr/local/kafka_2.12-2.4.0/bin
./kafka-server-start.sh -daemon ../config/server.properties #后台运行
?
?
登录zookeeper验证
cd /usr/local/zookeeper/bin
登录zookeeper服务端
./zkCli.sh -server 127.0.0.1:2181
查看节点配置文件server.properties的 broker id的信息
get /brokers/ids/3
?
#154上创建一个生产者
[root@node01 ~]# cd /usr/local/kafka/bin/
[root@node01 bin]# ./kafka-topics.sh --create --zookeeper 172.16.150.154:2181 --replication-factor 1 --partitions 1 --topic Test
Created topic "Test".
[root@node01 bin]# ./kafka-console-producer.sh --broker-list 172.16.150.154:9092 --topic Test
#其他服务器上创建一个消费者
[root@node02 ~]# cd /usr/local/kafka/bin/
[root@node02 bin]# ./kafka-console-consumer.sh --bootstrap-server 172.16.150.155:9092 --topic Test --from-beginning
#启动成功后,在154上输入任意内容,在另一台机器上查看是否会同步显示
?
?
zookeeper及kafka监控工具
1.zookeeper监控工具(没有安装过,有需要请参考官方文档)
zookeeper监控工具地址:https://github.com/soabase/exhibitor
2.kafka监控工具
1)KafkaOffsetMonitor
2)kafka-manager
?
?
?
?
?
?
?
?
?
?
?
?
标签:from 节点配置 stat 其他 producer style tran 生产 centos7
原文地址:https://www.cnblogs.com/-luoke/p/12532661.html