【kafka集群搭建+监控+启动守护线程 超详细】

kafka

1.下载

链接:https://pan.baidu.com/s/1XVFekzTc9W4nUkiWQnIi4A
提取码:roik

2.安装

2.1解压

tar -zxvf kafka_2.12-2.0.0.tgz 
mv kafka_2.12-2.0.0 kafka

2.2 配置环境变量

vi /etc/profile

内容如下:

export KAFKA_HOME=/usr/local/software/kafka
export PATH=$PATH:$KAFKA_HOME/bin

配置文件生效:

source /etc/profile

2.3 修改配置文件

  1. 创建日志目录

    cd /usr/local/software/kafka
    mkdir kafka-logs
    chmod 777 kafka-logs
    
  2. .进入/usr/local/software/kafka/config目录,修改配置文件server.properties

    vi server.properties
    
  3. 内容如下:

    broker.id=1 # 唯一ID同一集群下broker.id不能重复
    listeners=PLAINTEXT://10.202.80.196:9092 #ލ监听地址
    log.dirs=/usr/local/software/kafka/kafka-logs # 日志目录
    log.retention.hours=168 # kafka数据保留时间单位为hour 默认168小时 即7天
    log.retention.bytes=1073741824 #kafka数据量最大值,超出范围自动清理,和log.retention.hours配置使用,注意最大值设定不能超过磁盘大小
    zookeeper.connect=10.202.80.196:2181 #zookeeper连接的ip以及port,多个以逗号分割
    
  4. 启动kafka

    zkServer.sh start #先开启zookeeper服务
    kafka-server-start.sh config/server.properties
    

    查看进程:

    image-20211201164825645
  5. 关闭kafka

    kafka-server-stop.sh
    

3.命令

  • 创建主题

    kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic test01
    #主题名 test01 3个分区
    
  • 列出所有主题:

    kafka-topics.sh --list --zookeeper localhost:2181 
    
  • 查看topic的相关信息

    kafka-topics.sh --describe --zookeeper localhost:2181 --topic test01
    

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-s8585Ggd-1639724429219)(C:\Users\ZYZ\AppData\Roaming\Typora\typora-user-images\image-20211201171237876.png)]

  • 简单的发布订阅

    1. 要先开启zookeeper服务和kafka
    kafka-console-producer.sh --broker-list 10.202.80.196:9092 --topi
Bruce 是 Apache Kafka 的生产者守护进程,它简化了客户端发送消息到 Kafka ,无需关注后端的 Kafka 集群。Bruce 主要处理: Routing messages to the proper brokers, and spreading the load evenly across multiple partitions for a given topic Waiting for acknowledgements, and resending messages as necessary due to communication failures or Kafka-reported errors Buffering messages to handle transient load spikes and Kafka-related problems Tracking message discards when serious problems occur; Providing web-based discard reporting and status monitoring interfaces Batching and compressing messages in a configurable manner for improved performance Bruce runs on each individual host that communicates with Kafka, receiving messages from local clients over a UNIX domain datagram socket. Clients write messages to Bruce's socket in a simple binary format. Once a client has written a message, no further interaction with Bruce is required. From that point onward, Bruce takes full responsibility for reliable message delivery. Bruce serves as a single intake point for a Kafka cluster, receiving messages from diverse clients regardless of what programming language a client is written in. Client code is currently available in C, C , Java, Python, and PHP. Code contributions for clients in other programming languages are much appreciated. Technical details on how to send messages to Bruce are provided here. Bruce runs on Linux, and has been tested on CentOS versions 7 and 6.5, and Ubuntu versions 14.04.1 LTS and 13.10. Bruce requires at least version 0.8 of Kafka. 标签:Bruce
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值