Hyperledger Fabric 安装(版本1.0.0-beta)

经过几天的摸索,终于成功安装Fabric 安装(版本1.0.0-beta),另外还了解到,每tag 安装有所不一样

root@fabric03 e2e_cli]# git tag 
baseimage-v0.0.11
v0.6.0-preview
v0.6.1-preview
v1.0.0
v1.0.0-alpha
v1.0.0-alpha2
v1.0.0-beta
v1.0.0-rc1
v1.0.1
v1.0.2
v1.0.3
v1.0.4
v1.0.5
v1.0.6
v1.1.0
v1.1.0-alpha
v1.1.0-preview
v1.1.0-rc1

现在把安装v1.0.0-beta版本的步骤记录下来,以下是通过docker-compose工具部署的


1.准备环境

安装 docker git golang docker-compose 比较简单 在这里就不详细说了

[root@fabric03 e2e_cli]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core) 
yum install docker git golang python-pip
pip install --upgrade pip
pip install docker-compose

2.下载源码

注意要设置GOPATH="/opt/gopath"

mkdir -p /opt/gopath/src/github.com/hyperledger && cd /opt/gopath/src/github.com/hyperledger

git clone https://github.com/hyperledger/fabric.git

git checkout v1.0.0-beta

3.编译以及下载镜像

生成 configtxgen

[root@fabric03 e2e_cli]# pwd 
/opt/gopath/src/github.com/hyperledger/fabric/
[root@fabric03 e2e_cli]# make configtxgen

下载镜像

root@fabric03 e2e_cli]# bash download-dockerimages.sh 
===> Pulling fabric Images
==> FABRIC IMAGE: peer
...
===> List out hyperledger docker images
docker.io/hyperledger/fabric-tools       x86_64-1.1.0-alpha   b7b3d30505d4        7 weeks ago         1.44 GB
docker.io/hyperledger/fabric-tools       x86_64-1.0.0-beta    ae6b0f53cb70        9 months ago        1.32 GB
hyperledger/fabric-tools                 latest               ae6b0f53cb70        9 months ago        1.32 GB
hyperledger/fabric-couchdb               latest               31bbbec3d853        9 months ago        1.48 GB
docker.io/hyperledger/fabric-couchdb     x86_64-1.0.0-beta    31bbbec3d853        9 months ago        1.48 GB
docker.io/hyperledger/fabric-kafka       x86_64-1.0.0-beta    c4ac1c9a4797        9 months ago        1.3 GB
hyperledger/fabric-kafka                 latest               c4ac1c9a4797        9 months ago        1.3 GB
docker.io/hyperledger/fabric-zookeeper   x86_64-1.0.0-beta    2c4ebacb6f00        9 months ago        1.31 GB
hyperledger/fabric-zookeeper             latest               2c4ebacb6f00        9 months ago        1.31 GB
docker.io/hyperledger/fabric-orderer     x86_64-1.0.0-beta    11ff350dd297        9 months ago        179 MB
hyperledger/fabric-orderer               latest               11ff350dd297        9 months ago        179 MB
docker.io/hyperledger/fabric-peer        x86_64-1.0.0-beta    e01c2b645f11        9 months ago        182 MB
hyperledger/fabric-peer                  latest               e01c2b645f11        9 months ago        182 MB
docker.io/hyperledger/fabric-javaenv     x86_64-1.0.0-beta    61c188dca542        9 months ago        1.42 GB
hyperledger/fabric-javaenv               latest               61c188dca542        9 months ago        1.42 GB
docker.io/hyperledger/fabric-ccenv       x86_64-1.0.0-beta    7034cca1918d        9 months ago        1.29 GB
hyperledger/fabric-ccenv                 latest               7034cca1918d        9 months ago        1.29 GB
docker.io/hyperledger/fabric-ca          x86_64-1.0.0-beta    e549e8c53c2e        9 months ago        238 MB
hyperledger/fabric-ca                    latest               e549e8c53c2e        9 months ago        238 MB

[root@fabric03 e2e_cli]# ./generateArtifacts.sh qinzhao
qinzhao

Building cryptogen
make: 进入目录“/opt/gopath/src/github.com/hyperledger/fabric”
Building release/linux-amd64/bin/configtxgen for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /opt/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxgen -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/configtx/tool/configtxgen/metadata.Version=1.0.0-beta" github.com/hyperledger/fabric/common/configtx/tool/configtxgen
Building release/linux-amd64/bin/cryptogen for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /opt/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/cryptogen -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/tools/cryptogen/metadata.Version=1.0.0-beta" github.com/hyperledger/fabric/common/tools/cryptogen
Building release/linux-amd64/bin/configtxlator for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /opt/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxlator -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/tools/configtxlator/metadata.Version=1.0.0-beta" github.com/hyperledger/fabric/common/tools/configtxlator
mkdir -p release/linux-amd64/install
cat: release/linux-amd64/install/../../templates/get-docker-images.in: 没有那个文件或目录
make: 离开目录“/opt/gopath/src/github.com/hyperledger/fabric”

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
2018-03-18 15:25:10.776 CST [bccsp] GetDefault -> WARN 001 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.798 CST [bccsp] GetDefault -> WARN 002 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.800 CST [bccsp] GetDefault -> WARN 003 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.801 CST [bccsp] GetDefault -> WARN 004 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.803 CST [bccsp] GetDefault -> WARN 005 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
org2.example.com
2018-03-18 15:25:10.805 CST [bccsp] GetDefault -> WARN 006 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.808 CST [bccsp] GetDefault -> WARN 007 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.809 CST [bccsp] GetDefault -> WARN 008 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.811 CST [bccsp] GetDefault -> WARN 009 Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.812 CST [bccsp] GetDefault -> WARN 00a Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.814 CST [bccsp] GetDefault -> WARN 00b Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.815 CST [bccsp] GetDefault -> WARN 00c Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.
2018-03-18 15:25:10.817 CST [bccsp] GetDefault -> WARN 00d Before using BCCSP, please call InitFactories(). Falling back to bootBCCSP.

Using configtxgen -> /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
2018-03-18 15:25:10.850 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-18 15:25:10.855 CST [msp] getMspConfig -> INFO 002 intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/intermediatecerts: no such file or directory]
2018-03-18 15:25:10.855 CST [msp] getMspConfig -> INFO 003 crls folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/crls: no such file or directory]
2018-03-18 15:25:10.855 CST [msp] getMspConfig -> INFO 004 MSP configuration file not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/config.yaml]: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/ordererOrganizations/example.com/msp/config.yaml: no such file or directory]
2018-03-18 15:25:10.874 CST [msp] getMspConfig -> INFO 005 intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/msp/intermediatecerts: no such file or directory]
2018-03-18 15:25:10.875 CST [msp] getMspConfig -> INFO 006 crls folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/msp/crls: no such file or directory]
2018-03-18 15:25:10.875 CST [msp] getMspConfig -> INFO 007 MSP configuration file not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/msp/config.yaml]: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org1.example.com/msp/config.yaml: no such file or directory]
2018-03-18 15:25:10.875 CST [msp] getMspConfig -> INFO 008 intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org2.example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org2.example.com/msp/intermediatecerts: no such file or directory]
2018-03-18 15:25:10.875 CST [msp] getMspConfig -> INFO 009 crls folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org2.example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org2.example.com/msp/crls: no such file or directory]
2018-03-18 15:25:10.875 CST [msp] getMspConfig -> INFO 00a MSP configuration file not found at [/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org2.example.com/msp/config.yaml]: [stat /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/crypto-config/peerOrganizations/org2.example.com/msp/config.yaml: no such file or directory]
2018-03-18 15:25:10.876 CST [common/configtx/tool] doOutputBlock -> INFO 00b Generating genesis block
2018-03-18 15:25:10.877 CST [common/configtx/tool] doOutputBlock -> INFO 00c Writing genesis block

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2018-03-18 15:25:10.892 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-18 15:25:10.895 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-03-18 15:25:10.895 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
2018-03-18 15:25:10.912 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-18 15:25:10.915 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-18 15:25:10.916 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
2018-03-18 15:25:10.931 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-18 15:25:10.934 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-18 15:25:10.934 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update

4.运行测试

[root@fabric03 e2e_cli]# bash network_setup.sh up
setting to default channel 'mychannel'
mychannel

Using cryptogen -> /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
...
Creating peer0.org2.example.com ... 
Creating cli ... 

 ____    _____      _      ____    _____           _____   ____    _____ 
/ ___|  |_   _|    / \    |  _ \  |_   _|         | ____| |___ \  | ____|
\___ \    | |     / _ \   | |_) |   | |    _____  |  _|     __) | |  _|  
 ___) |   | |    / ___ \  |  _ <    | |   |_____| | |___   / __/  | |___ 
|____/    |_|   /_/   \_\ |_| \_\   |_|           |_____| |_____| |_____|

Channel name : mychannel
Creating channel...
2018-03-18 07:29:02.837 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-03-18 07:29:02.837 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-03-18 07:29:02.837 UTC [msp/identity] Sign -> DEBU 006 Sign: plaintext: 0AAD070A6708031A0C08BEAAB8D50510...6D7963631A0A0A0571756572790A0161 
2018-03-18 07:29:02.837 UTC [msp/identity] Sign -> DEBU 007 Sign: digest: 220C2ABEF437BC9AC0C73643A84427F51BBF760C79620F4BB4D06A5B517AC3A2 
Query Result: 90
2018-03-18 07:29:23.748 UTC [main] main -> INFO 008 Exiting.....
===================== Query on PEER3 on channel 'mychannel' is successful ===================== 

===================== All GOOD, End-2-End execution completed ===================== 


 _____   _   _   ____            _____   ____    _____ 
| ____| | \ | | |  _ \          | ____| |___ \  | ____|
|  _|   |  \| | | | | |  _____  |  _|     __) | |  _|  
| |___  | |\  | | |_| | |_____| | |___   / __/  | |___ 
|_____| |_| \_| |____/          |_____| |_____| |_____|

搞定

[root@fabric03 e2e_cli]# docker ps 
CONTAINER ID        IMAGE                                 COMMAND                  CREATED             STATUS              PORTS                                              NAMES
62664eef4f38        dev-peer1.org2.example.com-mycc-1.0   "chaincode -peer.a..."   10 minutes ago      Up 10 minutes                                                          dev-peer1.org2.example.com-mycc-1.0
fef4f609fb5b        dev-peer0.org1.example.com-mycc-1.0   "chaincode -peer.a..."   10 minutes ago      Up 10 minutes                                                          dev-peer0.org1.example.com-mycc-1.0
274082c69284        dev-peer0.org2.example.com-mycc-1.0   "chaincode -peer.a..."   10 minutes ago      Up 10 minutes                                                          dev-peer0.org2.example.com-mycc-1.0
db08126b70d7        hyperledger/fabric-tools              "/bin/bash -c './s..."   11 minutes ago      Up 11 minutes                                                          cli
99b641c25b69        hyperledger/fabric-peer               "peer node start"        11 minutes ago      Up 11 minutes       0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp     peer0.org2.example.com
3749d0011992        hyperledger/fabric-orderer            "orderer"                11 minutes ago      Up 11 minutes       0.0.0.0:7050->7050/tcp                             orderer.example.com
6cf95ca6553d        hyperledger/fabric-peer               "peer node start"        11 minutes ago      Up 11 minutes       0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp     peer0.org1.example.com
37be876216f5        hyperledger/fabric-peer               "peer node start"        11 minutes ago      Up 11 minutes       0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp     peer1.org1.example.com
75ae8f6cc10d        hyperledger/fabric-peer               "peer node start"        11 minutes ago      Up 11 minutes       0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp   peer1.org2.example.com

参考文档

http://hyperledger-fabric.readthedocs.io/en/latest/samples.html

http://hyperledger-fabric.readthedocs.io/en/latest/samples.html#binaries

http://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html

你可能感兴趣的:(区块链)