项目作者: Lispython

项目描述 :
Application for replication data between kafka clusters.
高级语言: Rust
项目地址: git://github.com/Lispython/kafka-replicator.git
创建时间: 2020-06-28T16:47:58Z
项目社区:https://github.com/Lispython/kafka-replicator

开源协议:MIT License

下载


Kafka replicator

Kafka Replicator is an easy to use tool for copying data between two Apache Kafka clusters with configurable re-partitionning strategy.

Data will be read from topics in the origin cluster and written to a topic/topics in the destination cluster according config rules.

Features

Lets start with an overview of features that exist in kafka-replicator:

  • Data replication: Real-time event streaming between Kafka clusters and data centers;
  • Schema replication: Copy schema from source cluster to destination;
  • Flexible topic selection: Select topics with configurable config;
  • Auto-create topics: Destination topics are automatically created for strict_p2p strategy;
  • Stats: The tool shows replication status;
  • Monitoring: Kafka replicator exports stats via prometheus.
  • Cycle detection

Use cases

  • Replicate data between Kafka clusters;
  • Aggregate record from several topics and put them into one;
  • Extend bandwidth for exist topic via repartitioning strategy.

Installation

System dependencies

  1. libsasl2-dev
  2. libssl-dev

Install from crates.io

If you have the Rust toolchain already installed on your local system.

  1. rustup update stable
  2. cargo install kafka-replicator

Compile and run it from sources

Clone the repository and change it to your working directory.

  1. git clone https://github.com/lispython/kafka-replicator.git
  2. cd kafka-replicator
  3. rustup override set stable
  4. rustup update stable
  5. cargo install

Usage

  1. RUST_LOG=info kafka-replicator /path/to/config.yml

Run it using Docker

  1. sudo docker run -it -v /replication/:/replication/ -e RUST_LOG=info lispython/kafka_replicator:latest kafka-replicator /replication/config.yml

Example config

  1. clusters:
  2. - name: cluster_1
  3. hosts:
  4. - replicator-kafka-1:9092
  5. - replicator-kafka-1:9092
  6. - name: cluster_2
  7. hosts:
  8. - replicator-kafka-2:9092
  9. clients:
  10. - client: cl_1_client_1
  11. cluster: cluster_1
  12. config: # optional
  13. message.timeout.ms: 5000
  14. auto.offset.reset: earliest
  15. - client: cl_2_client_1
  16. cluster: cluster_2
  17. routes:
  18. - upstream_client: cl_1_client_1
  19. downstream_client: cl_1_client_1
  20. upstream_topics:
  21. - 'topic1'
  22. downstream_topic: 'topic2'
  23. repartitioning_strategy: random # strict_p2p | random
  24. upstream_group_id: group_22
  25. show_progress_interval_secs: 10
  26. limits:
  27. messages_per_sec: 10000
  28. number_of_messages:
  29. - upstream_client: cl_1_client_1
  30. downstream_client: cl_2_client_1
  31. upstream_topics:
  32. - 'topic2'
  33. downstream_topic: 'topic2'
  34. repartitioning_strategy: strict_p2p
  35. upstream_group_id: group_22
  36. show_progress_interval_secs: 10
  37. - upstream_client: cl_2_client_1
  38. downstream_client: cl_1_client_1
  39. upstream_topics:
  40. - 'topic2'
  41. downstream_topic: 'topic3'
  42. repartitioning_strategy: strict_p2p # strict_p2p | random
  43. default_begin_offset: earliest # optional
  44. upstream_group_id: group_2
  45. show_progress_interval_secs: 10
  46. observers:
  47. - client: cl_1_client_1
  48. name: "my name"
  49. group_id: group_name # used for remaining metrics
  50. topics: # filter by topics
  51. - 'topic1'
  52. - 'topic2'
  53. fetch_timeout_secs: 5 # default: 5
  54. fetch_interval_secs: 5 # default: 60
  55. show_progress_interval_secs: 10 # default: 60
  56. - client: cl_2_client_1
  57. topic: 'topic3'
  58. topics:
  59. - 'topic2'
  60. show_progress_interval_secs: 5
  61. - client: cl_1_client_1
  62. topic: 'topic1'
  63. topics: [] # fetch all topics

Options describing

Root config options:

  • clusters - are a list of Kafka Clusters
  • clients - are a list of configurations for consumers
  • routes - are a list of replication rules
  • observers - are a list of observers

Contributing

Any suggestion, feedback or contributing is highly appreciated. Thank you for your support!