本文介绍了超账结构中的CORE_PEER_ADDRESS是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道在docker文件中定义对等时,我们正在设置环境变量"-CORE_PEER_ADDRESS = peer0.org1.example.com:7051 "那么为什么还要为其他组织使用相同的" 7051 "端口.正如我在下面的文件中看到的那样,他们在org2中定义对等方时,他们使用了相同的端口.我只是想知道这一点.

Hi i just want to know while defining peer in docker file we are setting environment variable "- CORE_PEER_ADDRESS=peer0.org1.example.com:7051" so why there is the same "7051" port for other organization also. as i can see in below file for while defining peer in org2 they used same port.i just want to know about this.

 # Copyright IBM Corp. All Rights Reserved.
 #
 # SPDX-License-Identifier: Apache-2.0
 #

version: '2'

services:

orderer.example.com:
  container_name: orderer.example.com
  image: hyperledger/fabric-orderer:$IMAGE_TAG
  environment:
    - ORDERER_GENERAL_LOGLEVEL=INFO
    - 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_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
  - orderer.example.com:/var/hyperledger/production/orderer
  ports:
    - 7050:7050

peer0.org1.example.com:
  container_name: peer0.org1.example.com
  extends:
    file: peer-base.yaml
    service: peer-base
  environment:
    - CORE_PEER_ID=peer0.org1.example.com
    - CORE_PEER_ADDRESS=peer0.org1.example.com:7051
    - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:7051
    - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
    - CORE_PEER_LOCALMSPID=Org1MSP
  volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls
      - peer0.org1.example.com:/var/hyperledger/production
  ports:
    - 7051:7051
    - 7053:7053

peer1.org1.example.com:
  container_name: peer1.org1.example.com
  extends:
    file: peer-base.yaml
    service: peer-base
  environment:
    - CORE_PEER_ID=peer1.org1.example.com
    - CORE_PEER_ADDRESS=peer1.org1.example.com:7051
    - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051
    - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
    - CORE_PEER_LOCALMSPID=Org1MSP
  volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/etc/hyperledger/fabric/tls
      - peer1.org1.example.com:/var/hyperledger/production

  ports:
    - 8051:7051
    - 8053:7053

peer0.org2.example.com:
  container_name: peer0.org2.example.com
  extends:
    file: peer-base.yaml
    service: peer-base
  environment:
    - CORE_PEER_ID=peer0.org2.example.com
    - CORE_PEER_ADDRESS=peer0.org2.example.com:7051
    - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051
    - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org2.example.com:7051
    - CORE_PEER_LOCALMSPID=Org2MSP
  volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls
      - peer0.org2.example.com:/var/hyperledger/production
  ports:
    - 9051:7051
    - 9053:7053

peer1.org2.example.com:
  container_name: peer1.org2.example.com
  extends:
    file: peer-base.yaml
    service: peer-base
  environment:
    - CORE_PEER_ID=peer1.org2.example.com
    - CORE_PEER_ADDRESS=peer1.org2.example.com:7051
    - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org2.example.com:7051
    - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org2.example.com:7051
    - CORE_PEER_LOCALMSPID=Org2MSP
  volumes:
      - /var/run/:/host/var/run/
      - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp:/etc/hyperledger/fabric/msp
      - ../crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls:/etc/hyperledger/fabric/tls
      - peer1.org2.example.com:/var/hyperledger/production
  ports:
    - 10051:7051
    - 10053:7053

推荐答案

在docker-composer文件中,右侧端口7051属于运行容器的HostOS.

In docker-composer file, right side port 7051 is belong to HostOS where containers are running.

基于此配置,7051端口被映射到左侧的Peer端口,以便与HOST OS进行通信.

Based on this configuration, 7051 port is mapped to Peer port on left side to communicate from HOST OS.

例如,您可以从主机OS运行CLI实用程序.

For example, You can run CLI utility from Host OS.

这篇关于超账结构中的CORE_PEER_ADDRESS是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 12:32