2017-09-12 11 views
1

我已經在開發環境中開發了一個包含hyperledge composer的區塊鏈網絡,如文檔所示。我已經測試過它並且工作得很好。所以我想建立一個生產網絡。此時,我的第一個目標是在同一臺服務器上爲開發環境添加更多的同行以學習。我看了startFabric.sh,我編輯了docker文件和這個sh,但它不起作用。我附加了兩個從原始代碼編輯的文件。它引發我的錯誤是peer1的容器不起作用。數據庫2正在工作。 我在論壇上搜索瞭如何添加更多的同伴,但我沒有找到一個好的指導,以瞭解如何一步一步做。 所以我的問題,我做了什麼壞事?你知道一個很好的教程,以瞭解如何在開發環境中添加更多的同行嗎? 謝謝我該如何添加更多的同齡人到使用hyperledge作曲家開發的網絡區塊鏈?

startFabric.sh

#!/bin/bash 

# Exit on first error, print all commands. 
set -ev 

#Detect architecture 
ARCH=`uname -m` 

# Grab the current directory 
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 

# 
cd "${DIR}"/composer 

ARCH=$ARCH docker-compose -f "${DIR}"/composer/docker-compose.yml down 
ARCH=$ARCH docker-compose -f "${DIR}"/composer/docker-compose.yml up -d 

# wait for Hyperledger Fabric to start 
# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number> 
echo ${FABRIC_START_TIMEOUT} 
sleep ${FABRIC_START_TIMEOUT} 

# Create the channel 
docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx 
docker exec peer1.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel1.tx 


# Join peer0.org1.example.com to the channel. 
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b composerchannel.block 
docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer1.org1.example.com peer channel join -b composerchannel.block 


cd ../.. 

泊塢窗,composer.yml

version: '2' 

services: 
    ca.org1.example.com: 
    image: hyperledger/fabric-ca:$ARCH-1.0.1 
    environment: 
     - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server 
     - FABRIC_CA_SERVER_CA_NAME=ca.org1.example.com 
#  - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/org1.example.com-cert.pem 
#  - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/a22daf356b2aab5792ea53e35f66fccef1d7f1aa2b3a2b92dbfbf96a448ea26a_sk 

    ports: 
     - "7054:7054" 
    command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/19ab65a$ 
    volumes: 
     - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config 
    container_name: ca.org1.example.com 

    orderer.example.com: 
    container_name: orderer.example.com 
    image: hyperledger/fabric-orderer:$ARCH-1.0.1 
    environment: 
     - ORDERER_GENERAL_LOGLEVEL=debug 
     - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 
     - ORDERER_GENERAL_GENESISMETHOD=file 
     - ORDERER_GENERAL_GENESISFILE=/etc/hyperledger/configtx/composer-genesis.block 
     - ORDERER_GENERAL_LOCALMSPID=OrdererMSP 
     - ORDERER_GENERAL_LOCALMSPDIR=/etc/hyperledger/msp/orderer/msp 
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric 
    command: orderer 
    ports: 
     - 7050:7050 
    volumes: 
     - ./:/etc/hyperledger/configtx 
     - ./crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp:/etc/hyperledger/msp/orderer/msp 

    peer0.org1.example.com: 
    container_name: peer0.org1.example.com 
    image: hyperledger/fabric-peer:$ARCH-1.0.1 
    environment: 
     - CORE_LOGGING_PEER=debug 
     - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG 
     - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock 
     - CORE_PEER_ID=peer0.org1.example.com 
     - CORE_PEER_ADDRESS=peer0.org1.example.com:7051 
     - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=composer_default 
     - CORE_PEER_LOCALMSPID=Org1MSP 
     - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peer/msp 
     - CORE_LEDGER_STATE_STATEDATABASE=CouchDB 
     - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb:5984 
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric 
    command: peer node start --peer-defaultchain=false 
    ports: 
     - 7051:7051 
     - 7053:7053 
    volumes: 
     - /var/run/:/host/var/run/ 
     - ./:/etc/hyperledger/configtx 
     - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/peer/msp 
     - ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users 
    depends_on: 
     - orderer.example.com 
     - couchdb 

    couchdb: 
    container_name: couchdb 
    image: hyperledger/fabric-couchdb:$ARCH-1.0.1 
    ports: 
     - 5984:5984 
    environment: 
     DB_URL: http://localhost:5984/member_db 


    peer1.org1.example.com: 
    container_name: peer1.org1.example.com 
    image: hyperledger/fabric-peer:$ARCH-1.0.1 
    environment: 
     - CORE_LOGGING_PEER=debug 
     - CORE_CHAINCODE_LOGGING_LEVEL=DEBUG 
     - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock 
     - CORE_PEER_ID=peer1.org1.example.com 
     - CORE_PEER_ADDRESS=peer1.org1.example.com:7051 
     - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=composer_default 
     - CORE_PEER_LOCALMSPID=Org1MSP 
     - CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/peer/msp 
     - CORE_LEDGER_STATE_STATEDATABASE=CouchDB 
     - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb2:5985 
    working_dir: /opt/gopath/src/github.com/hyperledger/fabric 
    command: peer node start --peer-defaultchain=false 
    ports: 
     - 7061:7061 
     - 7063:7063 
    volumes: 
     - /var/run/:/host/var/run/ 
     - ./:/etc/hyperledger/configtx 
     - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/etc/hyperledger/peer/msp 
     - ./crypto-config/peerOrganizations/org1.example.com/users:/etc/hyperledger/msp/users 
    depends_on: 
     - orderer.example.com 
     - couchdb2 


    couchdb2: 
    container_name: couchdb2 
    image: hyperledger/fabric-couchdb:$ARCH-1.0.1 
    ports: 
     - 5985:5985 
    environment: 
     DB_URL: http://localhost:5984/member_db 

回答

1

我們僅用於開發提供了一個基本Hyperledger佈網,並不意味着是一個例子,演示如何構建一個。 Hyperledger Composer將與任何Hyperledger Fabric設置一起使用正確的連接配置文件和Hyperledger Fabric提供文檔和示例,說明如何構建您自己的網絡,我認爲您需要的是 請參閱https://hyperledger-fabric.readthedocs.io/en/latest/build_network.html 關於如何構建您自己的網絡並參見 https://hyperledger.github.io/composer/reference/connectionprofile.html 瞭解有關作曲家連接配置文件的信息。 也看到 Does composer support endorsement policy? How? 它提供了有關多組織網絡的一些信息和連接配置文件

+0

感謝信息。我不知道它適用於hyperledger結構。我將閱讀並嘗試它們,如果我有其他問題或者它解決了我的所有問題,我會告訴你。 – cansado2930

+0

我已經構建了名爲first-network的示例,並且我已經爲org1添加了一個對等項,因此org2上有3個對等項,而org2上有2個對等項。然後,我編輯了文件以創建新的對等體,並且它可以正常工作,它已啓動。然後,我已經去了scripts/script.sh以編輯,因爲對等體已經創建,但沒有加入到頻道。所以,我已經編輯了這個函數來添加新的對等體,但是它啓動了一個錯誤,因爲證書對於peer1.org1有效,但對於peer2.org1不是。那麼我爲什麼沒有正確定義新的對等體以失敗連接過程呢?謝謝 – cansado2930

相關問題