简体   繁体   English

在不同容器端口中设置 hyperledger fabric 2.0 时的问题(测试和开发)

[英]Issues while Setting up hyperledger fabric 2.0 in different container ports (Testing & Devlopment)

I have been working on Hyperledger fabric 2.0 Multi-Org Networking running under default ports.我一直在研究在默认端口下运行的 Hyperledger fabric 2.0 Multi-Org Networking。 The setup is as follows:设置如下:

Org1 ( Peer0:7051, Peer1:8051, CA: 7054 ,couchdb0:5984, couchdb1:6984:5984)
Org2 ( Peer0:9051, Peer1:10051, CA: 8054,couchdb2:7984:5984, couchdb3:8984:5984)
Orderer (0rderer1:7050, Orderer2:8050, Orderer3: 9050) RAFT Mechanism

The requirement is to redefine all the container ports mentioned above so that I can run the same Fabric application as two environments ( One for Testing(Stable version) and one for Development ) I tried to change the ports (Specifying environmental variables for ports in docker-compose) of Peers, orderers, CA.要求是重新定义上面提到的所有容器端口,以便我可以将相同的 Fabric 应用程序作为两个环境运行(一个用于测试(稳定版),一个用于开发)我尝试更改端口(为 docker 中的端口指定环境变量-compose) 的 Peers、orderers、CA。 But I don't have any option for the CouchDB which always has the default port(5984)但是对于始终具有默认端口(5984)的 CouchDB,我没有任何选项

Is there any way to achieve this?有什么办法可以做到这一点? so that it will also be helpful in running two different fabric applications in the same virtual machine因此它也有助于在同一虚拟机中运行两个不同的结构应用程序

EDIT1: My docker-compose.yaml file (I have only mentioned for- Org1(Peer0,peer1), Orderer1,ca-org1, couchdb0,couchdb1) EDIT1:我的 docker-compose.yaml 文件(我只提到了 for-Org1(Peer0,peer1), Orderer1,ca-org1, couchdb0,couchdb1)

version: "2"

networks:
  test2:

services:
  ca-org1:
    image: hyperledger/fabric-ca
    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca.org1.test.com
      - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.test.com-cert.pem
      - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/priv_sk
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-tls/tlsca.org1.test.com-cert.pem
      - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-tls/priv_sk
    ports:
      - "3054:3054"
    command: sh -c 'fabric-ca-server start -b admin:adminpw -d'
    volumes:
      - ./channel/crypto-config/peerOrganizations/org1.test.com/ca/:/etc/hyperledger/fabric-ca-server-config
      - ./channel/crypto-config/peerOrganizations/org1.test.com/tlsca/:/etc/hyperledger/fabric-ca-server-tls
    container_name: ca.org1.test.com
    hostname: ca.org1.test.com
    networks:
      - test2

  orderer.test.com:
    container_name: orderer.test.com
    image: hyperledger/fabric-orderer:2.1
    dns_search: .
    environment:
      - ORDERER_GENERAL_LOGLEVEL=info
      - FABRIC_LOGGING_SPEC=INFO
      - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0
      - ORDERER_GENERAL_GENESISMETHOD=file
      - ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/genesis.block
      - ORDERER_GENERAL_LOCALMSPID=OrdererMSP
      - ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
      - 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]
      - ORDERER_KAFKA_VERBOSE=true
      - ORDERER_GENERAL_CLUSTER_CLIENTCERTIFICATE=/var/hyperledger/orderer/tls/server.crt
      - ORDERER_GENERAL_CLUSTER_CLIENTPRIVATEKEY=/var/hyperledger/orderer/tls/server.key
      - ORDERER_GENERAL_CLUSTER_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt]
      - ORDERER_METRICS_PROVIDER=prometheus
      - ORDERER_OPERATIONS_LISTENADDRESS=0.0.0.0:3443
      - ORDERER_GENERAL_LISTENPORT=3050
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderers
    command: orderer
    ports:
      - 3050:3050
      - 3443:3443
    networks:
      - test2
    volumes:
      - ./channel/genesis.block:/var/hyperledger/orderer/genesis.block
      - ./channel/crypto-config/ordererOrganizations/test.com/orderers/orderer.test.com/msp:/var/hyperledger/orderer/msp
      - ./channel/crypto-config/ordererOrganizations/test.com/orderers/orderer.test.com/tls:/var/hyperledger/orderer/tls

  couchdb0:
    container_name: couchdb0-test
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - 1984:1984
    networks:
      - test2

  couchdb1:
    container_name: couchdb1-test
    image: hyperledger/fabric-couchdb
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    ports:
      - 2984:1984
    networks:
      - test2

  
  peer0.org1.test.com:
    container_name: peer0.org1.test.com
    extends:
      file: base.yaml
      service: peer-base
    environment:
      - FABRIC_LOGGING_SPEC=DEBUG
      - ORDERER_GENERAL_LOGLEVEL=DEBUG
      - CORE_PEER_LOCALMSPID=Org1MSP

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=artifacts_test2

      - CORE_PEER_ID=peer0.org1.test.com
      - CORE_PEER_ADDRESS=peer0.org1.test.com:3051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:3051
      - CORE_PEER_CHAINCODEADDRESS=peer0.org1.test.com:3052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:3052
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.test.com:4051
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.test.com:3051

      # - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9440

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0-test:1984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
      - CORE_METRICS_PROVIDER=prometheus
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/crypto/peer/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/crypto/peer/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/crypto/peer/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/crypto/peer/msp
    depends_on:
      - couchdb0
    ports:
      - 3051:3051
    volumes:
      - ./channel/crypto-config/peerOrganizations/org1.test.com/peers/peer0.org1.test.com/msp:/etc/hyperledger/crypto/peer/msp
      - ./channel/crypto-config/peerOrganizations/org1.test.com/peers/peer0.org1.test.com/tls:/etc/hyperledger/crypto/peer/tls
      - /var/run/:/host/var/run/
      - ./channel/:/etc/hyperledger/channel/
    networks:
      - test2

  peer1.org1.test.com:
    container_name: peer1.org1.test.com
    extends:
      file: base.yaml
      service: peer-base
    environment:
      - FABRIC_LOGGING_SPEC=DEBUG
      - ORDERER_GENERAL_LOGLEVEL=debug
      - CORE_PEER_LOCALMSPID=Org1MSP

      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=artifacts_test2

      - CORE_PEER_ID=peer1.org1.test.com
      - CORE_PEER_ADDRESS=peer1.org1.test.com:4051
      - CORE_PEER_LISTENADDRESS=0.0.0.0:4051
      - CORE_PEER_CHAINCODEADDRESS=peer1.org1.test.com:4052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:4052
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.test.com:4051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.test.com:3051

      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1-test:1984
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
      - CORE_METRICS_PROVIDER=prometheus
      # - CORE_OPERATIONS_LISTENADDRESS=0.0.0.0:9440
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/crypto/peer/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/crypto/peer/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/crypto/peer/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/crypto/peer/msp
    ports:
      - 4051:4051
    volumes:
      - ./channel/crypto-config/peerOrganizations/org1.test.com/peers/peer1.org1.test.com/msp:/etc/hyperledger/crypto/peer/msp
      - ./channel/crypto-config/peerOrganizations/org1.test.com/peers/peer1.org1.test.com/tls:/etc/hyperledger/crypto/peer/tls
      - /var/run/:/host/var/run/
      - ./channel/:/etc/hyperledger/channel/
    networks:
      - test2


Thanks for the suggestions regarding couchDB.感谢您提供有关 couchDB 的建议。 I had a thought that we should only specify the default couchDB port each instance.我有一个想法,我们应该只为每个实例指定默认的 couchDB 端口。 Anyway I missed the step of changing the container name in the first place (default peer0.org1.example.com to peer0.org1.test.com) I was able to start the docker containers with new container names so that it doesn't stop(recreate) the existing containers which is already running on the actual ports.无论如何,我首先错过了更改容器名称的步骤(默认 peer0.org1.example.com 到 peer0.org1.test.com)我能够使用新容器名称启动 docker 容器,这样它就不会停止(重新创建)已经在实际端口上运行的现有容器。 The issue which I am facing now is peer is not able to communicate with the couchdb-test url我现在面临的问题是 peer 无法与 couchdb-test url 通信

U 04c Entering VerifyCouchConfig()
2020-08-12 11:22:45.010 UTC [couchdb] handleRequest -> DEBU 04d Entering handleRequest()  method=GET  url=http://couchdb1-test:1984/  dbName=
2020-08-12 11:22:45.010 UTC [couchdb] handleRequest -> DEBU 04e Request URL: http://couchdb1-test:1984/
2020-08-12 11:22:45.011 UTC [couchdb] handleRequest -> WARN 04f Retrying couchdb request in 125ms. Attempt:1  Error:Get "http://couchdb1-test:1984/": dial tcp 172.27.0.11:1984: connect: connection refused
2020-08-12 11:22:45.137 UTC [couchdb] handleRequest -> WARN 050 Retrying couchdb request in 250ms. Attempt:2  Error:Get "http://couchdb1-test:1984/": dial tcp 172.27.0.11:1984: connect: connection refused
2020-08-12 11:22:45.389 UTC [couchdb] handleRequest -> WARN 051 Retrying couchdb request in 500ms. Attempt:3  Error:Get "http://couchdb1-test:1984/": dial tcp 172.27.0.11:1984: connect: connection refused

Hence if I try to create a channel, peer container exits even though it was running till now and it's not able to join the channel因此,如果我尝试创建一个频道,即使它一直运行到现在,对等容器也会退出并且它无法加入频道

2020-08-12 10:58:29.264 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-08-12 10:58:29.301 UTC [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND}
2020-08-12 10:58:29.305 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-08-12 10:58:29.506 UTC [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-08-12 10:58:29.509 UTC [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
2020-08-12 10:58:29.710 UTC [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-08-12 10:58:29.713 UTC [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
2020-08-12 10:58:29.916 UTC [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-08-12 10:58:29.922 UTC [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
2020-08-12 10:58:30.123 UTC [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-08-12 10:58:30.126 UTC [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
2020-08-12 10:58:30.327 UTC [cli.common] readBlock -> INFO 00c Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-08-12 10:58:30.331 UTC [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized
2020-08-12 10:58:30.534 UTC [cli.common] readBlock -> INFO 00e Received block: 0
Error: error getting endorser client for channel: endorser client failed to connect to localhost:3051: failed to create new connection: connection error: desc = "transport: authentication handshake failed: read tcp 127.0.0.1:53668->127.0.0.1:3051: read: connection reset by peer"
Error: error getting endorser client for channel: endorser client failed to connect to localhost:4051: failed to create new connection: connection error: desc = "transport: authentication handshake failed: read tcp 127.0.0.1:60724->127.0.0.1:4051: read: connection reset by peer"
Error: error getting endorser client for channel: endorser client failed to connect to localhost:5051: failed to create new connection: connection error: desc = "transport: authentication handshake failed: read tcp 127.0.0.1:57948->127.0.0.1:5051: read: connection reset by peer"
Error: error getting endorser client for channel: endorser client failed to connect to localhost:6051: failed to create new connection: connection error: desc = "transport: authentication handshake failed: read tcp 127.0.0.1:58976->127.0.0.1:6051: read: connection reset by peer"
2020-08-12 10:58:37.518 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-08-12 10:58:37.552 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
2020-08-12 10:58:37.685 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-08-12 10:58:37.763 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update

Here, only the Orderers are successfully added to the channel but not the peers even after changing the ports.在这里,即使更改了端口,也只有 Orderers 成功添加到通道中,而 peer 没有成功添加到通道中。

You can change the couchDb port from the docker-compose file.您可以从 docker-compose 文件更改 couchDb 端口。 Showing a snippet from docekr-compose.yaml file.显示来自docekr-compose.yaml文件的片段。

  couchdb0:
    container_name: couchdb0
    image: couchdb:2.3
    # Populate the COUCHDB_USER and COUCHDB_PASSWORD to set an admin user and password
    # for CouchDB.  This will prevent CouchDB from operating in an "Admin Party" mode.
    environment:
      - COUCHDB_USER=
      - COUCHDB_PASSWORD=
    # Comment/Uncomment the port mapping if you want to hide/expose the CouchDB service,
    # for example map it to utilize Fauxton User Interface in dev environments.
    ports:
      - "5984:5984"
    networks:
      - byfn

From here you can change ports easily.从这里您可以轻松更改端口。

This isnt an issue, you can just specify it as you did for the others like this.这不是问题,您可以像对其他人一样指定它。 Are you facing some specific issues while mapping the ports您在映射端口时是否面临一些特定问题

ports:
  - 6984:5984 # Mapping Host Port to Container Port

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM