Hyperledger fabric hyperledger结构与连接订购程序发生多主机错误

Hyperledger fabric hyperledger结构与连接订购程序发生多主机错误,hyperledger-fabric,hyperledger,docker-swarm,Hyperledger Fabric,Hyperledger,Docker Swarm,我正在尝试使用hyperledger fabric 1.2连接多主机 我用了docker swarm和virtualbox 我用PC1执行了这段代码 docker swarm init docker swarm join-token manager docker network create --attachable --driver overlay byfn 并执行类似这样的代码以使其加入PC1 docker swarm join — token SWMTKN-1–3as8cvf3yxk8e

我正在尝试使用hyperledger fabric 1.2连接多主机

我用了docker swarm和virtualbox

我用PC1执行了这段代码

docker swarm init
docker swarm join-token manager
docker network create --attachable --driver overlay byfn
并执行类似这样的代码以使其加入PC1

docker swarm join — token SWMTKN-1–3as8cvf3yxk8e7zj98954jhjza3w75mngmxh543llgpo0c8k7z-61zyibtaqjjimkqj8p6t9lwgu 172.16.0.153:2377
并在PC1上的单独终端中执行每个PC1命令

并在PC2上的单独终端中执行每个PC2命令

但是,当我执行cli命令时,出现了错误

2018-08-07 01:53:32.659 UTC [grpc] Printf -> DEBU 040 grpc: addrConn.createTransport failed to connect to {0.0.0.0:7050 0  <nil>}. Err :connection error: desc = "transport: Error while dialing dial tcp 0.0.0.0:7050: connect: connection refused". Reconnecting...
2018-08-07 01:53:32.659 UTC [grpc] Printf -> DEBU 041 pickfirstBalancer: HandleSubConnStateChange: 0xc420460ad0, TRANSIENT_FAILURE
2018-08-07 01:53:34.326 UTC [grpc] Printf -> DEBU 042 pickfirstBalancer: HandleSubConnStateChange: 0xc420460ad0, CONNECTING
2018-08-07 01:53:34.328 UTC [grpc] Printf -> DEBU 043 grpc: addrConn.createTransport failed to connect to {0.0.0.0:7050 0  <nil>}. Err :connection error: desc = "transport: Error while dialing dial tcp 0.0.0.0:7050: connect: connection refused". Reconnecting...
2018-08-07 01:53:34.328 UTC [grpc] Printf -> DEBU 044 pickfirstBalancer: HandleSubConnStateChange: 0xc420460ad0, TRANSIENT_FAILURE
Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========
我指的是这个网站

网络拓扑

PC1

  • CA1
  • 订购者
  • PEER0(ORG1)
PC2

  • PEER0(ORG2)
  • CLI
PC1 钙 CA1 订购者 皮尔 PC2 皮尔 cli script.sh
#/bin/bash
回声
回声“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”
回声“/_124; 124; 124; 124;/\\\\\\\\\\\\\\\\\\\\\\\\\\\”
回声“\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
回声“uuuuuuuuuuuu124; | |/uuuuuu124; |<| |”
回声“| | | | | | | | | | | | | | | | | | | | | | | | | |
回声
echo“构建您的第一个网络(BYFN)端到端测试”
回声
频道名称=“$1”
延迟=“2美元”
语言=“3美元”
超时=“4美元”
VERBOSE=“$5”
:${CHANNEL_NAME:=“mychannel”}
:${DELAY:=“3”}
:${语言:=“golang”}
:${TIMEOUT:=“10”}
:${VERBOSE:=“false”}
LANGUAGE=`echo“$LANGUAGE”| tr[:上限:[:下限:]`
计数器=1
最大重试次数=5
CC_SRC_PATH=“github.com/chaincode/chaincode\u example02/go/”
如果[“$LANGUAGE”=“node”];然后
CC_SRC_PATH=“/opt/gopath/SRC/github.com/chaincode/chaincode_example02/node/”
fi
echo“频道名称:$Channel\u name
#导入UTIL
. 脚本/utils.sh
createChannel(){
setGlobals 0 1
如果[-z”$CORE\u PEER\u TLS\u ENABLED“-o”$CORE\u PEER\u TLS\u ENABLED”=“false”];则
集合x
对等通道创建-o order.example.com:7050-c$channel\u NAME-f./channel artifacts/channel.tx>&log.txt
res=$?
集合+x
其他的
集合x
对等通道创建-o order.example.com:7050-c$channel\u NAME-f./channel artifacts/channel.tx--tls$CORE\u peer\u tls\u ENABLED--cafile$order\u CA>&log.txt
res=$?
集合+x
fi
cat log.txt
verifyResult$res“频道创建失败”
echo“====================================================================================================================================”
回声
}
joinChannel(){
对于12中的组织,请执行以下操作
对于0 1中的对等方;请执行以下操作
joinChannelWithRetry$peer$org
echo“=====================================peer${peer}.org${org}加入了频道“$channel_NAME”===============================”
睡眠延迟
回声
完成
完成
}
##创建频道
echo“正在创建频道…”
创建频道
##将所有对等方加入该频道
echo“让所有对等方加入通道…”
连接通道
##为频道中的每个组织设置锚节点
echo“正在更新org1的锚节点…”
UpdateAnchor0 1
echo“正在更新org2的锚节点…”
更新0 2
##在peer0.org1和peer0.org2上安装链码
echo“在peer0.org1上安装链码…”
安装链代码0 1
echo“在peer0.org2上安装链码…”
安装链代码0 2
#在peer0.org2上实例化链码
#echo“在peer0.org2上实例化链码…”
#实例化代码0 2
#查询peer0.org1上的链码
#echo“查询peer0.org1上的链码…”
#chaincodeQuery 0 1 100
#在peer0.org1和peer0.org2上调用链码
#echo“在peer0.org1 peer0.org2上发送调用事务…”
#chaincodeInvoke 0 1 0 2
##在peer1.org2上安装链码
#echo“在peer1.org2上安装链码…”
#安装代码1 2
#查询peer1.org2上的链码,检查结果是否为90
#echo“查询peer1.org2上的链码…”
#链码查询1 2 90
回声
echo“=============一切正常,BYFN执行已完成=================”
回声
回声
回声“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuu”
回声“||||||||||”
回声“|||||||||”
回声“| | | | | | | | | | |”
回声“||||||||||||||
回声
出口0

我刚刚解决了同样的问题,只是删除了fabric和卷的所有docker图像。并重新安装结构版本1.2.0-rc1
curl-sSL http://url/2ysbOFE | bash-s1.2.0-rc1
url:bit dot ly我无法发布该url

编辑:您可以检查docker容器是否有一些功能问题?带有docker日志\u容器\u名称_ 在“容器名称”中,您应该输入死容器的容器名称,您可以使用
docker ps-a
,即“退出(n次)前”进行签出。
如果您的功能有问题,请使用configtx.yaml中的功能。其中一个问题可能是您有一个旧版本的cryptogen工具,如果您指向它的旧版本,则您的加密文件必须全部损坏,您应该始终指向下载的版本和示例

另一个解决方案是在两台电脑上都禁用防火墙,确保它们可以看到对方,并打开相应的端口,还应该在docker compose文件中添加一个
额外主机
部分(查看下面的链接,我在博客中讨论)

如果您已经运行了很多测试,请清理所有图像和容器,这总是有帮助的

如果这些都不管用的话,我写了一个基于基本网络示例的教程,以及如何在多台主机上运行它,也许您可以从中获取一些信息


如果您有疑问,请随时提问

您是否尝试禁用防火墙?
2018-08-07 06:29:04.357 UTC [grpc] Println -> DEBU 0c6 grpc: Server.Serve failed to create ServerTransport:  connection error: desc = "transport: http2Server.HandleStreams received bogus greeting from client: \"\\x16\\x03\\x01\\x00\\xb2\\x01\\x00\\x00\\xae\\x03\\x03\\x04w\\xffLbc0\\x94\\xec\\x8cV\\xdfa\""
2018-08-07 06:29:05.340 UTC [grpc] Println -> DEBU 0c7 grpc: Server.Serve failed to create ServerTransport:  connection error: desc = "transport: http2Server.HandleStreams received bogus greeting from client: \"\\x16\\x03\\x01\\x00\\xb2\\x01\\x00\\x00\\xae\\x03\\x03\\xb6\\x8cU-\\xfa\\xd8&\\x8fp\\x16(:\\xa4\""
2018-08-07 06:29:07.053 UTC [grpc] Println -> DEBU 0c8 grpc: Server.Serve failed to create ServerTransport:  connection error: desc = "transport: http2Server.HandleStreams received bogus greeting from client: \"\\x16\\x03\\x01\\x00\\xb2\\x01\\x00\\x00\\xae\\x03\\x03\\xfe\\xcf\\xd1\\xea,7we\\xa3\\x10Γ\\x06\""
docker run --rm -it --network="byfn" --name ca_peerOrg1 \
-p 7054:7054 \
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=byfn \
-e FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server \
-e FABRIC_CA_SERVER_CA_NAME=ca-org1 \
-e FABRIC_CA_SERVER_TLS_ENABLED=true \
-e FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem \
-e FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/e723fd0eac7f338381b2bb7f74b417ae42ed28b3c47faaa119837f2405c337da_sk \
-v $PWD/crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config \
hyperledger/fabric-ca \
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/e723fd0eac7f338381b2bb7f74b417ae42ed28b3c47faaa119837f2405c337da_sk -b admin:adminpw -d'
docker run --rm -it --network="byfn" --name ca_peerOrg2 
-p 8054:7054 
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=byfn 
-e FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server 
-e FABRIC_CA_SERVER_CA_NAME=ca-org2 
-e FABRIC_CA_SERVER_TLS_ENABLED=true 
-e FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem 
-e FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/3d8b514fa72a496e6715413d4c2dec90c335c827c7049a8de0aa712435ce1f7f_sk 
-v $PWD/crypto-config/peerOrganizations/org2.example.com/ca/:/etc/hyperledger/fabric-ca-server-config 
hyperledger/fabric-ca 
sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org2.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/3d8b514fa72a496e6715413d4c2dec90c335c827c7049a8de0aa712435ce1f7f_sk -b admin:adminpw -d'
docker run --rm -it --network="byfn" --name orderer.example.com \
-p 7050:7050 \
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=byfn \
-e ORDERER_GENERAL_LOGLEVEL=DEBUG \
-e ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 \
-e ORDERER_GENERAL_LISTENPORT=7050 \
-e ORDERER_GENERAL_GENESISMETHOD=file \
-e ORDERER_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block \
-e ORDERER_GENERAL_LOCALMSPID=OrdererMSP \
-e ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp \
-e ORDERER_GENERAL_TLS_ENABLED=false \
-e ORDERER_GENERAL_TLS_PRIVATEKEY=/var/hyperledger/orderer/tls/server.key \
-e ORDERER_GENERAL_TLS_CERTIFICATE=/var/hyperledger/orderer/tls/server.crt \
-e ORDERER_GENERAL_TLS_ROOTCAS=[/var/hyperledger/orderer/tls/ca.crt] \
-v $PWD/channel-artifacts/genesis.block:/var/hyperledger/orderer/orderer.genesis.block \
-v $PWD/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/:/var/hyperledger/orderer/msp \
-v $PWD/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/:/var/hyperledger/orderer/tls \
-v orderer.example.com:/var/hyperledger/production/orderer \
-w /opt/gopath/src/github.com/hyperledger/fabric \
hyperledger/fabric-orderer \
orderer
docker run --rm -it --network="byfn" --name peer0.org1.example.com \
--link orderer.example.com:orderer.example.com \
-p 7051:7051 \
-p 7053:7053 \
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=byfn \
-e CORE_PEER_ID=peer0.org1.example.com \
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 \
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051 \
-e CORE_PEER_LOCALMSPID=Org1MSP \
-e CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock \
-e CORE_LOGGING_LEVEL=DEBUG \
-e CORE_PEER_TLS_ENABLED=true \
-e CORE_PEER_GOSSIP_USELEADERELECTION=true \
-e CORE_PEER_GOSSIP_ORGLEADER=false \
-e CORE_PEER_PROFILE_ENABLED=true \
-e CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt \
-e CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key \
-e CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt \
-v /var/run/:/host/var/run/ \
-v $PWD/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/etc/hyperledger/fabric/msp \
-v $PWD/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/etc/hyperledger/fabric/tls \
-v peer0.org1.example.com:/var/hyperledger/production \
-w /opt/gopath/src/github.com/hyperledger/fabric/peer \
hyperledger/fabric-peer \
peer node start
docker run --rm -it --network="byfn" --name peer0.org2.example.com \
--link orderer.example.com:orderer.example.com \
-p 9051:7051 \
-p 9053:7053 \
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=byfn \
-e CORE_PEER_ID=peer0.org2.example.com \
-e CORE_PEER_ADDRESS=peer0.org2.example.com:7051 \
-e CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org2.example.com:7051 \
-e CORE_PEER_LOCALMSPID=Org2MSP \
-e CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock \
-e CORE_LOGGING_LEVEL=DEBUG \
-e CORE_PEER_TLS_ENABLED=true \
-e CORE_PEER_GOSSIP_USELEADERELECTION=true \
-e CORE_PEER_GOSSIP_ORGLEADER=false \
-e CORE_PEER_PROFILE_ENABLED=true \
-e CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt \
-e CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key \
-e CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt \
-v /var/run/:/host/var/run/ \
-v $PWD/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp:/etc/hyperledger/fabric/msp \
-v $PWD/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls:/etc/hyperledger/fabric/tls \
-v peer0.org2.example.com:/var/hyperledger/production \
-w /opt/gopath/src/github.com/hyperledger/fabric/peer \
hyperledger/fabric-peer \
peer node start
docker run --rm -it --network="byfn" --name cli \
--link orderer.example.com:orderer.example.com \
--link peer0.org1.example.com:peer0.org1.example.com \
--link peer0.org2.example.com:peer0.org2.example.com \
-p 12051:7051 \
-p 12053:7053 \
-e CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=byfn \
-e GOPATH=/opt/gopath \
-e CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock \
-e CORE_LOGGING_LEVEL=DEBUG \
-e CORE_PEER_ID=cli \
-e CORE_PEER_ADDRESS=peer0.org1.example.com:7051 \
-e CORE_PEER_LOCALMSPID=Org1MSP \
-e CORE_PEER_TLS_ENABLED=true \
-e CORE_PEER_TLS_CERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt \
-e CORE_PEER_TLS_KEY_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key \
-e CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt \
-e CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp \
-v /var/run/:/host/var/run/ \
-v $PWD/crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ \
-v $PWD/scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/ \
-v $PWD/channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts \
-v $HOME/fabric-samples/chaincode/:/opt/gopath/src/github.com/chaincode \
-w /opt/gopath/src/github.com/hyperledger/fabric/peer \
hyperledger/fabric-tools \
/bin/bash \
-c './scripts/script.sh'
#!/bin/bash

echo
echo " ____    _____      _      ____    _____ "
echo "/ ___|  |_   _|    / \    |  _ \  |_   _|"
echo "\___ \    | |     / _ \   | |_) |   | |  "
echo " ___) |   | |    / ___ \  |  _ <    | |  "
echo "|____/    |_|   /_/   \_\ |_| \_\   |_|  "
echo
echo "Build your first network (BYFN) end-to-end test"
echo
CHANNEL_NAME="$1"
DELAY="$2"
LANGUAGE="$3"
TIMEOUT="$4"
VERBOSE="$5"
: ${CHANNEL_NAME:="mychannel"}
: ${DELAY:="3"}
: ${LANGUAGE:="golang"}
: ${TIMEOUT:="10"}
: ${VERBOSE:="false"}
LANGUAGE=`echo "$LANGUAGE" | tr [:upper:] [:lower:]`
COUNTER=1
MAX_RETRY=5

CC_SRC_PATH="github.com/chaincode/chaincode_example02/go/"
if [ "$LANGUAGE" = "node" ]; then
CC_SRC_PATH="/opt/gopath/src/github.com/chaincode/chaincode_example02/node/"
fi

echo "Channel name : "$CHANNEL_NAME

# import utils
. scripts/utils.sh

createChannel() {
    setGlobals 0 1

    if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then
            set -x
    peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx >&log.txt
    res=$?
            set +x
else
            set -x
    peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt
    res=$?
            set +x
fi
cat log.txt
verifyResult $res "Channel creation failed"
echo "===================== Channel '$CHANNEL_NAME' created ===================== "
echo
}

joinChannel () {
for org in 1 2; do
    for peer in 0 1; do
    joinChannelWithRetry $peer $org
    echo "===================== peer${peer}.org${org} joined channel '$CHANNEL_NAME' ===================== "
    sleep $DELAY
    echo
    done
done
}

## Create channel
echo "Creating channel..."
createChannel

## Join all the peers to the channel
echo "Having all peers join the channel..."
joinChannel

## Set the anchor peers for each org in the channel
echo "Updating anchor peers for org1..."
updateAnchorPeers 0 1
echo "Updating anchor peers for org2..."
updateAnchorPeers 0 2

## Install chaincode on peer0.org1 and peer0.org2
echo "Installing chaincode on peer0.org1..."
installChaincode 0 1
echo "Install chaincode on peer0.org2..."
installChaincode 0 2

# Instantiate chaincode on peer0.org2
#echo "Instantiating chaincode on peer0.org2..."
#instantiateChaincode 0 2

# Query chaincode on peer0.org1
#echo "Querying chaincode on peer0.org1..."
#chaincodeQuery 0 1 100

# Invoke chaincode on peer0.org1 and peer0.org2
#echo "Sending invoke transaction on peer0.org1 peer0.org2..."
#chaincodeInvoke 0 1 0 2

## Install chaincode on peer1.org2
#echo "Installing chaincode on peer1.org2..."
#installChaincode 1 2

# Query on chaincode on peer1.org2, check if the result is 90
#echo "Querying chaincode on peer1.org2..."
#chaincodeQuery 1 2 90

echo
echo "========= All GOOD, BYFN execution completed =========== "
echo

echo
echo " _____   _   _   ____   "
echo "| ____| | \ | | |  _ \  "
echo "|  _|   |  \| | | | | | "
echo "| |___  | |\  | | |_| | "
echo "|_____| |_| \_| |____/  "
echo

exit 0