CentOS7搭建Kafka单机环境及基础操作

CentOS7搭建Kafka单机环境及基础操作

前提

安装Kafka前需要先安装zookeeper集群

Kafka安装

解压

tar -zxvf kafka_2.8.0-0.8.0.tar.gz

修改配置

cd /usr/local/hadoop/kafka_2.8.0-0.8.0/config

vim server.properties

 

 

 

listeners=PLAINTEXT://:9092

 

advertised.listeners=PLAINTEXT://192.168.63.81:9092

 

log.dirs=/opt/kafka/kafka_2.12-2.3.0/logs

 

zookeeper.connect=localhost:2181,localhost:2182,localhost:2183

 

启动kafka

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

 

后台运行  

./kafka-server-start.sh -daemon ../config/server.properties

 

Jps 查看进程

 

---new version--

 

./kafka-topics.sh --create --zookeeper 192.168.63.81:2181,192.168.63.81:2182,192.168.63.81:2183 --replication-factor 1 --partitions 1 --topic test

 

 

./kafka-topics.sh --list --zookeeper 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183

 

 

./kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic test

 

 

./kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic test --from-beginning

posted @ 2020-08-04 14:33  散落人间  阅读(337)  评论(0编辑  收藏  举报
interface food{} class A implements food{} class B implements food{} class C implements food{} public class StaticFactory { private StaticFactory(){} public static food getA(){ return new A(); } public static food getB(){ return new B(); } public static food getC(){ return new C(); } } class Client{ //客户端代码只需要将相应的参数传入即可得到对象 //用户不需要了解工厂类内部的逻辑。 public void get(String name){ food x = null ; if ( name.equals("A")) { x = StaticFactory.getA(); }else if ( name.equals("B")){ x = StaticFactory.getB(); }else { x = StaticFactory.getC(); } } }