Kafka安装教程
kafka
·
KAFKA
1、安装JDK
(1)解压tar.gz
tar -zxvf jdk-8u321-linux-x64.tar.gz
(2)配置环境变量
export JAVA_HOME=/opt/jdk/jdk1.8.0_321
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:${PATH}
2、安装Zookeeper
(1)解压zookeeper安装包
tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz
(2)将conf/zoo_sample.cfg复制为zoo.cfg,并修改zk的数据存储位置
#将zoo_sample.cfg复制一份,重命名为zoo.cfg
cp conf/zoo_sample.cfg conf/zoo.cfg
#在解压目录下新建目录data
mkdir data
#data下新建文件myid
touch data/myid
#编辑myid,写一个1。myid在zkServer集群中才有用,单机版zkServer可以不配置
vim data/myid
vim conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000 #心跳间隔,每隔2000ms即2s发送一次心跳
# The number of ticks that the initial
# synchronization phase can take
initLimit=10 #10*2s=20s,如果连续10次即20s内没有收到某个服务节点的心跳,就认为该节点挂掉了
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5 #follower从leader同步数据时,发送同步请求后,如果5个心跳时间即10s内没有收到leader的确认应答,就认为本次同步请求失败
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
#dataDir=/tmp/zookeeper
dataDir=/usr/local/apache-zookeeper-3.6.0-bin/data #数据存储位置
# the port at which the clients will connect
clientPort=2181 #zk client与zk server通信使用的端口号
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60 #zk client的最大数量
(3)防火墙开放指定端口给zk client连接
firewall-cmd --add-port=2181/tcp --zone=public --permanent
firewall-cmd --reload
(4)启动
./zkServer.sh start
start #启动
stop #停止
restart #重启
status #查看状态
version #查看zk server的版本
(5)测试
./zkCli -server 192.168.1.9:2181
3、安装Kafka
(1)解压kafka安装包
tar -zxvf kafka_2.12-3.0.0.tgz
(2)修改/conf/server.properties
log.dirs=/opt/moudle/kafka/datas
(3)启动
./kafka-server-start.sh -daemon ../config/server.properties
(4)创建topic
./kafka-topics.sh --bootstrap-server localhost:9092 --topic test --create --replication-factor 1 --partitions 1
(5)启动消费端
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test
(6)启动生产者
./kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test
更多推荐
已为社区贡献1条内容
所有评论(0)