HyperLedger Fabric 1.4.4マルチノードに基づくkafka共通認識クラスタの構築
23306 ワード
configtx.yaml
プロファイルの変更SampleDevModeKafka
でkafka
のbroker
ノードを追加し、私が追加した内容は以下の通りです.SampleDevModeKafka:
<<: *ChannelDefaults
Capabilities:
<<: *ChannelCapabilities
Orderer:
<<: *OrdererDefaults
OrdererType: kafka
Kafka:
Brokers:
- kafka1.example.com:9082
- kafka2.example.com:9083
- kafka3.example.com:9084
Organizations:
- *OrdererOrg
Capabilities:
<<: *OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- <<: *OrdererOrg
Consortiums:
SampleConsortium:
Organizations:
- *Org1
- *Org2
チャネルを生成する創世ブロック
従来の
solo
共通認識の命令を以下の命令configtxgen -profile SampleDevModeKafka -channelID kafka-channel -outputBlock ./channel-artifacts/genesis.block
に変更するdocker-compose-kafka.yaml
docker-compose-kafka.yaml
ファイルを新規作成します.内容は次のとおりです.# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# NOTE: This is not the way a Kafka cluster would normally be deployed in production, as it is not secure
# and is not fault tolerant. This example is a toy deployment that is only meant to exercise the Kafka code path
# of the ordering service.
version: '2'
services:
zookeeper1.example.com:
container_name: zookeeper1.example.com
hostname: zookeeper1.example.com
image: hyperledger/fabric-zookeeper:latest
ports:
- "2171:2181"
- "2878:2878"
- "3878:3878"
environment:
# zookeeper ,
# zookeeper 2181
# zookeeper , 2181
ZOOKEEPER_CLIENT_PORT: 32171
ZOOKEEPER_TICK_TIME: 2000
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zookeeper1.example.com:2878:3878 server.2=zookeeper2.example.com:2879:3879 server.3=zookeeper3.example.com:2880:3880
extra_hosts:
- "kafka1.example.com:10.1.24.225"
- "zookeeper2.example.com:10.1.24.225"
- "kafka2.example.com:10.1.24.225"
- "zookeeper3.example.com:10.1.24.225"
- "kafka3.example.com:10.1.24.225"
kafka1.example.com:
container_name: kafka1.example.com
image: hyperledger/fabric-kafka:latest
depends_on:
- zookeeper1.example.com
- zookeeper2.example.com
- zookeeper3.example.com
ports:
- "9082:9082"
environment:
- KAFKA_BROKER_ID=1
- KAFKA_ZOOKEEPER_CONNECT=zookeeper1.example.com:2171,zookeeper2.example.com:2172,zookeeper3.example.com:2173
# orderer kafka docker , , ,
# , docker ip ,
# ,
# ,
- KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9082
# kafka , , 0.0.0.0
# hostname , , kafka1.example.com,
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka1.example.com:9082
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=3
- KAFKA_MESSAGE_MAX_BYTES=1048576 # 1 * 1024 * 1024 B
- KAFKA_REPLICA_FETCH_MAX_BYTES=1048576 # 1 * 1024 * 1024 B
- KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
- KAFKA_LOG_RETENTION_MS=-1
- KAFKA_MIN_INSYNC_REPLICAS=1
- KAFKA_DEFAULT_REPLICATION_FACTOR=3
extra_hosts:
- "zookeeper1.example.com:10.1.24.225"
- "zookeeper2.example.com:10.1.24.225"
- "kafka2.example.com:10.1.24.225"
- "zookeeper3.example.com:10.1.24.225"
- "kafka3.example.com:10.1.24.225"
zookeeper2.example.com:
container_name: zookeeper2.example.com
hostname: zookeeper2.example.com
image: hyperledger/fabric-zookeeper:latest
ports:
- "2172:2181"
- "2879:2879"
- "3879:3879"
environment:
ZOOKEEPER_CLIENT_PORT: 32172
ZOOKEEPER_TICK_TIME: 2000
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zookeeper1.example.com:2878:3878 server.2=zookeeper2.example.com:2879:3879 server.3=zookeeper3.example.com:2880:3880
extra_hosts:
- "zookeeper1.example.com:10.1.24.225"
- "kafka1.example.com:10.1.24.225"
- "kafka2.example.com:10.1.24.225"
- "zookeeper3.example.com:10.1.24.225"
- "kafka3.example.com:10.1.24.225"
kafka2.example.com:
container_name: kafka2.example.com
image: hyperledger/fabric-kafka:latest
depends_on:
- zookeeper1.example.com
- zookeeper2.example.com
- zookeeper3.example.com
ports:
- "9083:9083"
environment:
- KAFKA_BROKER_ID=2
- KAFKA_ZOOKEEPER_CONNECT=zookeeper1.example.com:2171,zookeeper2.example.com:2172,zookeeper3.example.com:2173
- KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9083
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka2.example.com:9083
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=3
- KAFKA_MESSAGE_MAX_BYTES=1048576 # 1 * 1024 * 1024 B
- KAFKA_REPLICA_FETCH_MAX_BYTES=1048576 # 1 * 1024 * 1024 B
- KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
- KAFKA_LOG_RETENTION_MS=-1
- KAFKA_MIN_INSYNC_REPLICAS=1
- KAFKA_DEFAULT_REPLICATION_FACTOR=3
extra_hosts:
- "zookeeper1.example.com:10.1.24.225"
- "kafka1.example.com:10.1.24.225"
- "zookeeper2.example.com:10.1.24.225"
- "zookeeper3.example.com:10.1.24.225"
- "kafka3.example.com:10.1.24.225"
zookeeper3.example.com:
container_name: zookeeper3.example.com
hostname: zookeeper3.example.com
image: hyperledger/fabric-zookeeper:latest
ports:
- "2173:2181"
- "2880:2880"
- "3880:3880"
environment:
ZOOKEEPER_CLIENT_PORT: 32173
ZOOKEEPER_TICK_TIME: 2000
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zookeeper1.example.com:2878:3878 server.2=zookeeper2.example.com:2879:3879 server.3=zookeeper3.example.com:2880:3880
extra_hosts:
- "zookeeper1.example.com:10.1.24.225"
- "kafka1.example.com:10.1.24.225"
- "zookeeper2.example.com:10.1.24.225"
- "kafka2.example.com:10.1.24.225"
- "kafka3.example.com:10.1.24.225"
kafka3.example.com:
container_name: kafka3.example.com
image: hyperledger/fabric-kafka:latest
depends_on:
- zookeeper1.example.com
- zookeeper2.example.com
- zookeeper3.example.com
ports:
- "9084:9084"
environment:
- KAFKA_BROKER_ID=3
- KAFKA_ZOOKEEPER_CONNECT=zookeeper1.example.com:2171,zookeeper2.example.com:2172,zookeeper3.example.com:2173
- KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9084
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka3.example.com:9084
- KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=3
- KAFKA_MESSAGE_MAX_BYTES=1048576 # 1 * 1024 * 1024 B
- KAFKA_REPLICA_FETCH_MAX_BYTES=1048576 # 1 * 1024 * 1024 B
- KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
- KAFKA_LOG_RETENTION_MS=-1
- KAFKA_MIN_INSYNC_REPLICAS=1
- KAFKA_DEFAULT_REPLICATION_FACTOR=3
extra_hosts:
- "zookeeper1.example.com:10.1.24.225"
- "kafka1.example.com:10.1.24.225"
- "zookeeper2.example.com:10.1.24.225"
- "kafka2.example.com:10.1.24.225"
- "zookeeper3.example.com:10.1.24.225"
開始
起動時に
-f docker-compose-kafka.yaml
をお持ちください