HyperLedger fabric 实战 e2e-cli 有运行成功图

HyperLedger fabric 实战 e2e-cli 有运行成功图 安装GO语言。

attachments-2018-03-9MDlTgOS5aa74ab46b850.png

作者:佚名

来源:云栖社区

著权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

安装GO语言 配置yum

sudo wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

mv CentOS6-Base-163.repo CentOS-Base.repo

yum install go

yum安装go

配置环境变量

编辑当前用户的环境变量

vi ~/.profile

添加以下内容

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin

编辑保存并退出vi后,记得使这些环境变量生效source ~/.profile把go的目录GOPATH设置为当前用户的文件夹下,所以记得创建go文件夹

cd ~
mkdir go

异常

bash: /usr/local/go/bin/go: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
将32位go安装到64位服务器上

这样GO就顺利安装完毕了,有时候wget获取go安装包的时候会因为网络问题失败,也可以用apt安装go,只不过版本是比较老旧的1.6.2,但是我在测试中也可以正常使用sudo apt-get install golang添加的环境变量为

export PATH=$PATH:/usr/lib/go-1.6
export GOROOT=/usr/lib/go-1.6
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin

安装Docker 卸载已有docker

列出你安装过的包
$ yum list installed | grep docker

docker-engine.x86_64   1.7.1-1.el7 @/docker-engine-1.7.1-1.el7.x86_64.rpm123

删除安装包
$ sudo yum -y remove docker-engine.x86_641

删除镜像/容器等
$ rm -rf /var/lib/docker


## 安装 docker

系统版本uname -r3.10.0-229.el7.x86_64

更新yumsudo yum update

yum install docker

安装Docker-compose

  1. 添加EPEL源在Shell中运行以下命令,安装EPEL源:yum install -y epel-release
  2. 安装python-pip在Shell中运行以下命令,安装Python-pip软件包:yum install -y python-pip升级一下版本pip install --upgrade pip
  3. 安装docker-compose在Shell中运行以下命令,通过pip安装docker-compose:pip install docker-compose

验证安装

  1. 检查docker版本通过Shell检查docker版本,若返回信息如下图所示,则表示安装成功:
docker version
  1. 检查docker-compose版本通过Shell检查docker-compose版本,若返回信息如下图所示,则表示安装成功:
docker-compose version

检查版本

输入图片说明

  1. 运行示例容器

运行hello-world镜像,若返回信息如下图所示,则表示docker配置正确:

输入图片说明

非root用户执行docker设置

主为root,权限为rw,可读可写;其属组为docker,权限为rw,可读可写。如果要当前用户可直接读取该文件,那么我们就为当前用户添加到docker属组即可。

如果还没有 docker group 就添加一个:

sudo groupadd docker


将用户加入该 group 内。然后退出并重新登录就生效啦。

sudo gpasswd -a ${USER} docker


重启 docker 服务

sudo service docker restart


切换当前会话到新 group 或者重启 X 会话

newgrp - docker




注意:最后一步是必须的,否则因为 groups 命令获取到的是缓存的组信息,刚添加的组信息未能生效,所以 docker images 执行时同样有错。

Git安装

sudo yum install git

nodejs安装

sudo yum install nodejs

输入图片说明

Hyperledger Fabric实战

cd $GOPATH
mkdir -p src/github.com/hyperledger 

cd src/github.com/hyperledger

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

cd fabric

git checkout v1.0.0

cd examples/e2e_cli/

# 下载docker images
source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0

或者 sudo ./download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0

./network_setup.sh up

[watt@localhost e2e_cli]$ ./network_setup.sh up
setting to default channel 'mychannel'
mychannel

Building cryptogen
find: ‘/src/github.com/hyperledger/fabric/core/chaincode/shim’: No such file or directory
make: Entering directory `/home/watt/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 /home/watt/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.0" github.com/hyperledger/fabric/common/configtx/tool/configtxgen
Building release/linux-amd64/bin/cryptogen for linux-amd64

Creating network "e2ecli_default" with the default driver
Pulling orderer.example.com (hyperledger/fabric-orderer:latest)...
ERROR: manifest for hyperledger/fabric-orderer:latest not found
ERROR !!!! Unable to pull the images


error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/a1/a15c59ecda5b7faae9a370907fddd66208a1267f00979294e18cd99950c86f12/data?Expires=1520627639&Signature=d3trfYMkAe3Ec5v2miVTANKhntPyjoaJFv4euWBQbgaSWGOvtpUj-sSbOLwijze~mqGGXtjyeBet2NBulu6HwdqW~333ixTs3~WIqxTx-k-uBRytSrlY2Rjsj688orNJRcr6Wcz-nuCPaNAx57MfYFFpojtkDB9IJnDbnYAiZ5Q_&Key-Pair-Id=APKAJECH5M7VWIS5YZ6Q: net/http: TLS handshake timeout
Error response from daemon: No such image: hyperledger/fabric-ca:x86_64-1.0.0


docker默认镜像拉取地址为国外仓库下载速度较慢,则会报错“net/http: TLS handshake timeout”。
此时,只需要将拉取地址改为国内镜像仓库即可。

标准格式为:


$ docker pull registry.docker-cn.com/myname/myrepo:mytag
例:


$ docker pull registry.docker-cn.com/library/ubuntu:16.04
   


为了永久性保留更改,您可以修改 /etc/docker/daemon.json 文件并添加上
 registry-mirrors 键值。


{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}



修改保存后重启 Docker 以使配置生效。

sudo service docker stop
sudo service docker start

输入图片说明

输入图片说明

ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
ERROR !!!! Unable to pull the images


systemctl daemon-reload

systemctl restart docker

仍然没解决问题




https://docs.docker.com/articles/systemd/

sudo ./network_setup.sh up

启动好了输入图片说明

2018-03-23 09:57:27.038 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-03-23 09:57:27.038 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-03-23 09:57:27.051 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-03-23 09:57:27.052 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-03-23 09:57:27.052 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-03-23 09:57:27.052 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-03-23 09:57:27.052 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-03-23 09:57:27.052 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267314D53501280062D...53616D706C65436F6E736F727469756D
2018-03-23 09:57:27.052 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: E60DC844BB4AEE61D3283BD546B4766E040A38769975AD5EA597820380A46A97
2018-03-23 09:57:27.052 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-03-23 09:57:27.052 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-03-23 09:57:27.052 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-03-23 09:57:27.052 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-03-23 09:57:27.052 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A0608879FD3D50522...B239F5C82D59A7A8E21076C02A75E7C4
2018-03-23 09:57:27.052 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 877BEB5EA117BD6B0C0150D4CB348CBAF7064BF33E5298C1CC650A0730C1202B
Error: Got unexpected status: BAD_REQUEST
Usage:
  peer channel create [flags]

Flags:
  -c, --channelID string   In case of a newChain command, the channel ID to create.
  -f, --file string        Configuration transaction file generated by a tool such as configtxgen for submitting to orderer
  -t, --timeout int        Channel creation timeout (default 5)

Global Flags:
      --cafile string              Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
      --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")
      --tls                        Use TLS when communicating with the orderer endpoint
  -v, --version                    Display current version of fabric peer server

!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
================== ERROR !!! FAILED to execute End-2-End Scenario ==================


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

Channel name : mychannel
Creating channel...
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
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
CORE_PEER_LOCALMSPID=Org1MSP
CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
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
CORE_PEER_TLS_ENABLED=true
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
CORE_PEER_ID=cli
CORE_LOGGING_LEVEL=DEBUG
CORE_PEER_ADDRESS=peer0.org1.example.com:7051
2018-03-23 09:59:52.219 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-03-23 09:59:52.219 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-03-23 09:59:52.230 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2018-03-23 09:59:52.231 UTC [msp] GetLocalMSP -> DEBU 004 Returning existing local MSP
2018-03-23 09:59:52.231 UTC [msp] GetDefaultSigningIdentity -> DEBU 005 Obtaining default signing identity
2018-03-23 09:59:52.231 UTC [msp] GetLocalMSP -> DEBU 006 Returning existing local MSP
2018-03-23 09:59:52.231 UTC [msp] GetDefaultSigningIdentity -> DEBU 007 Obtaining default signing identity
2018-03-23 09:59:52.231 UTC [msp/identity] Sign -> DEBU 008 Sign: plaintext: 0A8C060A074F7267314D53501280062D...53616D706C65436F6E736F727469756D
2018-03-23 09:59:52.231 UTC [msp/identity] Sign -> DEBU 009 Sign: digest: 4E32EF5E499E6486FBB22FC4D469E41402274B288A1FDE9E9CA7E9CCCAE22B4A
2018-03-23 09:59:52.231 UTC [msp] GetLocalMSP -> DEBU 00a Returning existing local MSP
2018-03-23 09:59:52.231 UTC [msp] GetDefaultSigningIdentity -> DEBU 00b Obtaining default signing identity
2018-03-23 09:59:52.231 UTC [msp] GetLocalMSP -> DEBU 00c Returning existing local MSP
2018-03-23 09:59:52.231 UTC [msp] GetDefaultSigningIdentity -> DEBU 00d Obtaining default signing identity
2018-03-23 09:59:52.231 UTC [msp/identity] Sign -> DEBU 00e Sign: plaintext: 0AC3060A1508021A060898A0D3D50522...758B50C7D33769821B84F2C10A8F2718
2018-03-23 09:59:52.231 UTC [msp/identity] Sign -> DEBU 00f Sign: digest: 5721F3B93959C7C3CEAD3A6BA854096386F0710ADD13A33D44A6CB276C3D6EA1
Error: Got unexpected status: BAD_REQUEST
Usage:
  peer channel create [flags]

Flags:
  -c, --channelID string   In case of a newChain command, the channel ID to create.
  -f, --file string        Configuration transaction file generated by a tool such as configtxgen for submitting to orderer
  -t, --timeout int        Channel creation timeout (default 5)

Global Flags:
      --cafile string              Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
      --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")
      --tls                        Use TLS when communicating with the orderer endpoint
  -v, --version                    Display current version of fabric peer server

!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
================== ERROR !!! FAILED to execute End-2-End Scenario ==================

解决方案:
sudo ./network_setup.sh down



文章发布只为分享区块链技术内容,版权归原作者所有,观点仅代表作者本人,绝不代表区块链兄弟赞同其观点或证实其描述。

attachments-2018-02-kL1zBfXx5a7ffd0b78798.jpg


  • 发表于 2018-05-16 11:31
  • 阅读 ( 210 )
  • 分类:hyperledger

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
不写代码的码农
社区运营-小以

222 篇文章

作家榜 »

  1. 社区运营-小以 222 文章
  2. 社区运营-小链 194 文章
  3. 于中阳Mercina-zy 68 文章
  4. 涂晶 61 文章
  5. 吴寿鹤 35 文章
  6. 李晓琼 30 文章
  7. John-smith 19 文章
  8. lanyang 17 文章