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

简介: HyperLedger fabric 实战 e2e-cli 有运行成功图 安装GO语言 配置yum sudo wget http://mirrors.163.com/.help/CentOS6-Base-163.

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


安装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




目录
相关文章
|
6月前
|
监控 关系型数据库 MySQL
企业实战(8)CentOS 6.8安装Zabbix-agent 5.0监控主机性能与Mysql数据库
企业实战(8)CentOS 6.8安装Zabbix-agent 5.0监控主机性能与Mysql数据库
|
6月前
|
开发框架 .NET 区块链
Hyperledger fabric部署链码(五)初始化与链码升级
fabric部署chaincode-go(智能合约)系列之五
|
6月前
|
JavaScript 测试技术 Go
Hyperledger fabric部署链码(一)打包链码
fabric部署chaincode-go(智能合约)系列之一
|
6月前
|
测试技术 Go 区块链
Hyperledger fabric 测试环境部署
Hyperledger fabric 测试环境部署及相关问题解答
109 3
|
6月前
|
存储 JSON 安全
Hyperledger fabric智能合约编写(一)
本篇文章主要对链码编写的主要思路和部分API进行梳理。
|
6月前
|
Go API 区块链
Hyperledger Fabric相关概念介绍
在学习Hyperledger Fabric的过程中,初步对相关概念的了解。
Hyperledger Fabric相关概念介绍
|
6月前
|
JSON 区块链 数据格式
Hyperledger fabric部署链码(四)提交链码定义到channel
fabric部署chaincode-go(智能合约)系列之四
|
6月前
|
测试技术 API 区块链
Hyperledger fabric部署链码(三)批准链码定义
fabric部署chaincode-go(智能合约)系列之三
|
6月前
|
区块链
Hyperledger fabric部署链码(二)安装链码到fabric
fabric部署chaincode-go(智能合约)系列之二
|
6月前
|
Linux 虚拟化
VMware虚拟机中Centos 6.x系统磁盘空间扩容实战
VMware虚拟机中Centos 6.x系统磁盘空间扩容实战
176 0