我尝试使用composer部署到超级分层结构网络。由以下组成的结构网络:
我本地机器上的所有内容。
我可以让所有对等体加入相同的通道,并且我可以使用来自结构的样本链代码而没有任何错误(实例化,调用,查询)。
然后是composer-cli命令。它们中的每一个都在一个独特的composer-cli容器中运行。这是脚本(将PRIV_KEY1,PRIV_KEY2和COMPOSER-VERSION替换为正确的值)
docker run \
--rm \
--network composer_default \
-v $(pwd)/.vld-card-store:/home/composer/.composer \
-v $(pwd)/vldstage:/home/composer/vldstage \
-v $(pwd)/json:/home/composer/json \
-v $(pwd)/fabric-dev-servers/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp:/home/composer/PeerAdmin@org1 \
hyperledger/composer-cli:{{COMPOSER-VERSION}} \
card create -p json/connection1.json -u PeerAdmin -r PeerAdmin -r
ChannelAdmin -f /home/composer/vldstage/PeerAdmin@byfn-network-org1.card \
-c PeerAdmin@org1/signcerts/Admin@org1.example.com-cert.pem -k
PeerAdmin@org1/keystore/{{PRIV_KEY1}}
docker run \
--rm \
--network composer_default \
-v $(pwd)/.vld-card-store:/home/composer/.composer \
-v $(pwd)/vldstage:/home/composer/vldstage \
-v $(pwd)/fabric-dev-servers/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp:/home/composer/PeerAdmin@org1 \
hyperledger/composer-cli:{{COMPOSER-VERSION}} \
card import -f vldstage/PeerAdmin@byfn-network-org1.card --card PeerAdmin@byfn-network-org1
# build the PeerAdmin card for org2 and import it
docker run \
--rm \
--network composer_default \
-v $(pwd)/.vld-card-store:/home/composer/.composer \
-v $(pwd)/vldstage:/home/composer/vldstage \
-v $(pwd)/json:/home/composer/json \
-v $(pwd)/fabric-dev-servers/composer/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp:/home/composer/PeerAdmin@org2 \
hyperledger/composer-cli:{{COMPOSER-VERSION}} \
card create -p json/connection2.json -u PeerAdmin -r PeerAdmin -r ChannelAdmin -f /home/composer/vldstage/PeerAdmin@byfn-network-org2.card \
-c PeerAdmin@org2/signcerts/Admin@org2.example.com-cert.pem -k PeerAdmin@org2/keystore/{{PRIV_KEY2}}
docker run \
--rm \
--network composer_default \
-v $(pwd)/.vld-card-store:/home/composer/.composer \
-v $(pwd)/vldstage:/home/composer/vldstage \
-v $(pwd)/fabric-dev-servers/composer/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp:/home/composer/PeerAdmin@org2 \
hyperledger/composer-cli:{{COMPOSER-VERSION}} \
card import -f /home/composer/vldstage/PeerAdmin@byfn-network-org2.card --card PeerAdmin@byfn-network-org2
# Install the business network archive on both orgs
docker run \
--rm \
--network composer_default \
-v $(pwd)/vehicle-manufacture-network.bna:/home/composer/vehicle-manufacture-network.bna \
-v $(pwd)/vldstage:/home/composer/vldstage \
-v $(pwd)/.vld-card-store:/home/composer/.composer \
hyperledger/composer-cli:{{COMPOSER-VERSION}} \
network install -c PeerAdmin@byfn-network-org1 -a vehicle-manufacture-network.bna
docker run \
--rm \
--network composer_default \
-v $(pwd)/vehicle-manufacture-network.bna:/home/composer/vehicle-manufacture-network.bna \
-v $(pwd)/vldstage:/home/composer/vldstage \
-v $(pwd)/.vld-card-store:/home/composer/.composer \
hyperledger/composer-cli:{{COMPOSER-VERSION}} \
network install -c PeerAdmin@byfn-network-org2 -a vehicle-manufacture-network.bna
然后对于第二个安装命令,我有以下错误。
✖ Installing business network. This may take a minute...
Error: Error trying install business network. Error: No valid responses from
any peers.
Response from attempted peer comms was an error: Error: 14 UNAVAILABLE:
Connect Failed
我无法找到原因。两个连接配置文件似乎都没问题。 我还检查了容器知道peer0.org2.example.com的地址。所以我无法找到问题,为什么它不会对这个同行起作用。
似乎在运行第二个命令时,我没有登录peer0.org2.example.com,(但我在peer0.org1.example.com上)
如果有人读这篇文章可以提供帮助,我会很高兴谢谢
编辑:了解更多信息
Json for org2
{
"name": "composer_default",
"x-type": "hlfv1",
"x-commitTimeout": 100,
"version": "1.0.0",
"client": {
"organization": "Org2",
"connection": {
"timeout": {
"peer": {
"endorser": "300",
"eventHub": "300",
"eventReg": "300"
},
"orderer": "300"
}
}
},
"channels": {
"composerchannel": {
"orderers": [
"orderer.example.com"
],
"peers": {
"peer0.org1.example.com": {},
"peer0.org2.example.com": {}
}
}
},
"organizations": {
"Org1": {
"mspid": "Org1MSP",
"peers": [
"peer0.org1.example.com"
],
"certificateAuthorities": [
"ca.org1.example.com"
]
},
"Org2": {
"mspid": "Org2MSP",
"peers": [
"peer0.org2.example.com"
],
"certificateAuthorities": [
"ca.org2.example.com"
]
}
},
"orderers": {
"orderer.example.com": {
"url": "grpc://orderer.example.com:7050"
}
},
"peers": {
"peer0.org1.example.com": {
"url": "grpc://peer0.org1.example.com:7051",
"eventUrl": "grpc://peer0.org1.example.com:7053",
"endorsingPeer": true,
"chaincodeQuery": true,
"eventSource": true
},
"peer0.org2.example.com": {
"url": "grpc://peer0.org2.example.com:8051",
"eventUrl": "grpc://peer0.org2.example.com:8053",
"endorsingPeer": true,
"chaincodeQuery": true,
"eventSource": true
}
},
"certificateAuthorities": {
"ca.org1.example.com": {
"url": "http://ca.org1.example.com:7054",
"caName": "ca-org1",
"httpOptions": {
"verify": false
}
},
"ca.org2.example.com": {
"url": "http://ca.org2.example.com:8054",
"caName": "ca-org2",
"httpOptions": {
"verify": false
}
}
}}
连接配置文件之间的差异:
lgrondin@ING-OPS-009:/c/workspace/car_project/packages/vehicle-manufacture/composer-data-latest(multi_node)$ diff json/connection1.json json/connection2.json
7c7
< "organization": "Org1",
---
> "organization": "Org2",
composer card list -c PeerAdmin@byfn-network-org2
(来自上面的容器,具有相同的共享卷)
userName: PeerAdmin
description:
businessNetworkName:
identityId:
3c9251164b9da0021268a2bba92290eaa3787dd436ebc30c6bb481552b7323bf
roles:
- PeerAdmin
- ChannelAdmin
connectionProfile:
name: composer_default
x-type: hlfv1
credentials: Credentials set
Command succeeded
在org2上的安装命令后ca.org2.example.com
上没有登录orderer.example.com
docker network inspect composer_default
[
{
"Name": "composer_default",
"Id": "22d4c9d7238309f7b788b898b718f624f42ab43fd07d419b93c1dff561a8f983",
"Created": "2018-05-30T14:30:28.0377023Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"1424e6759d96fc75f892196d97a643ef0f48c066299dd8403d3d6e7bc56e88dc": {
"Name": "orderer.example.com",
"EndpointID": "0259ad551cb7202282b63f39ea9e3e6d92e2372125bc7923a6acfa378d51be75",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
},
"2b8333cfd852f9c276de25e67f6adffed902ef373eb185f70713faaa31ad3589": {
"Name": "cli",
"EndpointID": "365df656aad0a1990527532e2066f603c3c4c0a875e86c4a1fc544eda1884fa8",
"MacAddress": "02:42:ac:12:00:09",
"IPv4Address": "172.18.0.9/16",
"IPv6Address": ""
},
"7909047abe277b2d77a8e3455a6adaed25c4bed4d661c247b3388e9e29d0d15f": {
"Name": "hardcore_almeida",
"EndpointID": "80af1d145fa8ec8e2d59652c32c44c7cb310ae3dc83f10b196b1c14bc5e76ef3",
"MacAddress": "02:42:ac:12:00:0a",
"IPv4Address": "172.18.0.10/16",
"IPv6Address": ""
},
"79c7d18dcd256bfadf7b31157aeccc5c31b8bf45c542ac837bcb9a66c40260d4": {
"Name": "ca.org2.example.com",
"EndpointID": "9cccf7677f22e17dd3341e1ef6de96a84a6e44425c4f5e15f2be7976ecc2e399",
"MacAddress": "02:42:ac:12:00:05",
"IPv4Address": "172.18.0.5/16",
"IPv6Address": ""
},
"834172e897a97d9eddcc5f12bf94076313dc1dc259094490c044dd08fbe1cdb4": {
"Name": "peer0.org2.example.com",
"EndpointID": "d946f6b445cec7507e8fa995866284ad424e1138c3d0c5210561d7f0e59b09d3",
"MacAddress": "02:42:ac:12:00:07",
"IPv4Address": "172.18.0.7/16",
"IPv6Address": ""
},
"8731b15759abc6bb60f00e487dc06bdac988ac9d93a0bc89e11d0ff5710689e3": {
"Name": "peer0.org1.example.com",
"EndpointID": "e3105664d8f9296b027d4401fffabacb28cc12ef841e455cf08363fb83eea5f6",
"MacAddress": "02:42:ac:12:00:08",
"IPv4Address": "172.18.0.8/16",
"IPv6Address": ""
},
"b09d2d344ac60dc13d4f6c3bc19ec3eee7ab0af40bd4e3a948272167773507b3": {
"Name": "couchdb1",
"EndpointID": "79f5bf383e5812f200f35d08d953fcc21fbb2981f986cd8ddf449abd1ab38dda",
"MacAddress": "02:42:ac:12:00:06",
"IPv4Address": "172.18.0.6/16",
"IPv6Address": ""
},
"be1cb4046af5fa32166ef6db6d9be41f9d53ff1a5d197b9ebe4fedd72cd7b345": {
"Name": "ca.org1.example.com",
"EndpointID": "1916d4a04c54259a3366ce73237ef02e191a0856716b3cd1dedbe9f063b8ff88",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"c9b3405f9789438509cdbab71d8515ea33ba0cf5340892da9365eb8762ae93cb": {
"Name": "couchdb2",
"EndpointID": "4651a768d9dd494be0fb33202d9b316401b319db2dd46881013e9fe3b8eacb42",
"MacAddress": "02:42:ac:12:00:04",
"IPv4Address": "172.18.0.4/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}]
docker ps
lgrondin@ING-OPS-009:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7909047abe27 hyperledger/composer-cli:latest "/bin/sh" 3 minutes ago Up 3 minutes hardcore_almeida
2b8333cfd852 hyperledger/fabric-tools "/bin/bash -c './scr…" 20 minutes ago Up 20 minutes cli
8731b15759ab hyperledger/fabric-peer:x86_64-1.1.0 "peer node start" 20 minutes ago Up 20 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
834172e897a9 hyperledger/fabric-peer:x86_64-1.1.0 "peer node start" 20 minutes ago Up 20 minutes 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp peer0.org2.example.com
79c7d18dcd25 hyperledger/fabric-ca:x86_64-1.1.0 "sh -c 'fabric-ca-se…" 20 minutes ago Up 20 minutes 0.0.0.0:8054->7054/tcp ca.org2.example.com
b09d2d344ac6 hyperledger/fabric-couchdb:x86_64-0.4.6 "tini -- /docker-ent…" 20 minutes ago Up 20 minutes 4369/tcp, 9100/tcp, 0.0.0.0:5984->5984/tcp couchdb1
c9b3405f9789 hyperledger/fabric-couchdb:x86_64-0.4.6 "tini -- /docker-ent…" 20 minutes ago Up 20 minutes 4369/tcp, 9100/tcp, 0.0.0.0:6984->5984/tcp couchdb2
1424e6759d96 hyperledger/fabric-orderer:x86_64-1.1.0 "orderer" 20 minutes ago Up 20 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
be1cb4046af5 hyperledger/fabric-ca:x86_64-1.1.0 "sh -c 'fabric-ca-se…" 20 minutes ago Up 20 minutes 0.0.0.0:7054->7054/tcp ca.org1.example.com
答案 0 :(得分:1)
感谢所有信息!
我认为错误是最初在所有URL中都有localhost,包括主机独有的Ports。但当然localhost在容器中意味着不同的东西,因此您将地址更改为指向Docker Compose和名为“composer_default”的docker网桥提供的名称。
在ORG2的connection.json中,您指的是由docker主机转发的Ports,但您的上下文现在来自容器,因此您需要使用容器而不是docker主机公开的端口号。
因此,例如,您需要将Org2的对等端口号更改为
“URL”: “GRPC://peer0.org2.example.com:7051”
同样,Org2的所有URL都需要以相同的方式修复。