centos7安装配置kafka并设置开机自启

把kafka_2.10-0.10.2.0.tgz放到/usr/local文件夹下

解压

tar -zxvf kafka_2.10-0.10.2.0.tgz

解压得到的文件夹重命名为kafka

mv kafka_2.10-0.10.2.0 kafka

进入kafka配置文件的文件夹中

cd kafka/config

修改server的配置文件

vim server.properties

更改配置为自己ip地址,端口为9092

listeners=PLAINTEXT://192.168.30.11:9092

在kafka的目录下后台启动zookeeper和kafka服务

nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &

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

运行了之后查看kafka进场有无启动

ps -ef | grep kafka

两个进程都有则代表kafka安装成功

设置kafka开机自启

进入/lib/systemd/system目录下

新建zookeeper.service

vim zookeeper.service

[Unit]

Description=Zookeeper service

After=network.target

[Service]

Type=simple

Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/bin"

User=root

Group=root

ExecStart=/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties

ExecStop=/usr/local/kafka/bin/zookeeper-server-stop.sh

Restart=on-failure

[Install]

WantedBy=multi-user.target

新建kafka.service

vim 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/bin"

User=root

Group=root

ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties

ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh

Restart=on-failure

[Install]

WantedBy=multi-user.target

保存退出之后执行systemctl daemon-reload

systemctl enable zookeeper

systemctl enable kafka

systemctl start zookeeper

systemctl start kafka

开机自启设置完毕

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值