区块链在这里就不多费笔墨了,相信大家问度娘比看我的文章好多了
快速进入正题:
五台 CentOS7.2
[root@fabric=orderer e2e_cli]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
其中三台用来部署peer ,一台用来部署orderer,另一台用来部署证书
记得要关闭selinux
[root@fabric03 ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
安装 docker git golang docker-compose
yum install docker git golangyum install epel-releaseyum install pip && pip install --upgrade pip && pip install docker-composesystemctl start docker
http://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html
获取fabric源代码
mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
生成configtxgen
工具
[root@fabric=orderer fabric]# make configtxgen
find: ‘/src/github.com/hyperledger/fabric/core/chaincode/shim’: 没有那个文件或目录
build/bin/configtxgen
CGO_CFLAGS=" " GOBIN=/root/go/src/github.com/hyperledger/fabric/build/bin go install -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/configtx/tool/configtxgen/metadata.Version=1.0.7-snapshot-da14b6b" github.com/hyperledger/fabric/common/configtx/tool/configtxgen
Binary available as build/bin/configtxgen
[root@fabric=orderer fabric]# ls -l build/bin/
总用量 14816
-rwxr-xr-x 1 root root 15168777 3月 17 09:37 configtxgen
生成配置文件
[root@fabric=orderer fabric]# cd examples/e2e_cli/
[root@fabric=orderer e2e_cli]# pwd
/root/go/src/github.com/hyperledger/fabric/examples/e2e_cli
[root@fabric=orderer e2e_cli]# ls -l
总用量 84
drwxr-xr-x 2 root root 58 3月 17 09:36 base
drwxr-xr-x 2 root root 106 3月 17 09:54 channel-artifacts
-rw-r--r-- 1 root root 5013 3月 17 09:36 configtx.yaml
drwxr-xr-x 4 root root 57 3月 17 09:54 crypto-config
-rw-r--r-- 1 root root 3858 3月 17 09:36 crypto-config.yaml
-rw-r--r-- 1 root root 2677 3月 17 09:36 docker-compose-cli.yaml
-rw-r--r-- 1 root root 2005 3月 17 09:36 docker-compose-couch.yaml
-rw-r--r-- 1 root root 2517 3月 17 09:36 docker-compose-e2e-template.yaml
-rw-r--r-- 1 root root 2725 3月 17 09:54 docker-compose-e2e.yaml
-rw-r--r-- 1 root root 2119 3月 17 09:36 download-dockerimages.sh
-rw-r--r-- 1 root root 41711 3月 17 09:36 end-to-end.rst
drwxr-xr-x 3 root root 22 3月 17 09:36 examples
-rwxr-xr-x 1 root root 3588 3月 17 09:36 generateArtifacts.sh
-rwxr-xr-x 1 root root 2617 3月 17 09:36 network_setup.sh
drwxr-xr-x 2 root root 22 3月 17 09:36 scripts
在终端 执行./generateArtifacts.sh
[root@fabric=orderer e2e_cli]# ./generateArtifacts.sh
mychannelBuilding cryptogen
find: ‘/src/github.com/hyperledger/fabric/core/chaincode/shim’: 没有那个文件或目录
make: 进入目录“/root/go/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 /root/go/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.7-snapshot-da14b6b" 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 /root/go/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.7-snapshot-da14b6b" 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 /root/go/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.7-snapshot-da14b6b" github.com/hyperledger/fabric/common/tools/configtxlator
Building release/linux-amd64/bin/peer for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/peer -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.7-snapshot-da14b6b -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.2 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/peer
Building release/linux-amd64/bin/orderer for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /root/go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/orderer -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.7-snapshot-da14b6b -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.2 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/orderer
mkdir -p release/linux-amd64/bin
make: 离开目录“/root/go/src/github.com/hyperledger/fabric”##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
org2.example.comUsing configtxgen -> /root/go/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
2018-03-17 09:54:12.129 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 09:54:12.149 CST [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block
2018-03-17 09:54:12.150 CST [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2018-03-17 09:54:12.157 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 09:54:12.160 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-03-17 09:54:12.160 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
2018-03-17 09:54:12.167 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 09:54:12.169 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-17 09:54:12.169 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
2018-03-17 09:54:12.177 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 09:54:12.180 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-17 09:54:12.181 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update
获取镜像
docker pull hyperledger/fabric-orderer:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-peer:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-zookeeper:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-couchdb:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-kafka:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-ca:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-ccenv:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-javaenv:x86_64-1.0.0-alpha
docker pull hyperledger/fabric-tools:x86_64-1.1.0-alphadocker tag hyperledger/fabric-tools:x86_64-1.1.0-alpha hyperledger/fabric-tools:latest
docker tag hyperledger/fabric-orderer:x86_64-1.0.0-alpha hyperledger/fabric-orderer:latest
docker tag hyperledger/fabric-peer:x86_64-1.0.0-alpha hyperledger/fabric-peer:latest
docker tag hyperledger/fabric-zookeeper:x86_64-1.0.0-alpha hyperledger/fabric-zookeeper:latest
docker tag hyperledger/fabric-couchdb:x86_64-1.0.0-alpha hyperledger/fabric-couchdb:latest
docker tag hyperledger/fabric-kafka:x86_64-1.0.0-alpha hyperledger/fabric-kafka:latest
docker tag hyperledger/fabric-ca:x86_64-1.0.0-alpha hyperledger/fabric-ca:latest
docker tag hyperledger/fabric-ccenv:x86_64-1.0.0-alpha hyperledger/fabric-ccenv:latest
docker tag hyperledger/fabric-javaenv:x86_64-1.0.0-alpha hyperledger/fabric-javaenv:latest
[root@fabric=orderer e2e_cli]# ls -l
总用量 84
drwxr-xr-x 2 root root 58 3月 17 09:36 base
drwxr-xr-x 2 root root 106 3月 17 09:54 channel-artifacts
-rw-r--r-- 1 root root 5013 3月 17 09:36 configtx.yaml
drwxr-xr-x 4 root root 57 3月 17 09:54 crypto-config
-rw-r--r-- 1 root root 3858 3月 17 09:36 crypto-config.yaml
-rw-r--r-- 1 root root 2677 3月 17 09:36 docker-compose-cli.yaml
-rw-r--r-- 1 root root 2005 3月 17 09:36 docker-compose-couch.yaml
-rw-r--r-- 1 root root 2517 3月 17 09:36 docker-compose-e2e-template.yaml
-rw-r--r-- 1 root root 2725 3月 17 09:54 docker-compose-e2e.yaml
-rw-r--r-- 1 root root 2119 3月 17 09:36 download-dockerimages.sh
-rw-r--r-- 1 root root 41711 3月 17 09:36 end-to-end.rst
drwxr-xr-x 3 root root 22 3月 17 09:36 examples
-rwxr-xr-x 1 root root 3588 3月 17 09:36 generateArtifacts.sh
-rwxr-xr-x 1 root root 2617 3月 17 09:36 network_setup.sh
drwxr-xr-x 2 root root 22 3月 17 09:36 scripts
测试bash network_setup.sh up
该部署还存在问题,只提供参考
[root@fabricorderer e2e_cli]# pwd
/opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli
[root@fabricorderer e2e_cli]# bash network_setup.sh up
[root@fabricorderer e2e_cli]# bash network_setup.sh up
setting to default channel 'mychannel'
mychannelUsing cryptogen -> /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/cryptogen##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
org1.example.com
org2.example.comsed:-e 表达式 #1,字符 85:未终止的“s”命令
sed:-e 表达式 #1,字符 85:未终止的“s”命令
Using configtxgen -> /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli/../../release/linux-amd64/bin/configtxgen
##########################################################
######### Generating Orderer Genesis block ##############
##########################################################
2018-03-17 21:22:41.918 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 21:22:41.940 CST [common/configtx/tool] doOutputBlock -> INFO 002 Generating genesis block
2018-03-17 21:22:41.941 CST [common/configtx/tool] doOutputBlock -> INFO 003 Writing genesis block#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
2018-03-17 21:22:41.953 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 21:22:41.956 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 002 Generating new channel configtx
2018-03-17 21:22:41.956 CST [common/configtx/tool] doOutputChannelCreateTx -> INFO 003 Writing new channel tx#################################################################
####### Generating anchor peer update for Org1MSP ##########
#################################################################
2018-03-17 21:22:41.969 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 21:22:41.971 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-17 21:22:41.972 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update#################################################################
####### Generating anchor peer update for Org2MSP ##########
#################################################################
2018-03-17 21:22:41.983 CST [common/configtx/tool] main -> INFO 001 Loading configuration
2018-03-17 21:22:41.986 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 002 Generating anchor peer update
2018-03-17 21:22:41.986 CST [common/configtx/tool] doOutputAnchorPeersUpdate -> INFO 003 Writing anchor peer update/usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version!
Creating orderer.example.com ... done
Creating cli ... done
Creating peer1.org1.example.com ...
Creating peer1.org2.example.com ...
Creating orderer.example.com ...
Creating peer0.org2.example.com ...
Creating cli ... ____ _____ _ ____ _____ _____ ____ _____
/ ___| |_ _| / \ | _ \ |_ _| | ____| |___ \ | ____|
\___ \ | | / _ \ | |_) | | | _____ | _| __) | | _| ___) | | | / ___ \ | _ <| | |_____| | |___ / __/ | |___
|____/ |_| /_/ \_\ |_| \_\ |_| |_____| |_____| |_____|Channel name : mychannel
Creating channel...
CORE_PEER_TLS_ROOTCERT_FILE&#61;/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
CORE_PEER_TLS_KEY_FILE&#61;/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key
CORE_PEER_LOCALMSPID&#61;Org1MSP
CORE_VM_ENDPOINT&#61;unix:///host/var/run/docker.sock
CORE_PEER_TLS_CERT_FILE&#61;/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt
CORE_PEER_TLS_ENABLED&#61;true
CORE_PEER_MSPCONFIGPATH&#61;/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin&#64;org1.example.com/msp
CORE_PEER_ID&#61;cli
CORE_LOGGING_LEVEL&#61;DEBUG
CORE_PEER_ADDRESS&#61;peer0.org1.example.com:7051
2018-03-17 13:22:44.873 UTC [msp] getMspConfig -> INFO 001 intermediate certs folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin&#64;org1.example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin&#64;org1.example.com/msp/intermediatecerts: no such file or directory]
2018-03-17 13:22:44.873 UTC [msp] getMspConfig -> INFO 002 crls folder not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin&#64;org1.example.com/msp/intermediatecerts]. Skipping.: [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin&#64;org1.example.com/msp/crls: no such file or directory]
2018-03-17 13:22:44.873 UTC [msp] getMspConfig -> INFO 003 MSP configuration file not found at [/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin&#64;org1.example.com/msp/config.yaml]: [stat /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin&#64;org1.example.com/msp/config.yaml: no such file or directory]
2018-03-17 13:22:44.924 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-03-17 13:22:44.924 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-03-17 13:22:44.926 UTC [grpc] Printf -> DEBU 006 Failed to dial orderer.example.com:7050: connection error: desc &#61; "transport: authentication handshake failed: x509: certificate signed by unknown authority"; please retry.
Error: Error connecting due to rpc error: code &#61; Internal desc &#61; connection error: desc &#61; "transport: authentication handshake failed: x509: certificate signed by unknown authority"
Usage:peer channel create [flags]Global Flags:-b, --blockpath string Path to file containing genesis block--cafile string Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint-c, --chain string In case of a newChain command, the chain ID to create.-f, --file string Configuration transaction file generated by a tool such as configtxgen for submitting to orderer--logging-level string Default logging level and overrides, see core.yaml for full syntax-o, --orderer string Ordering service endpoint--test.coverprofile string Done (default "coverage.cov")-t, --timeout int Channel creation timeout (default 5)--tls Use TLS when communicating with the orderer endpoint-v, --version Display current version of fabric peer server!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61; ERROR !!! FAILED to execute End-2-End Scenario &#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;&#61;^C
[root&#64;fabricorderer e2e_cli]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e8211fcb9ced hyperledger/fabric-tools "/bin/bash -c &#39;./s..." 4 minutes ago Up 4 minutes cli
b13e244fc833 hyperledger/fabric-orderer "orderer" 4 minutes ago Up 4 minutes 0.0.0.0:7050->7050/tcp orderer.example.com
d4875001e448 hyperledger/fabric-peer "peer node start" 4 minutes ago Up 4 minutes 0.0.0.0:7051->7051/tcp, 0.0.0.0:7053->7053/tcp peer0.org1.example.com
9517f14308f6 hyperledger/fabric-peer "peer node start" 4 minutes ago Up 4 minutes 0.0.0.0:10051->7051/tcp, 0.0.0.0:10053->7053/tcp peer1.org2.example.com
97ea015136bc hyperledger/fabric-peer "peer node start" 4 minutes ago Up 4 minutes 0.0.0.0:8051->7051/tcp, 0.0.0.0:8053->7053/tcp peer1.org1.example.com
116b0d99d316 hyperledger/fabric-peer "peer node start" 4 minutes ago Up 4 minutes 0.0.0.0:9051->7051/tcp, 0.0.0.0:9053->7053/tcp peer0.org2.example.com