大数据平台环境搭建——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安装配置
- 使用kafka自带的zookeeper(在/kafka/bin目录下)
#前台启动方式
[hadoop@master bin]$ ./zookeeper-server-start.sh ../config/zookeeper.properties
#后台启动方式
[hadoop@master bin]$ ./zookeeper-server-start.sh ../config/zookeeper.properties &
- 使用自己主机配置的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安装配置就先写到这里啦,有什么错误及添加的地方欢迎大家评论或者私信我,我会持续更新的。