• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

一、拉取镜像

码头工人拉wurstmeister/动物园管理员

码头工人拉伍斯特梅斯特/卡夫卡

二、检查码头工人-撰写

docker-compose -v

三、创建docker-compose.yml文件

CD/data mkdir docker-compose CD docker-compose

触摸docker-compose.yml

添加内容

版本: '1 '

服务:

zookeeper:

图片:"动物园管理员"

主机名:"动物园管理员"

'容器名称: '动物园管理员'

卡夫卡:

图像: '伍斯特梅斯特/卡夫卡'

主机名: '卡夫卡'

'容器名称: '卡夫卡'

端口:

- '9092:9092'

环境:

卡夫卡_广告_主机_名称:卡夫卡

卡夫卡_动物园管理员_连接:动物园管理员:2181

#设置网络,名为当地的

网络:

本地:

驱动程序:桥

四、进入该文件所在目录执行

CD/数据/docker-撰写

码头工人-撰写构建

五、启动服务

码头工人-撰写向上-d

六、查看容器

docker ps

七、进入容器之中

docker exec -it卡夫卡聚会

八、创建主题

卡夫卡-主题。sh-create-zookeeper zookeeper :2181-复制-因子1-分区1-主题mykafka

执行后输出创造了话题《卡夫卡》.表示成功

九、查看主题

卡夫卡-话题。动物园管理员:2181

十、创建生产者

卡夫卡-控制台-制片人。sh-经纪人-名单卡夫卡:9092-主题麦卡夫卡

十一、查看主题内容

卡夫卡-控制台-消费者。服务器Kafka :9092-主题麦卡夫卡-从头开始

转载自:

https://www.jianshu.com/p/16e4fb821fa8

备注:

经常抛出找不到主机卡夫卡的问题,我的做法是更改/etc/hosts的域名配置文件,增加一行

卡夫卡

我的验证的爪哇岛脚本:

包com。举例。一个。卡夫卡;

导入Java。util。属性;

导入组织。阿帕奇。卡夫卡。客户。制片人。制片人;

导入组织。阿帕奇。卡夫卡。客户。制片人。kafkaproducer

导入组织。阿帕奇。卡夫卡。客户。制片人。制片人记录;

导入org。阿帕奇。卡夫卡。常见。序列化。字符串序列化程序;

//示例地址: https://www。yii Bai。com/Kafka/Apache _ Kafka _ simple _ producer _ example。超文本标记语言

公共类简单生产者{

公共静态void main(String[] args)引发异常{

//将topicName赋给字符串变量

String topicName=' mykafka

//为属性创建实例以访问生成器配置

属性属性=新属性

s(); //Assign localhost id props.put("bootstrap.servers", "localhost:9092"); //Set acknowledgements for producer requests. props.put("acks", "all"); //If the request fails, the producer can automatically retry, props.put("retries", 0); //Specify buffer size in config props.put("batch.size", 16384); //Reduce the no of requests less than 0 props.put("linger.ms", 1); //The buffer.memory controls the total amount of memory available to the producer for buffering. props.put("buffer.memory", 33554432); props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer","org.apache.kafka.common.serialization.StringSerializer"); Producer<String, String> producer = new KafkaProducer <String, String>(props); for (int i = 8; i < 19; i++) producer.send(new ProducerRecord<String, String>(topicName, Integer.toString(i), Integer.toString(i))); System.out.println("Message sent successfully"); producer.close(); } }

 

 

 

TRANSLATE with x English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
  TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back
Link to comment
Share on other sites