kafka单机版安装
程序员文章站
2022-05-27 17:00:07
...
zookeeper
下载并解压
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
tar -zxvf ./zookeeper-3.4.14.tar.gz
修改配置文件
cd ./zookeeper-3.4.14/conf/
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper
clientPort=2181
#上面都是默认的,下面这个是我加的,你的ip:2888:3888
server.1=standalone:2888:3888
配置环境变量
vim /etc/profile
#zk
export ZK_HOME=/usr/local/bigdata/zookeeper-3.4.14
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$SCALA_HOME/bin:$SPARK_HOME/bin:$ZK_HOME/bin:$KAFKA_HOME/bin
source /etc/profile
启动zk
zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/bigdata/zookeeper-3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看状态
zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/bigdata/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: standalone
kafka
解压
tar -zxvf kafka_2.11-0.11.0.2.tgz
修改配置
cd ./kafka_2.11-0.11.0.2/config/
vi server.properties
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://standalone:9092
其他的默认的就可以
配置环境变量
```bash
vim /etc/profile
#kafka
export KAFKA_HOME=/usr/local/bigdata/kafka_2.11-0.11.0.2
PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$SCALA_HOME/bin:$SPARK_HOME/bin:$ZK_HOME/bin:$KAFKA_HOME/bin
source /etc/profile
启动kafka
kafka-server-start.sh /usr/local/bigdata/kafka_2.11-0.11.0.2/config/server.properties &
会出现一堆日志,太多了,就不截图了
创建一个topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Created topic "test".
发送接收消息
用命令起一个消费者监听消息
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
起一个生产者发送消息
kafka-console-producer.sh --broker-list localhost:9092 --topic test
输入helloowrd
可以看到消费者接收到了
上一篇: centos7离线安装jdk
下一篇: linux下的压缩和解压