Linux_Kafka 安装笔记

来源:互联网 发布:软件用户说明书 编辑:程序博客网 时间:2024/06/16 17:22

环境:Vmware Workstation 10,CentOS-7-x86_64-DVD-1511.iso,Xshell 4.0,ip:192.168.216.140.

官方安装手册

[root@localhost ~]# wget http://mirrors.tuna.tsinghua.edu.cn/apache/kafka/0.10.2.1/kafka_2.12-0.10.2.1.tgz

[root@localhost ~]# tar -zxvf kafka_2.12-0.10.2.1.tgz -C /usr/local/

[root@localhost ~]# mv /usr/local/kafka_2.12-0.10.2.1/ /usr/local/kafka

使用自带的zookeeper

[root@localhost ~]# /usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &

[root@localhost ~]# vim /usr/local/kafka/config/server.properties

listeners=PLAINTEXT://192.168.216.140:9092
advertised.listeners=PLAINTEXT://192.168.216.140:9092

[root@localhost ~]# /usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties

[root@localhost ~]# /usr/local/kafka/bin/kafka-topics.sh –create –zookeeper localhost:2181 –replication-factor 1 –partitions 1 –topic test

[root@localhost ~]# /usr/local/kafka/bin/kafka-topics.sh –list –zookeeper localhost:2181

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
[2017-06-13 11:24:42,531] INFO Accepted socket connection from /0:0:0:0:0:0:0:1:40063 (org.apache.zookeeper.server.NIOServerCnxnFactory)
[2017-06-13 11:24:42,531] INFO Client attempting to establish new session at /0:0:0:0:0:0:0:1:40063 (org.apache.zookeeper.server.ZooKeeperServer)
[2017-06-13 11:24:42,533] INFO Established session 0x15c9f6d69020002 with negotiated timeout 30000 for client /0:0:0:0:0:0:0:1:40063 (org.apache.zookeeper.server.ZooKeeperServer)
test

[root@localhost ~]# /usr/local/kafka/bin/kafka-console-producer.sh –broker-list localhost:9092 –topic test

OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
My name is zhangsan.
[2017-06-13 11:27:35,380] INFO [Group Metadata Manager on Broker 0]: Removed 0 expired offsets in 0 milliseconds. (kafka.coordinator.GroupMetadataManager)
What is your name?

[root@localhost ~]# /usr/local/kafka/bin/kafka-console-consumer.sh –bootstrap-server localhost:9092 –topic test –from-beginning

My name is zhangsan.
What is your name?

注意:下面命令中“–”是两个“-”,csdn显示有误。

[root@localhost ~]# firewall-cmd –zone=public –add-port=9092/tcp –permanent

success

[root@localhost ~]# firewall-cmd –reload

success

原创粉丝点击