国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【kafka】記一次kafka基于linux的原生命令的使用

這篇具有很好參考價值的文章主要介紹了【kafka】記一次kafka基于linux的原生命令的使用。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報違法"按鈕提交疑問。

環(huán)境是linux,4臺機(jī)器,版本3.6,kafka安裝在node 1 2 3 上,zookeeper安裝在node2 3 4上。

安裝好kafka,進(jìn)入bin目錄,可以看到有很多sh文件,是我們執(zhí)行命令的基礎(chǔ)。
【kafka】記一次kafka基于linux的原生命令的使用,kafka,kafka,linq,分布式
啟動kafka,下面的命令的后面帶的配置文件的相對路徑

kafka-server-start.sh ./server.properties

遇到不熟悉的sh文件,直接輸入名字并回車,就會提示你可用的命令參數(shù)。如果參數(shù)用錯了,kafka也會提示你相應(yīng)的錯誤。

[root@localhost bin]# kafka-topics.sh
Create, delete, describe, or change a topic.
Option                                   Description                            
------                                   -----------                            
--alter                                  Alter the number of partitions and     
                                           replica assignment. Update the       
                                           configuration of an existing topic   
                                           via --alter is no longer supported   
                                           here (the kafka-configs CLI supports 
                                           altering topic configs with a --     
                                           bootstrap-server option).            
--at-min-isr-partitions                  if set when describing topics, only    
                                           show partitions whose isr count is   
                                           equal to the configured minimum.     
--bootstrap-server <String: server to    REQUIRED: The Kafka server to connect  
  connect to>                              to.                                  
--command-config <String: command        Property file containing configs to be 
  config property file>                    passed to Admin Client. This is used 
                                           only with --bootstrap-server option  
                                           for describing and altering broker   
                                           configs.                             
--config <String: name=value>            A topic configuration override for the 
                                           topic being created or altered. The  
                                           following is a list of valid         
                                           configurations:                      
                                         	cleanup.policy                        
                                         	compression.type                      
                                         	delete.retention.ms                   
                                         	file.delete.delay.ms                  
                                         	flush.messages                        
                                         	flush.ms                              
                                         	follower.replication.throttled.       
                                           replicas                             
                                         	index.interval.bytes                  
                                         	leader.replication.throttled.replicas 
                                         	local.retention.bytes                 
                                         	local.retention.ms                    
                                         	max.compaction.lag.ms                 
                                         	max.message.bytes                     
                                         	message.downconversion.enable         
                                         	message.format.version                
                                         	message.timestamp.after.max.ms        
                                         	message.timestamp.before.max.ms       
                                         	message.timestamp.difference.max.ms   
                                         	message.timestamp.type                
                                         	min.cleanable.dirty.ratio             
                                         	min.compaction.lag.ms                 
                                         	min.insync.replicas                   
                                         	preallocate                           
                                         	remote.storage.enable                 
                                         	retention.bytes                       
                                         	retention.ms                          
                                         	segment.bytes                         
                                         	segment.index.bytes                   
                                         	segment.jitter.ms                     
                                         	segment.ms                            
                                         	unclean.leader.election.enable        
                                         See the Kafka documentation for full   
                                           details on the topic configs. It is  
                                           supported only in combination with --
                                           create if --bootstrap-server option  
                                           is used (the kafka-configs CLI       
                                           supports altering topic configs with 
                                           a --bootstrap-server option).        
--create                                 Create a new topic.                    
--delete                                 Delete a topic                         
--delete-config <String: name>           A topic configuration override to be   
                                           removed for an existing topic (see   
                                           the list of configurations under the 
                                           --config option). Not supported with 
                                           the --bootstrap-server option.       
--describe                               List details for the given topics.     
--exclude-internal                       exclude internal topics when running   
                                           list or describe command. The        
                                           internal topics will be listed by    
                                           default                              
--help                                   Print usage information.               
--if-exists                              if set when altering or deleting or    
                                           describing topics, the action will   
                                           only execute if the topic exists.    
--if-not-exists                          if set when creating topics, the       
                                           action will only execute if the      
                                           topic does not already exist.        
--list                                   List all available topics.             
--partitions <Integer: # of partitions>  The number of partitions for the topic 
                                           being created or altered (WARNING:   
                                           If partitions are increased for a    
                                           topic that has a key, the partition  
                                           logic or ordering of the messages    
                                           will be affected). If not supplied   
                                           for create, defaults to the cluster  
                                           default.                             
--replica-assignment <String:            A list of manual partition-to-broker   
  broker_id_for_part1_replica1 :           assignments for the topic being      
  broker_id_for_part1_replica2 ,           created or altered.                  
  broker_id_for_part2_replica1 :                                                
  broker_id_for_part2_replica2 , ...>                                           
--replication-factor <Integer:           The replication factor for each        
  replication factor>                      partition in the topic being         
                                           created. If not supplied, defaults   
                                           to the cluster default.              
--topic <String: topic>                  The topic to create, alter, describe   
                                           or delete. It also accepts a regular 
                                           expression, except for --create      
                                           option. Put topic name in double     
                                           quotes and use the '\' prefix to     
                                           escape regular expression symbols; e.
                                           g. "test\.topic".                    
--topic-id <String: topic-id>            The topic-id to describe.This is used  
                                           only with --bootstrap-server option  
                                           for describing topics.               
--topics-with-overrides                  if set when describing topics, only    
                                           show topics that have overridden     
                                           configs                              
--unavailable-partitions                 if set when describing topics, only    
                                           show partitions whose leader is not  
                                           available                            
--under-min-isr-partitions               if set when describing topics, only    
                                           show partitions whose isr count is   
                                           less than the configured minimum.    
--under-replicated-partitions            if set when describing topics, only    
                                           show under replicated partitions     
--version                                Display Kafka version.                

如這里,我們創(chuàng)建一個topic名為test。

kafka-topics.sh --create --topic test  --bootstrap-server node1:9092 --partitions 2 --replication-factor 2
Created topic test.

連接其中node1上的kafka獲得metedata里的topic列表

[root@localhost bin]# kafka-topics.sh --list --bootstrap-server node1:9092
test

查看某個topic的細(xì)節(jié)

[root@localhost bin]# kafka-topics.sh --describe --topic test --bootstrap-server node1:9092
Topic: test	TopicId: WgjG4Ou_Q7iQvzgipRgzjg	PartitionCount: 2	ReplicationFactor: 2	Configs: 
	Topic: test	Partition: 0	Leader: 2	Replicas: 2,1	Isr: 2,1
	Topic: test	Partition: 1	Leader: 3	Replicas: 3,2	Isr: 3,2

在其中的一臺機(jī)器上起一個生產(chǎn)者,在其他兩臺機(jī)器上起2個消費(fèi)者,都在同一個組里。

[root@localhost bin]# kafka-console-producer.sh --broker-list node1:9092 --topic test
>hello 03
>1
>2
>3
>4
>5
>6
>7
>8

可以看到同一個組內(nèi),如果組內(nèi)消費(fèi)者注冊情況不變化有且只有同一個consumer能夠消費(fèi)數(shù)據(jù)。可以滿足對于消息要求順序性,不能并發(fā)消費(fèi)的情況。

[root@localhost bin]# kafka-console-consumer.sh --bootstrap-server node1:9092 --topic test --group msb
hello 03
1
2
3
4
5
6
7
8

查看某個組內(nèi)的情況

[root@localhost bin]# kafka-consumer-groups.sh --bootstrap-server node2:9092 --group msb --describe

GROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                           HOST             CLIENT-ID
msb             test            1          24              24              0               console-consumer-4987804d-6e59-4f4d-9952-9afb9aff6cbe /192.168.184.130 console-consumer
msb             test            0          0               0               0               console-consumer-242992e4-7801-4a38-a8f3-8b44056ed4b6 /192.168.184.130 console-consumer

最后看一下zk中的情況吧。
zk根目錄下多了一個kafka節(jié)點(diǎn)

[zk: localhost:2181(CONNECTED) 1] ls /
[kafka, node1, node6, node7, testLock, zookeeper]

kafka下面有很多metedata信息,包含在這些節(jié)點(diǎn)中,如,,

[zk: localhost:2181(CONNECTED) 2] ls /kafka
[admin, brokers, cluster, config, consumers, controller, controller_epoch, feature, isr_change_notification, latest_producer_id_block, log_dir_event_notification]
#集群id
[zk: localhost:2181(CONNECTED) 3] ls /kafka/cluster 
[id]
[zk: localhost:2181(CONNECTED) 5] get /kafka/cluster/id 
{"version":"1","id":"8t14lxoAS1SdXapY6ysw_A"}
#controller的id
[zk: localhost:2181(CONNECTED) 6] get /kafka/controller
{"version":2,"brokerid":3,"timestamp":"1698841142070","kraftControllerEpoch":-1}

可以看到topics中有一個__consumer_offsets,是kafka用來存儲offset的topic。文章來源地址http://www.zghlxwxcb.cn/news/detail-743729.html

[zk: localhost:2181(CONNECTED) 10] ls /kafka/brokers/topics 
[__consumer_offsets, test]
[zk: localhost:2181(CONNECTED) 12] get /kafka/brokers/topics/__consumer_offsets 
{"partitions":{"44":[1],"45":[2],"46":[3],"47":[1],"48":[2],"49":[3],"10":[3],"11":[1],"12":[2],"13":[3],"14":[1],"15":[2],"16":[3],"17":[1],"18":[2],"19":[3],"0":[2],"1":[3],"2":[1],"3":[2],"4":[3],"5":[1],"6":[2],"7":[3],"8":[1],"9":[2],"20":[1],"21":[2],"22":[3],"23":[1],"24":[2],"25":[3],"26":[1],"27":[2],"28":[3],"29":[1],"30":[2],"31":[3],"32":[1],"33":[2],"34":[3],"35":[1],"36":[2],"37":[3],"38":[1],"39":[2],"40":[3],"41":[1],"42":[2],"43":[3]},"topic_id":"RGxJyefAQlKrmY3LTVbKGw","adding_replicas":{},"removing_replicas":{},"version":3}

到了這里,關(guān)于【kafka】記一次kafka基于linux的原生命令的使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點(diǎn)擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 記一次線上kafka造成的事故

    背景:所有的原始數(shù)據(jù)均存儲在mysql,mysql會通過binlog將數(shù)據(jù)同步至kafka消息隊列,但是有人將mysql中的數(shù)據(jù)進(jìn)行刪除(大概有2、3年的數(shù)據(jù)),被刪除的數(shù)據(jù)也通過binlog被同步至消息隊列里導(dǎo)致大量消息積壓,且該消息隊列只有3個分區(qū),最多3個線程消費(fèi),消費(fèi)方即使過濾也遠(yuǎn)

    2024年02月13日
    瀏覽(19)
  • 記一次linux系統(tǒng)使用dockerfile編寫容器支持中文字體環(huán)境

    記一次linux系統(tǒng)使用dockerfile編寫容器支持中文字體環(huán)境

    今天研發(fā)開發(fā)一個網(wǎng)上受理需要容器支持中文環(huán)境否則服務(wù)啟動起來會出現(xiàn)中文亂碼。 解決思路: 1、先把jar把在本地環(huán)境直接加參數(shù)運(yùn)行如果運(yùn)行起來無亂碼說明本地的字體文件就可以直接COPY到容器中使用,如果還是亂碼就說明本地的字體文件不支持中文環(huán)境,就需要下載

    2024年02月09日
    瀏覽(97)
  • 記一次Flink通過Kafka寫入MySQL的過程

    記一次Flink通過Kafka寫入MySQL的過程

    一、前言 總體思路:source --transform --sink ,即從source獲取相應(yīng)的數(shù)據(jù)來源,然后進(jìn)行數(shù)據(jù)轉(zhuǎn)換,將數(shù)據(jù)從比較亂的格式,轉(zhuǎn)換成我們需要的格式,轉(zhuǎn)換處理后,然后進(jìn)行sink功能,也就是將數(shù)據(jù)寫入的相應(yīng)的數(shù)據(jù)庫DB中或者寫入Hive的HDFS文件存儲。 思路: pom部分放到最后面。 二

    2024年01月24日
    瀏覽(27)
  • 記一次docker安裝kafka,zookeeper拒絕連接的問題

    第一次玩kafka,在使用docker安裝kafka時,出現(xiàn)了如下問題 kafka的啟動參數(shù)KAFKA_ZOOKEEPER_CONNECT不能是localhost:2181,因為不是在一個容器中,localhost改為ip地址就可以了 nc 命令連接到 localhost:2181,確保ZooKeeper 服務(wù)器正在監(jiān)聽該地址,并且可以通過網(wǎng)絡(luò)進(jìn)行訪問 定位的過程中還遇到了

    2024年02月10日
    瀏覽(23)
  • 記一次線上kafka重復(fù)消費(fèi)的問題解決及思考

    線上ELK日志發(fā)現(xiàn)kafka消費(fèi)者消費(fèi)到重復(fù)消息 由于生產(chǎn)方本身就發(fā)送了重復(fù)的消息,導(dǎo)致消費(fèi)到重復(fù)消息 消費(fèi)方采用的是循環(huán)poll的模式,具體是在多線程分租戶去批量處理的消息

    2024年02月10日
    瀏覽(19)
  • 記一次Kafka 故障Too many open files問題

    記一次Kafka 故障Too many open files問題

    查看日志發(fā)現(xiàn),有kafka日志報錯提示: 查看limit.conf文件,發(fā)現(xiàn)文件打開數(shù)設(shè)置的值也沒問題,嘗試增大值后,但就是提示Too many open files,報錯就是文件打開數(shù)過多。 經(jīng)不懈的百度百度,發(fā)現(xiàn)如下圖兩條關(guān)鍵信息; systemd 服務(wù) 模塊 最大打開文件數(shù)默認(rèn)為1024,查看其他沒改動

    2024年02月13日
    瀏覽(22)
  • 記一次 springboot集成kafka-本地連接服務(wù)器的kafka,連接不上的問題

    記一次 springboot集成kafka-本地連接服務(wù)器的kafka,連接不上的問題

    yml中配置了bootstrap-servers: 服務(wù)器地址:9092 ,但是連接時卻報了 Connection to node -1 ( localhost/127.0.0.1:9092 ) could not be established. chat給我的回復(fù)如下,通過一些列檢查我確定了在服務(wù)器上,kafka沒有問題 最后還是從一篇博客中的第一句話得到了答案,博客鏈接放在最下方 我是docker安

    2024年01月17日
    瀏覽(25)
  • 記一次linux復(fù)制病毒處理過程

    某天我的阿里云突然發(fā)信息告訴我服務(wù)器有自變異木馬,我用遠(yuǎn)程工具連接服務(wù)器異??D甚至掉線,reboot也不好使.用阿里云的網(wǎng)頁控制臺會好些,但還是卡,我又用阿里云控制臺重啟服務(wù)器,重啟之后發(fā)現(xiàn)服務(wù)器完全連不上了,ping也ping不通了,我問了客服說可以用救援連接試試,果

    2024年01月24日
    瀏覽(21)
  • 記一次Linux啟動Mysql異常解決

    記一次Linux啟動Mysql異常解決

    并沒有發(fā)現(xiàn)3306數(shù)據(jù)庫端口 service mysqld start systemctl start mysqld.service 都無效,報錯 發(fā)現(xiàn)是磁盤空間不足。。。 (下圖是已經(jīng)清理過的結(jié)果截圖) 然后把磁盤的不重要文件直接刪除即可 rm -rf * 總結(jié): 第一步看全局端口占用情況 第二步看日志/根據(jù)提示命令看信息 其實,在啟動My

    2024年02月14日
    瀏覽(20)
  • 記一次mysql8 在linux上安裝全過程

    記一次mysql8 在linux上安裝全過程

    參照MYSQL官網(wǎng)官方文檔安裝 1、mysql官網(wǎng) mysql官網(wǎng) 2、直接進(jìn)入文檔頁 找到安裝文檔 3、找到自己系統(tǒng)對應(yīng)的安裝文檔,選合適的安裝方式,我這里使用的是YUM方式 a、開始安裝之前需要替換yum倉庫 具體步驟如下 b、將下載的文件上傳至自己的服務(wù)器 如下 c c、執(zhí)行yum倉庫安裝命

    2024年02月12日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包