如何使用Hyperledger架构网络配置CouchDb和CA服务器实例?

时间:2019-01-22 04:58:51

标签: docker hyperledger-fabric hyperledger

问题:

我对Hyperledger面料产品非常陌生。我试图从头开始建立一个网络。因此,我在其中创建了docker-compose-base.yaml,peer-base.yaml和docker-compose-cli.yaml文件,并成功建立了网络。现在,我想要的是使用CouchDB和CA服务器建立网络。这样我创建了一个docker-compose-couch.yaml文件。

This is my docker-composer-couch.yaml file.
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

version: "2"

networks:
  byfn:

services:
  couchdb0:
    container_name: couchdb0
    image: hyperledger/fabric-couchdb
    # 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

  peer0.millenniumitesp.trafficfine.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb0

  couchdb1:
    container_name: couchdb1
    image: hyperledger/fabric-couchdb
    # 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:
      - "6984:5984"
    networks:
      - byfn

  peer1.millenniumitesp.trafficfine.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb1

  couchdb2:
    container_name: couchdb2
    image: hyperledger/fabric-couchdb
    # 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:
      - "7984:5984"
    networks:
      - byfn

  peer0.policedepartment.trafficfine.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb2

  couchdb3:
    container_name: couchdb3
    image: hyperledger/fabric-couchdb
    # 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:
      - "8984:5984"
    networks:
      - byfn

  peer1.policedepartment.trafficfine.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb3:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb3

  couchdb4:
    container_name: couchdb4
    image: hyperledger/fabric-couchdb
    # 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:
      - "9984:5984"
    networks:
      - byfn

  peer0.ae.trafficfine.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb4

  couchdb5:
    container_name: couchdb5
    image: hyperledger/fabric-couchdb
    # 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:
      - "10984:5984"
    networks:
      - byfn

  peer1.ae.trafficfine.com:
    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb1:5984
      # The CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME and CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD
      # provide the credentials for ledger to connect to CouchDB.  The username and password must
      # match the username and password set for the associated CouchDB.
      - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=
      - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=
    depends_on:
      - couchdb5

这是我的docker-compose-cli.yaml文件。

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

version: "2"

volumes:
  orderer.trafficfine.com:
  peer0.millenniumitesp.trafficfine.com:
  peer1.millenniumitesp.trafficfine.com:
  peer0.policedepartment.trafficfine.com:
  peer1.policedepartment.trafficfine.com:
  peer0.ae.trafficfine.com:
  peer1.ae.trafficfine.com:

networks:
  byfn:

services:
  orderer.trafficfine.com:
    extends:
      file: base/docker-compose-base.yaml
      service: orderer.trafficfine.com
    container_name: orderer.trafficfine.com
    networks:
      - byfn

  peer0.millenniumitesp.trafficfine.com:
    container_name: peer0.millenniumitesp.trafficfine.com
    extends:
      file: base/docker-compose-base.yaml
      service: peer0.millenniumitesp.trafficfine.com
    networks:
      - byfn

  peer1.millenniumitesp.trafficfine.com:
    container_name: peer1.millenniumitesp.trafficfine.com
    extends:
      file: base/docker-compose-base.yaml
      service: peer1.millenniumitesp.trafficfine.com
    networks:
      - byfn

  peer0.policedepartment.trafficfine.com:
    container_name: peer0.policedepartment.trafficfine.com
    extends:
      file: base/docker-compose-base.yaml
      service: peer0.policedepartment.trafficfine.com
    networks:
      - byfn

  peer1.policedepartment.trafficfine.com:
    container_name: peer1.policedepartment.trafficfine.com
    extends:
      file: base/docker-compose-base.yaml
      service: peer1.policedepartment.trafficfine.com
    networks:
      - byfn

  peer0.ae.trafficfine.com:
    container_name: peer0.ae.trafficfine.com
    extends:
      file: base/docker-compose-base.yaml
      service: peer0.ae.trafficfine.com
    networks:
      - byfn

  peer1.ae.trafficfine.com:
    container_name: peer1.ae.trafficfine.com
    extends:
      file: base/docker-compose-base.yaml
      service: peer1.ae.trafficfine.com
    networks:
      - byfn

  cli:
    container_name: cli
    image: hyperledger/fabric-tools:latest
    tty: true
    stdin_open: true
    environment:
      - GOPATH=/opt/gopath
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      #- CORE_LOGGING_LEVEL=DEBUG
      - CORE_LOGGING_LEVEL=INFO
      - CORE_PEER_ID=cli
      - CORE_PEER_ADDRESS=peer0.millenniumitesp.trafficfine.com:7051
      - CORE_PEER_LOCALMSPID=MillenniumitespMSP
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/millenniumitesp.trafficfine.com/peers/peer0.millenniumitesp.trafficfine.com/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/millenniumitesp.trafficfine.com/peers/peer0.millenniumitesp.trafficfine.com/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/millenniumitesp.trafficfine.com/peers/peer0.millenniumitesp.trafficfine.com/tls/ca.crt
      - CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/millenniumitesp.trafficfine.com/users/Admin@millenniumitesp.trafficfine.com/msp
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
    command: /bin/bash
    volumes:
      - /var/run/:/host/var/run/
      - ./../chaincode/:/opt/gopath/src/github.com/chaincode
      - ./crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
      - ./scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
      - ./channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
    depends_on:
      - orderer.trafficfine.com
      - peer0.millenniumitesp.trafficfine.com
      - peer1.millenniumitesp.trafficfine.com
      - peer0.policedepartment.trafficfine.com
      - peer1.policedepartment.trafficfine.com
      - peer0.ae.trafficfine.com
      - peer1.ae.trafficfine.com
    networks:
      - byfn

这是我的docker-compose-base.yaml文件

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

version: "2"

services:
  orderer.trafficfine.com:
    container_name: orderer.trafficfine.com
    image: hyperledger/fabric-orderer:latest
    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/trafficfine.com/orderers/orderer.trafficfine.com/msp:/var/hyperledger/orderer/msp
      - ../crypto-config/ordererOrganizations/trafficfine.com/orderers/orderer.trafficfine.com/tls/:/var/hyperledger/orderer/tls
      - orderer.trafficfine.com:/var/hyperledger/production/orderer
    ports:
      - 7050:7050

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

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

    ports:
      - 8051:7051
      - 8053:7053

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

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

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

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

有人可以告诉我应该编辑哪些文件以及如何编辑这些文件,从而可以帮助我通过网络设置沙发数据库实例和ca服务器。谢谢!

0 个答案:

没有答案