[大数据技术与应用省赛学习记录五]——模块一(Kafka安装配置)

本文详细介绍了如何在大数据平台环境中搭建Kafka,包括下载与安装、server.properties配置、Zookeeper的配置与启动,以及Kafka服务器的启动流程。重点在于实战步骤和常见问题解决。
摘要由CSDN通过智能技术生成

大数据平台环境搭建——Kafka安装配置

一、下载及安装Kafka

[大数据技术与应用省赛学习记录一]——软件准备
压缩看参考前期hadoop与spark的相关博客
[大数据技术与应用省赛学习记录二]——模块一(HADOOP完全分布式集群搭建)
[大数据技术与应用省赛学习记录三]——模块一(SPARK安装配置)

二、相关配置

server.properties ——在/kafka/config目录下

broker.id=4#myid中是几这就写几
port=9092
host.name=master#主机名
advertised.host.name=master#主机名
delect.topic.enable=true #删除topic的参数
advertised.listeners=PLAINTEXT://master:9092#修改为自己的主机名
log.dirs=/software/kafka/logs #log存放位置
num.partitions=3#分区数
zookeeper.connect=master:2181,hadoop1:2181,hadoop2:2181:hadoop3:2181

因为使用kafka当中会使用到zookeeper,所以这里我们配置以下zookeeper
这里使用zookeeper有两种方法

Zookeeper安装配置

  1. 使用kafka自带的zookeeper(在/kafka/bin目录下)
#前台启动方式
[hadoop@master bin]$ ./zookeeper-server-start.sh ../config/zookeeper.properties
#后台启动方式
[hadoop@master bin]$ ./zookeeper-server-start.sh ../config/zookeeper.properties &
  1. 使用自己主机配置的zookeeper

①下载安装zookeeper
zookeeper地址,安排!
相关安装、解压、更名步骤同之前hadoop方式
②环境配置

export ZK_HOME=/software/zookeeper
export PATH=${ZK_HOME}/bin:$PATH

Esc:wq 退出保存后记得要source以下,不然不会生效;

[hadoop@master ~]$ source /etc/profile

③修改zookeep配置文件

[hadoop@master ~]$ cd /software/zookeeper/conf
[hadoop@master conf]$ cp zoo_sample.cfg zoo.cfg
[hadoop@master conf]$ vim ./zoo.cfg

参考内容:

server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888
server.4=master:2888:3888
#修改为你的集群主机名,端口号有好多版本,不想用这个可以参考其他博主的。
#要记住server后的序号对应相关的主机名
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/software/zookeeper/zkdata 
 #该文件夹需要自己创建
# the port at which the clients will connect
admin.serverPort=8080
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

④创建文件夹(根据zoo.cfg文件)
在这里插入图片描述

[hadoop@master conf]$ mkdir zkdata

⑤在文件夹中创建myid文件

[hadoop@master conf] vim ./zkdata/myid 
#进入后将zoo.cfg文件中与主机名相对应的server序号写入myid文件中

⑥分发至开发端,并进行简单修改

[hadoop@master conf]$ cd /software
[hadoop@master software]$ scp -r ./zookeeper hadoop1:/software #示例仅供参考
#格式: scp -r 所要发送文件的路径 收文件的路径
#使用前提 安装ssh并连通后方可使用,不会安装ssh的可以看我博客第二个(hadoop完全分布式)

分发完后,使用ssh 快速修改

[hadoop@master conf]$ ssh hadoop1
hadoop@hadoop1:~$ vi /software/zookeeper/zkdata/myid

我设置的hadoop对应的是1,所以在里面打个1就好。其他开发端同理;
在这里插入图片描述
⑦启动zookeeper(每台都要分别启动)

[hadoop@master conf]$ zkServer.sh start
#命令未找到可以查看是否配了全局,在或者没有source生效呢。
[hadoop@master conf]$ zkServer.sh status
#查看当前zookeeper状态

在这里插入图片描述在这里插入图片描述

⑧确认zookeeper开启
要有QuorumPeerMain就是zookeeper在启动

[hadoop@master conf]$ jps

在这里插入图片描述在zookeeper过程的一些问题

[hadoop@master bin]$ zkServer.sh status
ZooKeeper JMX enabled by default
#问题:
Using config: /software/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Error contacting service. It is probably not running.

解决方法:

1.检查zkServer文件与zoo.cnf文件以及myid文件
2.创建pid文件夹与相关pid文件链接至zkServer.sh

三、启动Kakfa

#前台启动方式
[hadoop@master bin]$ ./kafka-server-start.sh ../config/kafka.properties
#后台启动方式
[hadoop@master bin]$ ./kafka-server-start.sh ../config/kafka.properties &

本期的KAFKA安装配置就先写到这里啦,有什么错误及添加的地方欢迎大家评论或者私信我,我会持续更新的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ench77

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值