当我跟着书上的步骤一起做时,并没有得到书上的结果,并且会出现许多错误,于是我选择跟随hyperledger开发文档来做。
1.开始之前的准备
2.安装示例、二进制和 Docker 镜像
3.# 使用Fabric的测试网络
当我运行
./network.sh down
出现如下错误:(具体原因未知)
root@lennon-System-Product-Name:/home/lennon/桌面/fabric-samples/test-network# ./network.sh down
Stopping network
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_orderer.example.com
WARNING: Volume net_orderer.example.com not found.
Removing volume net_peer0.org1.example.com
WARNING: Volume net_peer0.org1.example.com not found.
Removing volume net_peer0.org2.example.com
WARNING: Volume net_peer0.org2.example.com not found.
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
No containers available for deletion
No images available for deletion
Unable to find image 'busybox:latest' locally
然后运行
./network.sh up
root@lennon-System-Product-Name:/home/lennon/桌面/fabric-samples/test-network# ./network.sh up
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.3.0
DOCKER_IMAGE_VERSION=2.3.0
/home/lennon/桌面/fabric-samples/test-network/../bin/cryptogen
Generate certificates using cryptogen tool
Create Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Create Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Create Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generate CCP files for Org1 and Org2
/home/lennon/桌面/fabric-samples/test-network/../bin/configtxgen
Generating Orderer Genesis block
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
2020-12-03 21:28:55.563 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-12-03 21:28:55.568 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2020-12-03 21:28:55.568 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
2020-12-03 21:28:55.568 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/lennon/桌面/fabric-samples/test-network/configtx/configtx.yaml
2020-12-03 21:28:55.569 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2020-12-03 21:28:55.569 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Creating system channel genesis block
2020-12-03 21:28:55.570 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
Creating network "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating peer0.org1.example.com ... error
Creating peer0.org2.example.com ...
Creating orderer.example.com ...
ERROR: for peer0.org1.example.com Cannot create container for service peer0.org1.example.com: Conflict. The Creating peer0.org2.example.com ... error
660a1c4c5b1dbb7c70ce2acdd8f8". You have to remove (or rename) that container to be able to reuse that name.
ERROR: for peer0.org2.example.com Cannot create container for service peer0.org2.example.com: Conflict. The container name "/peer0.org2.example.com" is already in use by container "ee52ab3c5c5fffb5363ab36ecac3f387171ae9a9f0a2ae878e846d1a10e9ad92". You have to remove (or rename) that container to be able to reuse that name.
Creating orderer.example.com ... error
ERROR: for orderer.example.com Cannot start service orderer.example.com: driver failed programming external connectivity on endpoint orderer.example.com (39290adbf8f4780bce68f1a8662e3397b4f12a1cfa49a9b4f49c1cbf74e8ebc2): Bind for 0.0.0.0:7050 failed: port is already allocated
ERROR: for peer0.org1.example.com Cannot create container for service peer0.org1.example.com: Conflict. The container name "/peer0.org1.example.com" is already in use by container "325dad70284513e43be4acc8da595d946b65660a1c4c5b1dbb7c70ce2acdd8f8". You have to remove (or rename) that container to be able to reuse that name.
ERROR: for peer0.org2.example.com Cannot create container for service peer0.org2.example.com: Conflict. The container name "/peer0.org2.example.com" is already in use by container "ee52ab3c5c5fffb5363ab36ecac3f387171ae9a9f0a2ae878e846d1a10e9ad92". You have to remove (or rename) that container to be able to reuse that name.
ERROR: for orderer.example.com Cannot start service orderer.example.com: driver failed programming external connectivity on endpoint orderer.example.com (39290adbf8f4780bce68f1a8662e3397b4f12a1cfa49a9b4f49c1cbf74e8ebc2): Bind for 0.0.0.0:7050 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5f56a825884e hyperledger/fabric-orderer:latest "orderer" 3 seconds ago Created orderer.example.com
bcda3c4b5799 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 9443/tcp, 0.0.0.0:8051->7051/tcp peer1.org1.example.com
97dad4c06e80 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 9443/tcp, 0.0.0.0:10051->7051/tcp peer1.org2.example.com
325dad702845 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 0.0.0.0:7051->7051/tcp, 9443/tcp peer0.org1.example.com
ee52ab3c5c5f yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 9443/tcp, 0.0.0.0:9051->7051/tcp peer0.org2.example.com
66edbe51aba7 yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 23 hours ago Up 5 hours 0.0.0.0:7050->7050/tcp, 8443/tcp orderer0.example.com
32f11286be4e yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 23 hours ago Up 5 hours 8443/tcp, 0.0.0.0:8050->7050/tcp orderer1.example.com
a2a8b3f255c0 yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 23 hours ago Up 5 hours 8443/tcp, 0.0.0.0:9050->7050/tcp orderer2.example.com
0a251475276f yeasy/hyperledger-fabric:2.0.0 "bash -c 'cd /tmp; s…" 23 hours ago Up 5 hours 7050-7051/tcp, 7054/tcp, 8443/tcp, 9443/tcp fabric-cli
4ed7334f8531 hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago beautiful_heyrovsky
出现了,好像是因为我之前跟着书上的来做docker中创建过容器,需要移出或者重命名之前那个才行。
然后,我输入命令
docker ps
查看本地系统中运行的容器信息:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5f56a825884e hyperledger/fabric-orderer:latest "orderer" 40 seconds ago Created orderer.example.com
bcda3c4b5799 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 9443/tcp, 0.0.0.0:8051->7051/tcp peer1.org1.example.com
97dad4c06e80 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 9443/tcp, 0.0.0.0:10051->7051/tcp peer1.org2.example.com
325dad702845 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 0.0.0.0:7051->7051/tcp, 9443/tcp peer0.org1.example.com
ee52ab3c5c5f yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 23 hours ago Up 5 hours 9443/tcp, 0.0.0.0:9051->7051/tcp peer0.org2.example.com
66edbe51aba7 yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 23 hours ago Up 5 hours 0.0.0.0:7050->7050/tcp, 8443/tcp orderer0.example.com
32f11286be4e yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 23 hours ago Up 5 hours 8443/tcp, 0.0.0.0:8050->7050/tcp orderer1.example.com
a2a8b3f255c0 yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 23 hours ago Up 5 hours 8443/tcp, 0.0.0.0:9050->7050/tcp orderer2.example.com
0a251475276f yeasy/hyperledger-fabric:2.0.0 "bash -c 'cd /tmp; s…" 23 hours ago Up 5 hours 7050-7051/tcp, 7054/tcp, 8443/tcp, 9443/tcp fabric-cli
4ed7334f8531 hello-world "/hello" 2 weeks ago Exited (0) 2 weeks ago beautiful_heyrovsky
这说明我之前已经创建过了容器,我需要先将这些删除掉,但是我当时并没有这样做,而是运行了创建通道的命令
./network.sh createChannel
然后就出现了error
2020-12-03 21:31:32.856 CST [comm.tls] ClientHandshake -> ERRO 001 Client TLS handshake failed after 534.859µs with error: x509: certificate is valid for orderer0.example.com, orderer0, orderer0.example.com, orderer0, not orderer.example.com remoteaddress=127.0.0.1:7050
2020-12-03 21:31:33.859 CST [comm.tls] ClientHandshake -> ERRO 002 Client TLS handshake failed after 2.059853ms with error: x509: certificate is valid for orderer0.example.com, orderer0, orderer0.example.com, orderer0, not orderer.example.com remoteaddress=127.0.0.1:7050
2020-12-03 21:31:35.515 CST [comm.tls] ClientHandshake -> ERRO 003 Client TLS handshake failed after 3.180058ms with error: x509: certificate is valid for orderer0.example.com, orderer0, orderer0.example.com, orderer0, not orderer.example.com remoteaddress=127.0.0.1:7050
Error: failed to create deliver client for orderer: orderer client failed to connect to localhost:7050: failed to create new connection: context deadline exceeded
Channel creation failed
Create channel failed
然后我运行删除之前容器的命令:
./network.sh down
出现如下提示:
Stopping network
Removing network net_test
Removing volume net_orderer.example.com
Removing volume net_peer0.org1.example.com
Removing volume net_peer0.org2.example.com
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
No containers available for deletion
No images available for deletion
Unable to find image 'busybox:latest' locally
提示我没有能删除的容器和镜像。
此时我以为已经删除掉了之前的容器,然后就尝试创建通道
./network.sh up createChannel -c mychannel
又出现之前的错误
2020-12-03 21:42:15.650 CST [comm.tls] ClientHandshake -> ERRO 001 Client TLS handshake failed after 601.338µs with error: x509: certificate is valid for orderer0.example.com, orderer0, orderer0.example.com, orderer0, not orderer.example.com remoteaddress=127.0.0.1:7050
2020-12-03 21:42:16.654 CST [comm.tls] ClientHandshake -> ERRO 002 Client TLS handshake failed after 2.438379ms with error: x509: certificate is valid for orderer0.example.com, orderer0, orderer0.example.com, orderer0, not orderer.example.com remoteaddress=127.0.0.1:7050
2020-12-03 21:42:18.543 CST [comm.tls] ClientHandshake -> ERRO 003 Client TLS handshake failed after 1.941349ms with error: x509: certificate is valid for orderer0.example.com, orderer0, orderer0.example.com, orderer0, not orderer.example.com remoteaddress=127.0.0.1:7050
Error: failed to create deliver client for orderer: orderer client failed to connect to localhost:7050: failed to create new connection: context deadline exceeded
Channel creation failed
Create channel failed
这说明之前的容器还是没有删除掉,输入查询容器命令(此命令只显示id):
docker ps -aq
输出结果是:
bcda3c4b5799
97dad4c06e80
325dad702845
ee52ab3c5c5f
66edbe51aba7
32f11286be4e
a2a8b3f255c0
0a251475276f
4ed7334f8531
然后我又用:
./network.sh down
出现许多Not found:
Stopping network
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_orderer.example.com
WARNING: Volume net_orderer.example.com not found.
Removing volume net_peer0.org1.example.com
WARNING: Volume net_peer0.org1.example.com not found.
Removing volume net_peer0.org2.example.com
WARNING: Volume net_peer0.org2.example.com not found.
Removing network net_test
WARNING: Network net_test not found.
Removing volume net_peer0.org3.example.com
WARNING: Volume net_peer0.org3.example.com not found.
No containers available for deletion
No images available for deletion
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
5f5dd3e95e9f: Pull complete
Digest: sha256:9f1c79411e054199210b4d489ae600a061595967adb643cd923f8515ad8123d2
Status: Downloaded newer image for busybox:latest
然后查询容器
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bcda3c4b5799 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 24 hours ago Up 6 hours 9443/tcp, 0.0.0.0:8051->7051/tcp peer1.org1.example.com
97dad4c06e80 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 24 hours ago Up 6 hours 9443/tcp, 0.0.0.0:10051->7051/tcp peer1.org2.example.com
325dad702845 yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 24 hours ago Up 6 hours 0.0.0.0:7051->7051/tcp, 9443/tcp peer0.org1.example.com
ee52ab3c5c5f yeasy/hyperledger-fabric-peer:2.0.0 "peer node start" 24 hours ago Up 6 hours 9443/tcp, 0.0.0.0:9051->7051/tcp peer0.org2.example.com
66edbe51aba7 yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 24 hours ago Up 6 hours 0.0.0.0:7050->7050/tcp, 8443/tcp orderer0.example.com
32f11286be4e yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 24 hours ago Up 6 hours 8443/tcp, 0.0.0.0:8050->7050/tcp orderer1.example.com
a2a8b3f255c0 yeasy/hyperledger-fabric-orderer:2.0.0 "orderer start" 24 hours ago Up 6 hours 8443/tcp, 0.0.0.0:9050->7050/tcp orderer2.example.com
0a251475276f yeasy/hyperledger-fabric:2.0.0 "bash -c 'cd /tmp; s…" 24 hours ago Up 6 hours 7050-7051/tcp, 7054/tcp, 8443/tcp, 9443/tcp fabric-cli
发现还是有容器,没有删除掉
最后使用
docker system prune
终于删除掉了
root@lennon-System-Product-Name:/home/lennon/桌面/fabric-samples/test-network# docker system prune
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all dangling images
- all dangling build cache
Are you sure you want to continue? [y/N] y
Deleted Containers:
bcda3c4b5799162f3ad9de3ca48f2098738f1a609ae2f6d110c0b5b6adb9bd63
97dad4c06e800c9b1024a31f7357c8a218879f97d2983b24a50d67c980da5732
325dad70284513e43be4acc8da595d946b65660a1c4c5b1dbb7c70ce2acdd8f8
ee52ab3c5c5fffb5363ab36ecac3f387171ae9a9f0a2ae878e846d1a10e9ad92
66edbe51aba7836bb799a878db7c0c8d787e9e260dab9001efb1e6a8084fe18a
32f11286be4ee7985fb94f29da8ddc992345c2678c0ce840ce1309bc4c35b022
a2a8b3f255c023e6e05087274791da1d8f212e591992ab3ec3c18df79d9ec882
0a251475276fc5822547cff6e209bf1d91124664511ada4619299e1a05e2ac94
Deleted Networks:
hlf_net
Total reclaimed space: 16.68MB
这时再输入,发现之前的容器都删除掉了。
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
此时,启动
./network.sh up
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
LOCAL_VERSION=2.3.0
DOCKER_IMAGE_VERSION=2.3.0
/home/lennon/桌面/fabric-samples/test-network/../bin/cryptogen
Generate certificates using cryptogen tool
Create Org1 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output=organizations
org1.example.com
+ res=0
Create Org2 Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output=organizations
org2.example.com
+ res=0
Create Orderer Org Identities
+ cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output=organizations
+ res=0
Generate CCP files for Org1 and Org2
/home/lennon/桌面/fabric-samples/test-network/../bin/configtxgen
Generating Orderer Genesis block
+ configtxgen -profile TwoOrgsOrdererGenesis -channelID system-channel -outputBlock ./system-genesis-block/genesis.block
2020-12-04 09:36:04.459 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-12-04 09:36:04.464 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2020-12-04 09:36:04.464 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 003 Orderer.EtcdRaft.Options unset, setting to tick_interval:"500ms" election_tick:10 heartbeat_tick:1 max_inflight_blocks:5 snapshot_interval_size:16777216
2020-12-04 09:36:04.464 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/lennon/桌面/fabric-samples/test-network/configtx/configtx.yaml
2020-12-04 09:36:04.465 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2020-12-04 09:36:04.465 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Creating system channel genesis block
2020-12-04 09:36:04.465 CST [common.tools.configtxgen] doOutputBlock -> INFO 007 Writing genesis block
+ res=0
Creating network "net_test" with the default driver
Creating volume "net_orderer.example.com" with default driver
Creating volume "net_peer0.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating peer0.org2.example.com ... done
Creating orderer.example.com ... done
Creating peer0.org1.example.com ... done
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
25c8d2b542c9 hyperledger/fabric-peer:latest "peer node start" 5 seconds ago Up Less than a second 0.0.0.0:7051->7051/tcp peer0.org1.example.com
92e942e2db16 hyperledger/fabric-orderer:latest "orderer" 5 seconds ago Up Less than a second 0.0.0.0:7050->7050/tcp orderer.example.com
80d5ca18b4f6 hyperledger/fabric-peer:latest "peer node start" 5 seconds ago Up 1 second 7051/tcp, 0.0.0.0:9051->9051/tcp peer0.org2.example.com
网友评论