Skip to content

c语言实现文件内容实时推送至kafka The c language implementation, file's content pushed to kafka in real time.

License

Notifications You must be signed in to change notification settings

GuangxinZhang/ctk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

项目简介

  • 名称: ctk
  • 开发语言:c
  • 当前版本:0.0.1
  • 项目概述:c语言实现实时读取文本,并发送至kafka topic

环境搭建

  • 安装log4c1.2.4
    ./configure --prefix=/usr/local/lib/log4c/
    make
    make install
    将liglog4c.so.3所在目录/usr/local/lib/log4c/lib/添加到文件/etc/ld.so.conf中
    执行:sudo ldconfig

  • 安装 librdkafka-0.9.3
    ./configure
    make
    sudo make install
    将librdkafka.so所在目录/usr/local/lib/加入/etc/ld.so.conf文件中
    安装完毕后执行sudo ldconfig

  • 修改系统hosts 增加kafka 的brokers
  • 编译执行程序:
    下载项目源码,进入Release目录,执行make all,即可在当前目录下生成 ctk 的可执行文件。
    启动程序:修改log4crc文件的logdir日志目录,修改config.ini对应配置,执行 nohup ./ctk &

  • ctk 开发环境搭建
    • IDE: eclipse cpp-neon
    • 系统环境安装依赖包:log4c1.2.4,librdkafka0.9.3
    • eclipse新建项目,导入项目文件
    • 项目右键->Properties->C/C++ Build->Settings->Tool Settings->GCC C Compiler->Includes->Include paths(-I)
    • 添加:/usr/local/lib/log4c/include
    • 添加:/usr/local/lib/log4c/lib64
    • 添加:/usr/local/lib
    • 项目右键->Properties->C/C++ Build->Settings->Tool Settings->GCC C Linker->Libraries->Libraries(-l)
    • 添加:log4c
    • 添加:rdkafka
    • 项目右键->Properties->C/C++ Build->Settings->Tool Settings->GCC C Linker->Libraries->Library search path(-L)
    • 添加:/usr/local/lib/log4c/lib64
    • 此处注意是lib64还是lib,有些平台是/usr/local/lib/log4c/lib
  • Syntax and Semantic Error
    • 取消 "Preference" —> "C/C++" -> "Code Analysis" -> “Syntax and Semantic Error”

使用

  • 在Release目录下,修改config.ini 和 log4crc 配置文件的属性
  • nohup ./ctk & 启动程序,后台执行
  • config.ini log4crc 和 ctk可执行程序必须放在同一目录

常见问题

    log4c:
    ./configure  --prefix=/usr/local/lib/log4c/
    make
    make install  
    error while loading shared libraries: liblog4c.so.3: cannot open shared object file: No such file or directory
    vim /etc/ld.so.conf
    添加:/usr/local/lib
    执行:ldconfig
    /lib64/libc.so.6: version GLIBC_2.14 not found (required by ./agent_pcap_v2)
    下载:http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz
    [root@localhost glibc-2.14]# mkdir build
    [root@localhost glibc-2.14]# cd ./build/
    [root@localhost build]# ../conf
    conf/      configure  conform/   
    [root@localhost build]# ../configure --prefix=/opt/glibc-2.14
    [root@localhost build]# make -j4
    [root@localhost build]# make install
    cp -r /etc/ld.so.c* /opt/glibc-2.14/etc/
    ln -sf /opt/glibc-2.14/lib/libc-2.14.so /lib64/libc.so.6

About

c语言实现文件内容实时推送至kafka The c language implementation, file's content pushed to kafka in real time.

Resources

License

Stars

Watchers

Forks

Packages

No packages published