Kafka日常運維命令總結

一、集群管理
  1. 前臺啟動Broker

    bin/kafka-server-start.sh <path>/server.properties
    
    • 關閉方式:Ctrl + C
  2. 后臺啟動Broker

    bin/kafka-server-start.sh -daemon <path>/server.properties
    
  3. 關閉Broker

    bin/kafka-server-stop.sh
    

二、Topic管理
操作命令
創建Topicbin/kafka-topics.sh --create --bootstrap-server localhost:9092 --partitions 3 --replication-factor 3 --topic <topicname>
刪除Topicbin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic <topicname>
查詢Topic列表bin/kafka-topics.sh --bootstrap-server localhost:9092 --list
查詢Topic詳情bin/kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic <topicname>
增加分區數bin/kafka-topics.sh --alter --bootstrap-server localhost:9092 --partitions 6 --topic <topicname>

注意:新版本推薦使用--bootstrap-server替代--zookeeper


三、Consumer Groups管理
操作命令
查詢消費組列表bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
查詢消費組詳情bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group <groupname>
刪除消費組bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --delete --group <groupname>
  1. 重設消費位移
    # 重置到最早位移
    bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group <groupname> --reset-offsets --to-earliest --execute# 重置到最新位移
    bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group <groupname> --reset-offsets --to-latest --execute# 重置到指定位移
    bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --group <groupname> --reset-offsets --to-offset 2000 --execute
    

四、常用運維工具
  1. 生產者控制臺

    bin/kafka-console-producer.sh --broker-list localhost:9092 --topic <topicname>
    
    • 高級參數:
      --compression-codec lz4(壓縮)
      --request-required-acks all(ACK機制)
      --message-send-max-retries 10(重試次數)
  2. 消費者控制臺

    bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic <topicname> --group <groupname> --from-beginning
    
  3. 性能測試工具

    # 生產者性能測試
    bin/kafka-producer-perf-test.sh --topic <topic> --num-records 1000000 --record-size 1000# 消費者性能測試
    bin/kafka-consumer-perf-test.sh --topic <topic> --messages 1000000
    
  4. 獲取Topic消息數

    # 最新位移(總消息數)
    bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic <topic> --time -1# 最早位移
    bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic <topic> --time -2
    

五、分區管理
  1. Preferred Leader選舉

    bin/kafka-leader-election.sh --bootstrap-server localhost:9092 --election-type preferred --topic <topic> --partition 0
    
  2. 分區重分配

    # 生成遷移計劃
    bin/kafka-reassign-partitions.sh --bootstrap-server localhost:9092 --generate --topics-to-move-json-file plan.json# 執行遷移
    bin/kafka-reassign-partitions.sh --bootstrap-server localhost:9092 --execute --reassignment-json-file reassign.json# 驗證進度
    bin/kafka-reassign-partitions.sh --bootstrap-server localhost:9092 --verify --reassignment-json-file reassign.json
    

六、高級運維
  1. 查看日志段元數據

    bin/kafka-dump-log.sh --files 000000000000.log --print-data-log
    
  2. 跨集群復制(MirrorMaker)

    bin/kafka-mirror-maker.sh --consumer.config consumer.conf --producer.config producer.conf --whitelist ".*"
    
  3. 查看__consumer_offsets

    bin/kafka-console-consumer.sh --topic __consumer_offsets --formatter "kafka.coordinator.group.GroupMetadataManager\$OffsetsMessageFormatter"
    

關鍵注意事項:

  1. 版本兼容性

    • ≥ Kafka 2.2.x 推薦使用 --bootstrap-server 替代 --zookeeper
    • 刪除Topic需確保 delete.topic.enable=true
  2. 生產環境建議

    • 分區重分配避免高峰時段操作
    • 重設位移前先停止消費者組
    • MirrorMaker需監控復制延遲
  3. 常用診斷技巧

    # 檢查消息積壓(Lag)
    bin/kafka-consumer-groups.sh --describe --group <group> | awk '{print $6}'# 檢查Controller狀態
    bin/kafka-metadata-quorum.sh --status
    

完整文檔參考:Apache Kafka Operations

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/87233.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/87233.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/87233.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

如何訓練一個 Reward Model:RLHF 的核心組件詳解

Reward Model&#xff08;獎勵模型&#xff09;是 RLHF 的核心&#xff0c;決定了模型“覺得人類偏好什么”的依據。本文將系統介紹如何從零開始訓練一個 reward model&#xff0c;包括數據準備、模型結構、損失函數、訓練方法與注意事項。 什么是 Reward Model&#xff1f; …

FrozenBatchNorm2d 詳解

FrozenBatchNorm2d 詳解 基本概念 FrozenBatchNorm2d 是 BatchNorm2d 的一種特殊變體,主要用于在模型訓練或推理過程中固定批量統計量(running mean 和 running variance)以及仿射參數(weight 和 bias)。這種凍結操作在以下場景中特別有用: 模型微調(Fine-tuning):當…

Helix Toolkit 在 WPF 中加載帶貼圖素材的模型

引言 在現代應用程序開發中,將 3D 模型集成到桌面應用中變得越來越普遍。無論是建筑可視化、產品設計還是游戲開發,WPF(Windows Presentation Foundation)結合 Helix Toolkit 提供了一個強大的解決方案來展示和操作 3D 內容。本文將指導你如何使用 Helix Toolkit 加載 .ob…

Http、Ftp、Dns和Dhcp服務器搭建

服務器搭建的要求 ①搭建Web服務器 要求做一個簡單的主頁&#xff08;index.html&#xff09;以便測試 web 服務&#xff0c;服務器&#xff08;Linux 平臺&#xff09;ip 地址配置&#xff1a;10.28.110.251,255.255.255.0&#xff0c;域名為&#xff1a;www.xxx.cie.net。 …

系統架構設計師論文分享-論單元測試方法及其應用

我的軟考歷程 摘要 2023年2月&#xff0c;我所在的公司做了開發紗線MES系統的決定&#xff0c;該系統為國內紗線工廠提供SAAS服務&#xff0c;旨在提高紗線工廠的智能化和數字化水平。我在該項目中被任命為系統架構設計師&#xff0c;全面掌管該項目的架構設計工作。本文將結…

RabbitMQ簡單消息監聽

如何監聽RabbitMQ隊列 簡單代碼實現RabbitMQ消息監聽 需要的依賴 <!--rabbitmq--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId><version>x.x.x</version>&l…

自定義注解的使用

自定義注解 /*** 自定義注解*/ Target(ElementType.FIELD) Retention(RetentionPolicy.RUNTIME) public interface FieldLabel {// 字段中文String label();// 字段順序int order() default 0;// 分組標識String group() default "default";}解析自定義注解&#xf…

Linux:network:socket 綁定到一個interface,如果刪除這個interface會怎么樣?

最近碰到一個問題,應用綁定到了一個GRE的interface,如下socket綁定到了bond10這個interface。 ss -anp | grep bond udp UNCONN 0 0 100.0.5.113%bond10:5061 0.0.0.0:* users

OpenGL 3D編程大師基礎之路:從幾何體到物理引擎

引言&#xff1a;開啟3D編程之旅 歡迎來到令人興奮的3D編程世界&#xff01;本教程將帶您從OpenGL基礎開始&#xff0c;逐步掌握3D渲染的核心技術&#xff0c;最終實現一個包含物理模擬的完整3D場景。我們將探索幾何體創建、光照系統、紋理映射、變換操作和碰撞檢測等關鍵主題…

解決往GitHub提交大文件報錯問題

前言 GitHub倉庫單個文件的推薦大小不能超過50MB&#xff08;僅限于警告&#xff09;&#xff0c;但絕對不能超過100MB&#xff08;拒絕提交&#xff09; 問題 人總有手賤的時候&#xff0c;一不小心往Git倉庫拷貝大文件并嘗試push到GitHub&#xff0c;發現報錯后才意識到問…

PostgreSQL基于歸檔日志的持續恢復測試

測試環境&#xff1a; os: linux PG: 17.4 src ip: 192.168.100.51 dst ip: 192.168.100.138 src: PGDATA/home/postgres174/pgdata dst: PGDATA/data/174/pgdata_standby 歸檔路徑&#xff1a; 192.168.100.138 /data/174/archivedir 測試流程&#xff1a; 1. 主庫(…

Linux——內核——網絡協議

Linux網絡協議棧是Linux內核中實現網絡通信的核心組件&#xff0c;其設計遵循分層架構&#xff0c;支持多種網絡協議和功能。以下從協議棧的分層結構、關鍵組件、工作流程、數據包處理機制、優化與調試等方面進行詳盡闡述&#xff1a; 一、協議棧的分層結構 Linux網絡協議棧基…

vue | 插件 | 移動文件的插件 —— move-file-cli 插件 的安裝與使用

問題&#xff1a;想將打包生成的 dist 文件下的樣式相關文件&#xff0c;進行移動。 解決&#xff1a;在 npm 上找寫好的兼容操作系統的包 move-file-cli 插件 &#xff0c;用于移動文件 move-file-cli 插件的安裝與使用 安裝&#xff1a;npm install move-file-cli --save-d…

多個單片機簡單通訊框架

文章目錄 一、場景描述二、框架搭建設計思路通信協議設計2號單片機通訊框架框架優化建議 三、2號單片機的通訊框架如何處理消息丟失和重傳&#xff1f;消息丟失與重傳機制設計改進的通信協議重傳機制實現關鍵機制說明優化建議 一、場景描述 有3個單片機進行通訊&#xff0c;分…

如何在服務區已有預裝鏡像的情況下管理自己的包

你的需求非常明確&#xff1a;希望利用 NGC 鏡像預裝的主環境包&#xff08;如 PyTorch、CUDA&#xff09;&#xff0c;同時能獨立管理自己額外安裝的包&#xff0c;避免直接污染主環境。以下是幾種解決方案&#xff0c;按推薦度排序&#xff1a; 方案 1&#xff1a;虛擬環境復…

JavaWeb之Servlet(2)RequestResponse..

文章目錄 1 Request和Response的概述2 Request對象2.1 Request繼承體系2.2 Request獲取請求數據2.2.1 獲取請求行數據2.2.2 獲取請求頭數據2.2.3 獲取請求體數據1-3小結2.2.4 獲取請求參數的通用方式請求參數和請求數據的區別問題案例分析問題解決 2.3 IDEA快速創建Servlet2.4 …

將 h264+g711a存為 mp4文件,記錄

將 h264g711a存為 mp4文件&#xff0c;記錄 &#x1f4cc; 關鍵問題&#xff1a;MP4 不原生支持 G.711A MP4 容器格式 不原生支持 G.711&#xff08;包括 A-law&#xff0c;也就是 G.711A&#xff09;音頻&#xff0c;所以不能直接將 G.711A 音頻封裝進 MP4 文件中。常見的做法…

【Elasticsearch】全文檢索 組合檢索

全文檢索 1.全文檢索1.1 準備測試數據1.2 案例分析1.2.1 match&#xff08;分詞檢索&#xff09;1.2.2 match_phrase&#xff08;短語檢索&#xff09;1.2.3 match_phrase_prefix&#xff08;短語前綴匹配&#xff09;1.2.4 multi_match&#xff08;多字段匹配&#xff09;1.2.…

信號處理學習——文獻精讀與code復現之TFN——嵌入時頻變換的可解釋神經網絡(上)

??????????????TFN: An interpretable neural network with time-frequency transform embedded for intelligent fault diagnosis - ScienceDirecthttps://www.sciencedirect.com/science/article/abs/pii/S0888327023008609?via%3Dihub &#xff08;看看玲娜貝…

Panda3D實戰:從入門到精通

Panda3D基礎實例 創建一個簡單的Panda3D場景,加載一個模型并顯示: from direct.showbase.ShowBase import ShowBaseclass MyApp(ShowBase):def __init__(self):ShowBase.__init__(self)self.scene = self.loader.loadModel("models/environment")self.scene.repa…