README.adoc 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. == What you need? ==
  2. * Java 17 (or 21) SDK
  3. * Streams for Apache Kafka 2.7.0 (https://developers.redhat.com/products/streams-for-apache-kafka/download/)
  4. * Zookeeper and Broker Configuration (in this directory)
  5. * some sort of IDE
  6. == What to do with it? ==
  7. * Create a working directory for the demos.
  8. * Extract amq-streams.zip to that directory
  9. ** (rename `kafka_2.13-3.7.0.redhat-00007` to `kafka` for ease of use)
  10. * Place the config files into the same directory (next to `kafka`).
  11. After setup, your working directory should look like this:
  12. [subs="+quotes"]
  13. ----
  14. $ *ls -l*
  15. total 32
  16. -rw-r--r--@ 1 johndoe staff 926 10 Sep 14:31 broker0.properties
  17. -rw-r--r--@ 1 johndoe staff 926 10 Sep 14:31 broker1.properties
  18. -rw-r--r--@ 1 johndoe staff 926 10 Sep 14:31 broker2.properties
  19. drwxr-xr-x@ 9 johndoe staff 288 10 Sep 14:36 kafka/
  20. -rw-r--r--@ 1 johndoe staff 101 10 Sep 14:31 zookeeper.properties
  21. ----
  22. == How to start and stop the services? ==
  23. Start services (each in a separate window):
  24. * `./kafka/bin/zookeper-server-start.sh zookeeper.properties`
  25. * `./kafka/bin/kafka-server-start.sh broker0.properties`
  26. * `./kafka/bin/kafka-server-start.sh broker1.properties`
  27. * `./kafka/bin/kafka-server-start.sh broker2.properties`
  28. Stop the services in reverse order (broker2 first, etc.)
  29. == How to use the cluster? ==
  30. Use any of the following listeners as your bootstrap server:
  31. * `localhost:9092`
  32. * `localhost:9192`
  33. * `localhost:9292`
  34. You can also use all, or some, of them in a comma-separated list:
  35. `kafka.bootstrap.servers = localhost:9092,localhost:9192,localhost:9292`
  36. == Managing Topics ==
  37. You can create, delete, and alter topics with the `kafka-topics.sh` command.
  38. Creating a topic:
  39. [subs="+quotes"]
  40. ----
  41. $ *./kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \*
  42. *--topic sample-topic --partitions 9 \*
  43. *--replication-factor 3 --config min.insync.replicas=2 --create*
  44. ----
  45. Displaying a topic's configuration:
  46. [subs="+quotes"]
  47. ----
  48. $ *./kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \*
  49. *--topic sample-topic --describe*
  50. Topic: sample-topic TopicId: _zItfNPHS9Wzuzo2lh2CdA PartitionCount: 9
  51. ReplicationFactor: 3 Configs: min.insync.replicas=2
  52. Topic: sample-topic Partition: 0 Leader: 0 Replicas: 0,1,2 Isr: 1,2,0
  53. Topic: sample-topic Partition: 1 Leader: 1 Replicas: 1,2,0 Isr: 1,2,0
  54. Topic: sample-topic Partition: 2 Leader: 2 Replicas: 2,0,1 Isr: 1,2,0
  55. Topic: sample-topic Partition: 3 Leader: 0 Replicas: 0,1,2 Isr: 1,2,0
  56. Topic: sample-topic Partition: 4 Leader: 1 Replicas: 1,2,0 Isr: 1,2,0
  57. Topic: sample-topic Partition: 5 Leader: 2 Replicas: 2,0,1 Isr: 1,2,0
  58. Topic: sample-topic Partition: 6 Leader: 0 Replicas: 0,1,2 Isr: 1,2,0
  59. Topic: sample-topic Partition: 7 Leader: 1 Replicas: 1,2,0 Isr: 1,2,0
  60. Topic: sample-topic Partition: 8 Leader: 2 Replicas: 2,0,1 Isr: 1,2,0
  61. ----
  62. Deleting a topic:
  63. [subs="+quotes"]
  64. ----
  65. $ *./kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 \*
  66. *--topic sample-topic --delete*
  67. ----