Skip to content

Commit 80c8b80

Browse files
committed
Added role role_kafka_mirrormaker
1 parent d5112d3 commit 80c8b80

File tree

16 files changed

+234
-23
lines changed

16 files changed

+234
-23
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: all up-dc1 up-dc2 up provision-dc1 provision-dc2 provision restart-dc1 restart-dc2 restart brokers topics demo elastic_health elastic_indices elastic_allocation elastic all-dc1 all-dc2
22
.DEFAULT_GOAL := all
33

4-
all: all-dc1 all-dc2 kafka-demo
4+
all: all-dc1 all-dc2 kafka-demo
55

66
all-dc1: up-dc1 provision-dc1 restart-dc1
77

@@ -68,3 +68,6 @@ restart: restart-dc1 restart-dc2
6868
kafka-demo:
6969
ansible-playbook -i vagrant/inventory/hosts vagrant/ansible-playbook_demo_script.yml --limit "dc1"
7070
ansible-playbook -i vagrant/inventory/hosts vagrant/ansible-playbook_demo_script.yml --limit "dc2"
71+
72+
mirrormaker:
73+
ansible-playbook -i vagrant/inventory/hosts vagrant/ansible-playbook.yml --tags "mirrormaker"

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This Makefile contains several options to control the environment.
2727
The most common options have been described below:
2828

2929
* make (without arguments)
30-
Will spin up a single DC setup. After spinning up the VMs for a single DC setup Ansible will be automatically called to provision the VMs.
30+
Will spin up a dual DC setup. After spinning up the VMs for a the DCs Ansible will be automatically called to provision the VMs.
3131

3232
* make [up-dc1 | up-dc2]
3333
Will only spin up either dc1 or dc2. No Ansible scripting will be done.
@@ -42,6 +42,9 @@ Requires Vms to already be up.
4242
* make provision
4343
Will provision both dc1 and dc2.
4444

45+
* make mirrormaker
46+
Will provision a MirrorMaker instance on the TARGET DC. In this case the process will be started on DC2. It will consume from DC1 and act as a producer for DC2.
47+
4548

4649

4750
# Regarding port numbers that Kafka uses
@@ -92,3 +95,30 @@ Hint: Some lines were ellipsized, use -l to show in full.
9295
[vagrant@kafka_broker_01 ~]$
9396
9497
```
98+
99+
100+
# MirrorMaker
101+
102+
An additional service "confluence-mirrormaker" has been added. This newly added service can be managed through the regular systemctl commands.
103+
104+
Example:
105+
106+
```
107+
[vagrant@dc2_kafka_workernode_01 ~]$ sudo systemctl status confluent-mirrormaker -l
108+
● confluent-mirrormaker.service - Apache Kafka - MirrorMaker
109+
Loaded: loaded (/usr/lib/systemd/system/confluent-mirrormaker.service; static; vendor preset: disabled)
110+
Active: active (running) since Fri 2018-09-21 11:28:37 UTC; 2min 52s ago
111+
Main PID: 14189 (java)
112+
CGroup: /system.slice/confluent-mirrormaker.service
113+
└─14189 java -Xmx256M -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dkafka.logs.dir=/var/log/kafka -Dlog4j.configuration=file:/etc/kafka/tools-log4j.properties -cp /bin/../share/java/kafka/*:/bin/../share/java/confluent-support-metrics/*:/usr/share/java/confluent-support-metrics/* kafka.tools.MirrorMaker --consumer.config /etc/kafka/consumer_dc1_to_dc2.properties --producer.config /etc/kafka/producer_dc1_to_dc2.properties --num.streams 3 --abort.on.send.failure true --whitelist test test2 test3 test4 test5
114+
115+
Sep 21 11:28:37 dc2_kafka_workernode_01 systemd[1]: Started Apache Kafka - MirrorMaker.
116+
Sep 21 11:28:37 dc2_kafka_workernode_01 systemd[1]: Starting Apache Kafka - MirrorMaker...
117+
[vagrant@dc2_kafka_workernode_01 ~]$
118+
119+
```
120+
121+
*NOTE!!!*
122+
Do NOT start MirrorMaker on BOTH DCs. This will cause a neverending replication loop between both Kafka clusters!
123+
MirrorMaker does NOT have support for preventing this.
124+
Confluent Replicator is needed if you want to replicate both ways!

vagrant/ansible-playbook.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@
4343
- import_playbook: ansible-playbook_import_elasticsearch_singlenode.yml
4444
tags:
4545
- elasticsearch
46+
47+
# 8) Setting up MirrorMaker
48+
- import_playbook: ansible-playbook_import_mirrormaker.yml
49+
tags:
50+
- mirrormaker
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
###
2+
### Set up the hostname
3+
### Done in Ansible because of Vagrant race condition between setting both IP addresses and hostname
4+
5+
- hosts: kafka_brokers, kafka_worker_nodes
6+
remote_user: vagrant
7+
become: true
8+
become_user: root
9+
become_method: sudo
10+
gather_facts: true
11+
12+
roles:
13+
- role: role_kafka_mirrormaker

vagrant/group_vars/all

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ zookeeper_datadir: "/var/lib/zookeeper"
3838
kafka_zookeeper_connect: "
3939
{%- for node in vars['ansible_play_hosts'] | intersect(groups['kafka_brokers']) -%}
4040
{{ node }}:{{ port_zookeeper }}{% if not loop.last %},{% endif %}
41-
{% endfor%}
41+
{%- endfor%}
4242
"
4343

4444
# Zookeeper multiline server config in zookeeper.properties file
@@ -55,21 +55,21 @@ zookeeper_properties_server_multiline_config: "{% for server in vars['ansible_pl
5555
kafka_bootstrap_servers: "
5656
{%- for node in vars['ansible_play_hosts'] | intersect(groups['kafka_brokers']) -%}
5757
{{ node }}:{{ port_kafka_broker }}{% if not loop.last %},{% endif %}
58-
{% endfor%}
58+
{%- endfor %}
5959
"
6060

6161
# Example content: "172.28.129.201, 172.28.129.202, 172.28.129.203 "
6262
kafka_broker_ips: "
6363
{%- for node in vars['ansible_play_hosts'] | intersect(groups['kafka_brokers']) -%}
6464
{{ node }}{% if not loop.last %},{% endif %}
65-
{% endfor%}
65+
{%- endfor %}
6666
"
6767

6868
# Example content: "172.28.129.204, 172.28.129.205 "
6969
kafka_workernode_ips: "
7070
{%- for node in vars['ansible_play_hosts'] | intersect(groups['kafka_worker_nodes']) -%}
7171
{{ node }}{% if not loop.last %},{% endif %}
72-
{% endfor%}
72+
{%- endfor %}
7373
"
7474

7575
###

vagrant/group_vars/kafka_worker_nodes

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,64 @@ elastic_sink_name: 'elastic_sink_connector'
6161

6262

6363
###
64-
### MirrorMaker
64+
### MirrorMaker "confluent-mirrormaker" systemctl service
65+
### Note: only needs to run at the TARGET destination
6566
###
6667

67-
### Note:
68-
### only needs to run at the TARGET destination
69-
7068
### Config files
7169
mirrormaker_consumer_config: "/etc/kafka/consumer_dc1_to_dc2.properties"
7270
mirrormaker_producer_config: "/etc/kafka/producer_dc1_to_dc2.properties"
7371

7472
### Space separated list of topics needed to be replicated
75-
mirrormaker_topic_whitelist: "test"
73+
mirrormaker_topic_whitelist: "test test2 test3 test4 test5"
74+
75+
# Number of parallel streams
76+
mirrormaker_num_streams: "3"
77+
mirrormaker_abort_on_failure: "true"
78+
79+
80+
###
81+
### MirrorMaker consumer & producer config files
82+
### Note: only needs to run at the TARGET destination
83+
###
84+
85+
mirrormaker_log4j_rootLogger: "WARN, stderr, file"
86+
87+
### Variables for SOURCE target (aka: dc1)
88+
89+
# Example content: "172.28.129.201:9092,172.28.129.202:9092,172.28.129.203:9092"
90+
mirrormaker_source_bootstrap_servers: "
91+
{%- for node in groups['dc1_kafka_brokers'] -%}
92+
{{ node }}:{{ port_kafka_broker }}{% if not loop.last %},{% endif %}
93+
{%- endfor %}
94+
"
95+
96+
mirrormaker_source_group_id: "mirrormaker-group-source"
97+
mirrormaker_source_client_id: "mirror_maker_consumer"
98+
mirrormaker_source_exclude_internal_topics: "true"
99+
100+
101+
### Variables for DESTINATION target (aka: dc2)
102+
103+
# Example content: "172.28.129.221:9092,172.28.129.222:9092,172.28.129.223:9092"
104+
mirrormaker_target_bootstrap_servers: "
105+
{%- for node in groups['dc2_kafka_brokers'] -%}
106+
{{ node }}:{{ port_kafka_broker }}{% if not loop.last %},{% endif %}
107+
{%- endfor %}
108+
"
109+
110+
# (valid values are none, gzip, snappy, or lz4)
111+
mirrormaker_target_compression_type: "none"
112+
mirrormaker_target_client_id: "mirror_maker_producer"
113+
mirrormaker_target_max_in_flight_requests_per_connection: "1"
114+
mirrormaker_target_retries: "Int.MaxValue"
115+
mirrormaker_target_acks: "all"
116+
mirrormaker_target_block_on_buffer_full: "true"
117+
118+
# Note that enabling idempotence requires
119+
# max.in.flight.requests.per.connection to be less than or equal to 5,
120+
# retries to be greater than 0 and
121+
# acks must be 'all'.
122+
# If these values are not explicitly set by the user, suitable values will be chosen.
123+
# If incompatible values are set, a ConfigException will be thrown.
124+
mirrormaker_target_enable_idempotence: "true"

vagrant/roles/role_kafka_mirrormaker/defaults/main.yml

Whitespace-only changes.

vagrant/roles/role_kafka_mirrormaker/files/main.yml

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

vagrant/roles/role_kafka_mirrormaker/meta/main.yml

Whitespace-only changes.

0 commit comments

Comments
 (0)