centos安装部署配置kafka

1、解压到目录

tar -zxvf kafka_2.13-2.8.2.tgz -C /usr/local/kafka

2.进入目录

cd /usr/local/kafka/kafka_2.13-2.8.2

3.查看版本(验证是否已解压)

bin/kafka-topics.sh --version

4.修改配置,注意:此配置中有一个默认的zookeeper的配置

vim config/server.properties

5.有三个配置要调整

#server.properties
 listeners=PLAINTEXT://:9092
 advertised.listeners=PLAINTEXT://<外网ip>:9092
 advertised.host.name=<内网ip>

6.示例配置

listeners=PLAINTEXT://:9092
 advertised.listeners=PLAINTEXT://8.219.68.237:9092
 advertised.host.name=127.0.0.1

7.启动zk

sh -x bin/zookeeper-server-start.sh -daemon config/zookeeper.properties

8、启动kafka

 #nohup /usr/local/kafka/kafka_2.13-2.8.2/bin/kafka-server-start.sh /usr/local/kafka/kafka_2.13-2.8.2/config/server.properties
 bin/kafka-server-start.sh config/server.properties &

 sh -x bin/kafka-server-start.sh  -daemon config/server.properties

9、停止kafka

#关闭kafka
 #/usr/local/kafka/kafka_2.13-2.8.2/bin/kafka-server-stop.sh /usr/local/kafka/kafka_2.13-2.8.2/config/server.properties
 bin/kafka-server-stop.sh config/server.properties

设置开机自动服务

vi /lib/systemd/system/kafka.service
[Unit]
Description=Apache Kafka server (broker)
After=network.target zookeeper.service
[Service]
Type=simple
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/1.8.0_391/bin"
User=root
Group=root
ExecStart=/usr/local/kafka2.12/bin/kafka-server-start.sh /usr/local/kafka2.12/config/server.properties
ExecStop=/usr/local/kafka2.12/bin/kafka-server-stop.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
systemctl enable kafka.service #加入开机启动
systemctl start kafka.service #启动
systemctl stop kafka.service #停止
systemctl status kafka.service #状态

创建topic

bin/kafka-topics.sh  --create --bootstrap-server 192.168.0.133:9092 --replication-factor 1 --partitions 1 --topic demo002
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值