カフカの紹介
AMPQ
ampq定義されました
AMPQ(アドバンスト・メッセージキューProtocal)は、ユニファイドメッセージングサービスのアプリケーション層の標準的な高度なメッセージキュープロトコルを提供するリンクプロトコルです。
達成するAMPQの使用フレームワークです:カフカ、RabbitMQの
カフカ
カフカは、動的な容量拡張(飼育係のコンポーネントがサポート)をサポートする
ニュース消費完了メッセージが削除された:RabbitMQの、ActiveMQの最大の特徴
カフカの特長:すべての消費者は、自動的に2日間保存されます。
RabbitMQのは、オープンソースのメッセージキュー自体は、多くのプロトコルをサポートして使用してErlangで書かれている。このためのAMQP、XMPP、SMTP、STOMPは、それは非常にヘビー級で、エンタープライズクラスの開発に適しています。メッセージがクライアントに送信中心に最初のキューにキューイングされていることを意味ブローカー・アーキテクチャを実現しながら。、ルーティング、ロードバランシングやデータの永続性は非常に良いサポートを持っています。
カフカの原則
クラスタとしてカフカは、複数のデータセンターにある複数のサーバー上で実行することができます。
呼ばれるストリームに関する記録保存カフカのクラスタカテゴリ
の各レコードに対しては、キー、タイムスタンプ値と組成で構成されてい
長期
プロデューサー:プロデューサーは、[説明:オブジェクトが呼び出しトピックプロデューサー(カフカ話題プロデューサー)を発表しました]
:消費者、サブスクリプションメッセージとプロセスメッセージ投稿シードオブジェクトと呼ばれるテーマ消費者(消費者)消費者
トピック:ラベル(実際には、キューとして見ることができる)、[説明:カフカ種子はメッセージ分類を養うには、メッセージは各カテゴリがテーマです(トピック)]
ブローカー:パブリッシュされたメッセージは、サーバのセットに保存されたカフカとして知られていますクラスター。これらのメッセージの消費が掲載されているように、各クラスタは、消費者はブローカーを引っ張ってから1つのまたは複数のトピック(話題)、およびデータを購読することができますプロキシサーバー(ブローカー)。です。
4つのコアAPI
一つ以上の話題(テーマ)にメッセージをパブリッシュ使用1.プロデューサーAPIアプリケーション。
2.アプリケーションは、トピックの一つ以上の、メッセージの生成および処理を購読する消費者のAPIを使用しています。
3.アプリケーションは、ストリームAPIを効果的に入力ストリーム出力ストリームを変換し、出力するトピックまたは1を複数製造するために、1つ以上のトピックのメッセージ入力ストリームと出力ストリームから、フロープロセッサとして機能する使用します。
4:コネクタのAPIは、消費者やビルドに生産を可能にしたり、既存のアプリケーションやデータシステムに接続するための再利用可能な、トピックを実行します。たとえば:コネクターは、すべての変更をキャプチャするためのリレーショナルデータベースであってもよいです
テーマとログ(少し)
プロデューサー
コンシューマー
共通コマンド
管理
## 创建主题(4个分区,2个副本)
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 2 --partitions 4 --topic test
お問い合わせ
## 查询集群描述
bin/kafka-topics.sh --describe --zookeeper
## 消费者列表查询
bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --list
## 新消费者列表查询(支持0.9版本+)
bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --list
## 显示某个消费组的消费详情(仅支持offset存储在zookeeper上的)
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper localhost:2181 --group test
## 显示某个消费组的消费详情(支持0.9版本+)
bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --describe --group test-consumer-group
送信と消費
## 生产者
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
## 消费者
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test
## 新生产者(支持0.9版本+)
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test --producer.config config/producer.properties
## 新消费者(支持0.9版本+)
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --new-consumer --from-beginning --consumer.config config/consumer.properties
## 高级点的用法
bin/kafka-simple-consumer-shell.sh --brist localhost:9092 --topic test --partition 0 --offset 1234 --max-messages 10
バランスのとれたリーダー
bin/kafka-preferred-replica-election.sh --zookeeper zk_host:port/chroot
圧力測定コマンドカフカが来ます
bin/kafka-producer-perf-test.sh --topic test --num-records 100 --record-size 1 --throughput 100 --producer-props bootstrap.servers=localhost:9092
コピー増やす
1:ルールJSONを作成します。
cat > increase-replication-factor.json <<EOF
{"version":1, "partitions":[
{"topic":"__consumer_offsets","partition":0,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":1,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":2,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":3,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":4,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":5,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":6,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":7,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":8,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":9,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":10,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":11,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":12,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":13,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":14,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":15,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":16,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":17,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":18,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":19,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":20,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":21,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":22,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":23,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":24,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":25,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":26,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":27,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":28,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":29,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":30,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":31,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":32,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":33,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":34,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":35,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":36,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":37,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":38,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":39,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":40,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":41,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":42,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":43,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":44,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":45,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":46,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":47,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":48,"replicas":[0,1]},
{"topic":"__consumer_offsets","partition":49,"replicas":[0,1]}]
}
EOF
2:実行
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.json --execute
3:確認してください
bin/kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.jso
出典ます。https://www.cnblogs.com/mlan/p/11084526.html