-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfiguring Kafka on EC2
71 lines (39 loc) · 1.93 KB
/
Configuring Kafka on EC2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Configuring KAFKA on EC2
---------------------
Launch instance of EC2 and make a note of public and private IPs of those instances
broker ip
172.31.43.18
35.161.163.235
consumer ip
172.31.37.164
18.236.96.59
First configure java in the EC2 instances.
1)Running zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
Before running the kafka server, we have to set the server.properties in config folder of kafka, we have to add internal IP(private IP) in the properties file
2)Running kafka server
bin/kafka-server-start.sh config/server.properties
If we try this command, then we will face the memory issue, so we can use the following commands to overcome the issue
export KAFKA_HEAP_OPTS="-Xmx512M -Xms512M"
KAFKA_HEAP_OPTS="-Xmx512M -Xms512M" bin/kafka-server-start.sh config/server.properties
3)Create a topic (Run the below command in kafka directory)
bin/kafka-topics.sh --create --zookeeper <zookeepr ip aaddress>:2181 --replication-factor 1 --partitions 1 --topic twitterdata
bin/kafka-topics.sh --create --zookeeper 172.31.43.18:2181 --replication-factor 1 --partitions 1 --topic twitterdata
4)We can now see the topic if we run the list topic command
bin/kafka-topics.sh --list --zookeeper 172.31.43.18:2181
5)create a producer
bin/kafka-console-producer.sh --broker-list 172.31.43.18:9092 --topic twitterdata
6)Start a consumer (Run in another instance)
bin/kafka-console-consumer.sh --zookeeper 172.31.43.18:2181 --topic twitterdata --from-beginning
-------------------------------------------------------------
Creating a Twitter App on Twitter
We can create an app from https://apps.twitter.com/
we will need consumer key, consumer secret(API secret), access token, access token secret
For my app, IPL Stream kafka
Consumer key:
// Insert the consumer key obtained here
Consumer Secret(API Secret)
// Insert the consumer secret obtained here
Access Token
// Insert the Access Token obtained here
Access Token Secret