gpt4 book ai didi

apache-kafka - Hyperledger Fabric First 网络不与 kafka 一起使用并使用 TLS

转载 作者:行者123 更新时间:2023-12-04 05:24:56 26 4
gpt4 key购买 nike

我尝试运行第一个网络示例 Building Your First Network来自官方文档。我需要使用 kafka orderer 类型运行这个示例。对于这种情况,我编辑 configtx.yaml 文件(将 OrdererType 更改为 kafka 并添加了 Brokers)

...

# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: kafka

...

Kafka:
# Brokers: A list of Kafka brokers to which the orderer connects
# NOTE: Use IP:port notation
Brokers:
- kafka:9093

...

并在 base/docker-compose-base.yaml 中添加了 kafka 和 zookeeper 容器

....

zookeeper:
image: hyperledger/fabric-zookeeper
container_name: zookeeper
ports:
- 2181:2181
networks:
- byfn
kafka:
image: hyperledger/fabric-kafka
container_name: kafka
environment:
- KAFKA_ADVERTISED_HOST_NAME=kafka
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_SSL_KEYSTORE_LOCATION=/var/private/ssl/kafka.server.keystore.jks
- KAFKA_SSL_KEYSTORE_PASSWORD=test1234
- KAFKA_SSL_KEY_PASSWORD=test1234
- KAFKA_SSL_TRUSTSTORE_LOCATION=/var/private/ssl/kafka.server.truststore.jks
- KAFKA_SSL_TRUSTSTORE_PASSWORD=test1234
- KAFKA_LISTENERS=PLAINTEXT://kafka:9092,SSL://kafka:9093
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,SSL://kafka:9093
- KAFKA_MESSAGE_MAX_BYTES=103809024
- KAFKA_REPLICA_FETCH_MAX_BYTES=103809024
- KAFKA_UNCLEAN_LEADER_ELECTION_ENABLE=false
volumes:
- ./sample/server.keystore.jks:/var/private/ssl/kafka.server.keystore.jks
- ./sample/server.truststore.jks:/var/private/ssl/kafka.server.truststore.jks
ports:
- 9093:9093
- 9092:9092
networks:
- byfn

我还为 kafka 客户端和服务器生成了加密数据。

keytool -keystore server.keystore.jks -alias kafka -validity 365 -genkey -keyalg RSA -keysize 2048 -storepass test1234 -dname "cn=kafka" -keypass test1234
keytool -keystore client.keystore.jks -alias orderer -validity 365 -genkey -keyalg RSA -keysize 2048 -storepass test1234 -dname "cn=orderer" -keypass test1234
openssl req -new -x509 -keyout ca-key.pem -out ca-cert.pem -days 365 -subj "/CN=FAB5226" -nodes
keytool -keystore server.truststore.jks -alias CARoot -import -file ca-cert.pem -storepass test1234 -noprompt
keytool -keystore client.truststore.jks -alias CARoot -import -file ca-cert.pem -storepass test1234 -noprompt
keytool -keystore server.keystore.jks -alias kafka -certreq -file server-cert-signing-request.pem -storepass test1234
openssl x509 -req -CA ca-cert.pem -CAkey ca-key.pem -in server-cert-signing-request.pem -out server-cert-signed.pem -days 365 -CAcreateserial -passin pass:test1234
keytool -keystore server.keystore.jks -alias CARoot -import -file ca-cert.pem -storepass test1234 -noprompt
keytool -keystore server.keystore.jks -alias kafka -import -file server-cert-signed.pem -storepass test1234 -noprompt
keytool -keystore client.keystore.jks -alias orderer -certreq -file client-cert-signing-request.pem -storepass test1234
openssl x509 -req -CA ca-cert.pem -CAkey ca-key.pem -in client-cert-signing-request.pem -out client-cert-signed.pem -days 365 -CAcreateserial -passin pass:test1234
keytool -importkeystore -srckeystore client.keystore.jks -destkeystore client.keystore.p12 -deststoretype PKCS12 -storepass test1234 -srcstorepass test1234
openssl pkcs12 -in client.keystore.p12 -nodes -nocerts -out client-key.pem -passin pass:test1234

并更改了 base/docker-compose-base.yaml 中的 orderer 容器配置

orderer.example.com:
container_name: orderer.example.com
image: hyperledger/fabric-orderer
environment:
- ORDERER_GENERAL_LOGLEVEL=debug
- ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
# enabled TLS
- ORDERER_KAFKA_TLS_ENABLED=true
- ORDERER_KAFKA_TLS_PRIVATEKEY_FILE=/var/private/ssl/client-key.pem
- ORDERER_KAFKA_TLS_CERTIFICATE_FILE=/var/private/ssl/client-cert-signed.pem
- ORDERER_KAFKA_TLS_ROOTCAS_FILE=/var/private/ssl/ca-cert.pem
- ORDERER_KAFKA_VERBOSE=true
- ORDERER_KAFKA_SERVER=kafka
- ORDERER_KAFKA_BROKERS=[kafka:9093]
- ORDERER_GENERAL_TLS_ENABLED=true
- ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key
- ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt
- ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
volumes:
- ../channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/var/hyperledger/orderer/msp
- ../crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls
- ../sample/ca-cert.pem:/var/private/ssl/ca-cert.pem
- ../sample/client-cert-signed.pem:/var/private/ssl/client-cert-signed.pem
- ../sample/client-key.pem:/var/private/ssl/client-key.pem
ports:
- 7050:7050

然后我尝试使用以下命令运行示例

./byfn.sh -m up -s couchdb -a

并在脚本尝试创建新 channel 时收到错误消息

Error: got unexpected status: SERVICE_UNAVAILABLE -- cannot enqueue

Error message when the script try to create new channel

请帮我解决这个错误。

最佳答案

我解决了问题。在 cli 容器中运行 script.sh 之前添加了 sleep 30。文件 docker-compose-cli.yaml

command: /bin/bash -c 'sleep 30; ./scripts/script.sh ${CHANNEL_NAME} ${DELAY} ${LANG}; sleep $TIMEOUT'

关于apache-kafka - Hyperledger Fabric First 网络不与 kafka 一起使用并使用 TLS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47753859/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com