linux mint安装kafka,及flume与kafka整合

需要软件
jdk1.8(jdk-8u131-linux-x64.rpm)
zookeeper (zookeeper-3.4.10.tar.gz)
kafka 2.11-2.0.0
flume1.8.0
 
把触控板的操作做为输出
sudo fusuma 1>/var/log/script/test111 2>&1 &
 
1、jdk就不说了
2、zookeeper安装,参考其他
bin目录./zkServer.sh start
查看状态./zkServer.sh status
3、安装kafka
http://kafka.apache.org/downloads.html
tar -zxf kafka_2.11-2.0.0.tgz
修改配置文件
gedit config/server.properties
listeners=PLAINTEXT://172.17.173.226:9092
外网访问需要加:advertised.listeners=PLAINTEXT://39.105.189.4:9092
log.dirs=/opt/softWare/Cache/kafka 指定日志存放目录
 
控制台方式,日志记录到当前目录下nohup.out文件中
cd /opt/softWare/kafka_2.11-2.0.0
./bin/kafka-server-start.sh ./config/server.properties &
后台启动
nohup ./bin/kafka-server-start.sh ./config/server.properties &
查看状态 jps
 
测试kafka 在bin目录下
创建一个topic
./bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic robots2 --partitions 1 --replication-factor 1
查看创建的topic
./bin/kafka-topics.sh --zookeeper localhost:2181 --list
test_kafka
 
启动消费者
./kafka-console-consumer.sh --bootstrap-server 172.17.173.226:9092 --topic robots2 --from-beginning
新版的kafka只能使用–bootstrap-server来启动,zookeeper的指令已经被取消了。
 
在新的shell中启动生产者
bin/kafka-console-producer.sh --broker-list 172.17.173.226:9092 --topic robots2
启动之后输入消息,在消费者的shell中就可以接收到生产者中输入的信息。
单机版安装完成
 
================================================================================================================
1、flume安装目录conf下新建了kafka.properties文件,启动时也应当用此配置文件作为参数启动。
================================================================
kafka.properties
agent.sources = s1
agent.channels = c1
agent.sinks = k1
agent.sources.s1.type=exec
agent.sources.s1.command=tail -F /var/log/nginx/access.log
agent.sources.s1.channels=c1
agent.channels.c1.type=memory
agent.channels.c1.capacity=10000
agent.channels.c1.transactionCapacity=100
#设置Kafka接收器
agent.sinks.k1.type= org.apache.flume.sink.kafka.KafkaSink
#设置Kafka的broker地址和端口号
agent.sinks.k1.brokerList=172.17.173.226:9092
#设置Kafka的Topic
agent.sinks.k1.topic=robots2
#设置序列化方式
agent.sinks.k1.serializer.class=kafka.serializer.StringEncoder\
agent.sinks.k1.channel=c1
==================================================================
2、在kafka安装目录下执行如下命令,启动zk,kafka 。
启动zookeeper
cd /opt/Servers/zookeeper-3.4.10/bin
./zkServer.sh start
后台启动kafka
nohup ./kafka-server-start.sh ../config/server.properties &
打开新终端添加一个topic
./kafka-topics.sh --zookeeper localhost:2181 --create --topic mylog --partitions 1 --replication-factor 1
查看创建的topic
./kafka-topics.sh --zookeeper localhost:2181 --list
打开新终端,在kafka安装目录下执行如下命令,生成对topic robots2 的消费
./bin/kafka-console-consumer.sh --bootstrap-server 172.17.173.226:9092 --topic robots2 --from-beginning
后台启动flume
nohup ./bin/flume-ng agent -c ./conf/ -f ./conf/kafka.properties -n agent -Dflume.root.logger=DEBUG,console &
posted @ 2025-01-02 11:50  Robots2  阅读(34)  评论(0)    收藏  举报