1.安装git
yum install -y git
2.切换到/usr/local/src目录,然后将kafka的c客户端源码clone到本地
cd /usr/local/src
git clone https://github.com/edenhill/librdkafka
(如果这一步没有成功可以使用git --version命令查看当前git版本,版本如果为1.7请升级)
3.进入到librdkafka,然后进行编译
cd librdkafka
yum install -y gcc
yum install -y gcc-c++
yum install pcre-devel
yum install zlib-devel
./configure
make && make install
4.安装nginx整合kafka的插件,进入到/usr/local/src,clone nginx整合kafka的源码
cd /usr/local/src
git clone https://github.com/brg-liuwei/ngx_kafka_module
(如果报错可以将https改为git)
5.进入到nginx的源码包目录下 (编译nginx,然后将将插件同时编译)
cd /usr/local/src/nginx-1.12.2
./configure --add-module=/usr/local/src/ngx_kafka_module/
make
make install
6.修改nginx的配置文件(/usr/local/nginx)
nginx.conf7.启动zk和kafka集群(创建topic)
/bigdata/zookeeper-3.4.9/bin/zkServer.sh start
/bigdata/kafka_2.11-0.10.2.1/bin/kafka-server-start.sh -daemon /bigdata/kafka_2.11-0.10.2.1/config/server.properties
8.启动nginx(/usr/local/nginx),报错,找不到kafka.so.1的文件
error while loading shared libraries: librdkafka.so.1: cannot open shared object file: No such file or directory
9.加载so库
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
10.测试,向nginx中写入数据,然后观察kafka的消费者能不能消费到数据
curl localhost/kafka/track -d "message send to kafka topic"
curl localhost/kafka/track -d "老赵666"
网友评论