One of the introductory tutorials for Kafka: installation
One of the Kafka getting started tutorials: install. Note-content {font-family: 'Helvetica Neue', Arial,' Hiragino Sans GB', STHeiti, 'Microsoft YaHei',' WenQuanYi Micro Hei', SimSun, Song, sans-serif;} Kafka starter tutorials: install 1. Download the software on the official website
Http://kafka.apache.org/
two。 Install single-node kafkaa) create user kafka [root@tjtestrac1 ~] # useradd kafka [root@tjtestrac1 ~] # passwd kafkaChanging password for user kafka.New password: BAD PASSWORD: The password is shorter than 8 charactersRetype new password: passwd: all authentication tokens updated successfully.b) decompression package [kafka@tjtestrac1 ~] $lskafka_2.12-2.1.0.tgz [kafka@tjtestrac1 ~] $tar-xvf kafka_2.12-2.1.0.tgzc) configuration environment variable kafka _ home and java_ home[ Kafka @ tjtestrac1] $vi .bash _ profileexport KAFKA_HOME=/home/kafka/kafka_2.12-2.1.0export JAVA_HOME=/u02/cassandra/java/jdk1.8.0_162PATH=$PATH:$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin:$KAFKA_HOME/bin [kafka@tjtestrac1 ~] $source .bash _ profile 3. Start zookeeper Kafka component a) create a folder for zookeeper [kafka@tjtestrac1 config] $mkdir-p / home/kafka/zk b) modify kafka's built-in zk configuration file [kafka@tjtestrac1 config] $vi zookeeper.properties dataDir=/home/kafka/zk# the port at which the clients will connectclientPort=2181# disable the per-ip limit on the number of connections since this isa non-production configmaxClientCnxns=0c) launch zkkafka@tjtestrac1 config] $zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties & d) Check the background process [kafka@tjtestrac1 ~] $jps30323 QuorumPeerMain30660 Jps4. Start kafkaa) create a folder for kafka [kafka@tjtestrac1 ~] $mkdir-p / home/kafka/kfb) modify kafka's configuration file [kafka@tjtestrac1 config] $vi server.properties log.dirs=/home/kafka/kf c) start the kafka process [kafka@tjtestrac1 config] $kafka-server-start.sh $KAFKA_HOME/config/server.properties & d) view the background process [kafka@tjtestrac1 config] $jps30323 QuorumPeerMain4739 Kafka5414 Jps5. Create a topic topic [Kafka @ tjtestrac1 config] $kafka-topics.sh-- create-- zookeeper localhost:2181-- replication-factor 1-- partitions 1-- topic test [2018-11-22 17-17purr 27RV 47517] INFO Accepted socket connection from / 127.0.0.1-- Riv 58228 (org.apache.zookeeper.server.NIOServerCnxnFactory) [2018-11-22 1727RV-47519] INFO Client attempting to establish new session at / 127.0.0.1-58228 (org.apache.zookeeper.server.ZooKeeperServer) ) INFO Established session 0x10052ce304e0001 with negotiated timeout 30000 for client / 127.0.1 org.apache.zookeeper.server.ZooKeeperServer) [2018-11-22 17 org.apache.zookeeper.server.ZooKeeperServer] INFO Got user-level KeeperException when processing sessionid:0x10052ce304e0001 type:setData cxid:0x4 zxid:0x1f txntype:-1 reqpath:n/an Error Path:/config/topics/test Error:KeeperErrorCode = NoNode for / config/topics/test (org.apache.zookeeper.server.PrepRequestProcessor) Created topic "test". List the topics: [kafka@tjtestrac1 config] $kafka-topics.sh-- list-- zookeeper localhost:2181 [2018-11-22 17purl 29RV 31251] INFO Accepted socket connection from / 0VOVO Velcro 0VOVO VLU 0VOVO VLU 01VOULGULING 64976 (org.apache.zookeeper.server.NIOServerCnxnFactory) [2018-11-22 1729VG 31253] INFO Client attempting to establish new session at / 0VUL0VOREOGRAPHING 00VOREOREL 00LREL 1L (org.apache.zookeeper.server.ZooKeeperServer) ) [2018-11-22 17 org.apache.zookeeper.server.ZooKeeperServer 29 org.apache.zookeeper.server.ZooKeeperServer] INFO Processed session termination for sessionid: 0x10052ce304e0002 (org.apache.zookeeper.server.PrepRequestProcessor) [2018-11-22 17 purl 29] 31303] INFO Closed socket connection for client / 00purl 00Ru 0RU 0RU 0RU 00RO (org.apache.zookeeper.server.ZooKeeperServer) test [2018-11-22 17JV 29A 31302] INFO Processed session termination for sessionid: 0x10052ce304e0002 (org.apache.zookeeper.server.PrepRequestProcessor) [2018-11-22 17V 29] Which had sessionid 0x10052ce304e0002 (org.apache.zookeeper.server.NIOServerCnxn) 6. Start the producer to send data [kafka@tjtestrac1 ~] $kafka-console-producer.sh-- broker-list localhost:9092-- topic test > jason > comm on > test message7. Start the consumer to receive data [kafka@tjtestrac1 ~] $kafka-console-consumer.sh-- bootstrap-server localhost:9092-- topic test-- from-beginning [kafka@tjtestrac1 ~] $kafka-console-producer.sh-- broker-list localhost:9092-- topic test > jason > comm on > test message > next message