Fabric学习--环境搭建

前言:这是本人学习fabric的一个安装笔记,本来觉得应该很简单,一切从头开始安装,因为很久没有干活了,所以,前后安装了好几天,因为碰到的各种问题很多,有自己小白的错误,也有不同版本的问题,查阅了很多网友的经验,结果导致内容很散,也很多,且因为是工作之余安装,内容随手记录,前后记录也有重复,但整体上记录了我从centos8虚拟机安装到搭建fabric环境,到成功运行的全部过程记录,如果跟我安装环境类似,可以搜索借鉴,如果嫌麻烦就不要看了,切记!

1、准备工作

1.1安装环境

win10/VMware® Workstation 15 Pro/Centos8.2

1.2 虚拟机配置

网络:NAT模式 , 其他视情况而定;

1.3 环境检查

  1. ping通网络;
  2. 开启虚拟机
  3. 启动xshell登录系统

1.4 用户配置

建立一个管理员用户fabric。

 

2、安装步骤

2.1安装wget

因为需要管理员权限,所以要用sudo授权执行此命令。

sudo yum -y install wget

2.2安装go

2.2.1下载go

需要管理员权限,带sudo命令,嫌麻烦的可以直接用su命令切换到root用户。在/usr/local目录下执行命令:

sudo wget --no-check-certificate https://storage.googleapis.com/golang/go1.11.linux-amd64.tar.gz

注意:必须带--no-check-certificate参数,否则提示SSL证书错误。另外,我这里go的版本是1.11,根据实际情况调整版本。

2.2.2解压go

下载完成后,可以看到/usr/local目录中有“go1.11.linux-amd64.tar.gz”文件存在。

sudo tar xvf go1.11.linux-amd64.tar.gz

解压后在/usr/local目录中多了一个“go”目录,也就是/usr/local/go目录中保存着解压的内容。

2.2.3设置环境变量

  • 编辑/etc/profile文件,再最后一行添加go相关的环境变量设置,因为我为了其他人也能用到,所以就在/etc/profile做了全局配置。
[fabric@localhost etc]$ sudo vi profile

export PATH=$PATH:/usr/local/go/bin
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$HOME/go/bin
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
  • 采用source命令生效配置
[fabric@localhost ~]$ source profile
  • 用env命令查看环境变量的配置
[fabric@localhost ~]$ env

检查配置是否存在。

  • 测试go命令
[fabric@localhost ~]$ go version
go version go1.11 linux/amd64

可看到已经可以执行go命令,说明配置生效,这样go环境就已经装好了。

 

 

2.3安装Docker

docker运行环境的要求linux内核3.10以上,我是centos8,内核4.1没有问题,安装条件满足。目前红帽RHEL和CentOS系统下面安装docker可以有两种方式:一种是使用curl获得docker的安装脚本进行安装,还有一种是使用yum包管理器来安装docker。我自己使用yum包管理器来安装docker。下面步骤基本都是参考官方文档执行。

2.3.1更新yum包

这一步是稀里糊涂跟着文档执行,后来发现是更新linux的,真是瞎鼓捣,但既然执行了,就记录下来。

[fabric@localhost ~]$ sudo yum update

效果就是我等了半天时间,但切记不能在生产环境执行此命令,那将是一场灾难!!

2.3.2配置yum源

我用的是阿里的yum源,我的centos版本是8。详细添加yum源过程如下:

[fabric@localhost ~]$ sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
[sudo] fabric 的密码:
--2020-09-21 09:34:10--  http://mirrors.aliyun.com/repo/Centos-8.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 111.164.19.225, 125.36.180.241, 125.36.136.239, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|111.164.19.225|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2595 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

/etc/yum.repos.d/CentOS-Base.repo         100%[=====================================================================================>]   2.53K  --.-KB/s  用时 0s      

2020-09-21 09:34:10 (479 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2595/2595])

查看一下结果,显示如下:

[fabric@localhost ~]$ cat /etc/yum.repos.d/CentOS-Base.repo 
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[fabric@localhost ~]$ yum makecache
CentOS-8 - Base - mirrors.aliyun.com                                                                                                    2.3 MB/s | 2.2 MB     00:00    
CentOS-8 - Extras - mirrors.aliyun.com                                                                                                   30 kB/s | 8.1 kB     00:00    
CentOS-8 - AppStream - mirrors.aliyun.com                                                                                               4.0 MB/s | 5.8 MB     00:01    
元数据缓存已建立。

注意:yum makecache的作用,就是把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存 以后用install时就在缓存中搜索,提高了速度。配合yum -C search xxx使用 不用上网检索就能查找软件信息。需要yum clean all定期清理缓存。

2.3.3添加yum-util工具测试效果

[fabric@localhost ~]$ sudo yum install -y yum-utils 
[sudo] fabric 的密码:
上次元数据过期检查:0:02:32 前,执行于 2020年09月21日 星期一 09时45分58秒。
依赖关系解决。
========================================================================================================================================================================
 软件包                                              架构                              版本                                       仓库                             大小
========================================================================================================================================================================
安装:
 yum-utils                                           noarch                            4.0.12-4.el8_2                             base                             66 k
升级:
 dnf-plugins-core                                    noarch                            4.0.12-4.el8_2                             base                             64 k
 python3-dnf-plugins-core                            noarch                            4.0.12-4.el8_2                             base                            204 k

事务概要
========================================================================================================================================================================
安装  1 软件包
升级  2 软件包

总下载:334 k
下载软件包:
(1/3): dnf-plugins-core-4.0.12-4.el8_2.noarch.rpm                                                                                       443 kB/s |  64 kB     00:00    
(2/3): python3-dnf-plugins-core-4.0.12-4.el8_2.noarch.rpm                                                                               982 kB/s | 204 kB     00:00    
(3/3): yum-utils-4.0.12-4.el8_2.noarch.rpm                                                                                              292 kB/s |  66 kB     00:00    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                    1.4 MB/s | 334 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                         1/1 
  升级    : python3-dnf-plugins-core-4.0.12-4.el8_2.noarch                                                                                                          1/5 
  升级    : dnf-plugins-core-4.0.12-4.el8_2.noarch                                                                                                                  2/5 
  安装    : yum-utils-4.0.12-4.el8_2.noarch                                                                                                                         3/5 
  清理    : dnf-plugins-core-4.0.12-3.el8.noarch                                                                                                                    4/5 
  清理    : python3-dnf-plugins-core-4.0.12-3.el8.noarch                                                                                                            5/5 
  运行脚本: python3-dnf-plugins-core-4.0.12-3.el8.noarch                                                                                                            5/5 
  验证    : yum-utils-4.0.12-4.el8_2.noarch                                                                                                                         1/5 
  验证    : dnf-plugins-core-4.0.12-4.el8_2.noarch                                                                                                                  2/5 
  验证    : dnf-plugins-core-4.0.12-3.el8.noarch                                                                                                                    3/5 
  验证    : python3-dnf-plugins-core-4.0.12-4.el8_2.noarch                                                                                                          4/5 
  验证    : python3-dnf-plugins-core-4.0.12-3.el8.noarch                                                                                                            5/5 
Installed products updated.

已升级:
  dnf-plugins-core-4.0.12-4.el8_2.noarch                                         python3-dnf-plugins-core-4.0.12-4.el8_2.noarch                                        

已安装:
  yum-utils-4.0.12-4.el8_2.noarch                                                                                                                                       

完毕!
[fabric@localhost ~]$ 

这就证明配置的yum源没有问题,顺便也把工具安装上。

2.3.4添加Docker的Device Mapper驱动依赖包

[fabric@localhost ~]$ sudo yum install -y device-mapper-persistent-data lvm2

上次元数据过期检查:0:04:56 前,执行于 2020年09月21日 星期一 09时45分58秒。
软件包 device-mapper-persistent-data-0.8.5-3.el8.x86_64 已安装。
软件包 lvm2-8:2.03.08-3.el8.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!

我记得我没有安装这两个包,是不是centos8自动支持了?回头再查一下。

2.3.5添加Docker的yum源

[fabric@localhost ~]$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[sudo] fabric 的密码:
添加仓库自:https://download.docker.com/linux/centos/docker-ce.repo
Curl error (35): SSL connect error for https://download.docker.com/linux/centos/docker-ce.repo [OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to download.docker.com:443 ]
错误:配置仓库失败

添加docker失败,后来查询网上资料按照如下办法搞定:

[fabric@localhost ~]$ sudo yum update nss
[sudo] fabric 的密码:
上次元数据过期检查:1:22:01 前,执行于 2020年09月21日 星期一 09时45分58秒。
依赖关系解决。
无需任何处理。
完毕!
[fabric@localhost ~]$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
添加仓库自:https://download.docker.com/linux/centos/docker-ce.repo

至于原因,意思要升级网络安全服务NSS。NSS是什么东西,我查询了一下资料,记录如下:

NSS 是开源软件,和 OpenSSL 一样,是一个底层密码学库,包括 TLS 实现。NSS 并不是完全由 Mozilla 开发出来的,很多公司(包括 Google)和个人都贡献了代码,只是 Mozilla 提供了一些基础设施(比如代码仓库、bug 跟踪系统、邮件组、讨论组)。

NSS 是跨平台的,很多产品都使用了NSS 密码库,包括:

  • Mozilla 的产品,比如 Firefox、Thunderbird、Firefox OS。
  • 一些开源的软件,比如 Pidgin、Apache OpenOffice、LibreOffice。
  • Red Hat 的服务器产品,比如 Red Hat Directory Server, Red Hat Certificate System。
  • 其他服务器产品,比如 Apache 的 mod_nss模块,没有发现 Nginx 支持 NSS
  • SJES 的 Sun 服务器产品。

NSS 支持的密码学算法标准和应用如下:

  • SSL&TLS,NSS 计划从 NSS 3.29 版本开始支持 TLS 1.3 协议。
  • 各类 PKCS 公开密码学标准,详细信息可参考 Public Key Cryptography Standards
  • Cryptographic Message Syntax,用于 S/MIME(对 MIME 数据进行加密和签名),关于 CMS 标准和 S/MIME 应用了解的不多,所以在《深入迁出HTTPS:从原理到实践》这本书中并没有阐述。
  • X.509 v3 证书,这是 HTTPS 协议中非常重要的组成部分。
  • OCSP,是证书非常有效的补充协议,用于在线校验证书的吊销状态(可扩展,还包括其他状态,比如可以包含证书透明度信息)。
  • 各类密码学算法,包括 RSA、DH、ECC、AES、SHA、HMAC 等等。
  • 符合 FIPS 186-2 标准的伪随机生成函数。

NSS 提供了完整的软件开发包,包括密码库、API、命令行工具、文档集(API references、man 帮助、示例代码)。NSS 3.14版本开始,升级到 GPL 兼容的 MPL 2.0 许可证。

NSS 符合 FIPS 140(1&2)标准,FIPS 标准是美国政府定义的一种标准,主要是数据编码的标准。NSS 库也通过了 NISCC TLS/SSL 和 S/MIME 的测试(160万输入数据的测试),NISCC 是英国政府提出的安全标准。

2.3.6查看仓库中Docker的版本

[fabric@localhost ~]$ yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64            3:19.03.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.13-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.12-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.11-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.10-3.el7                    docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
Docker CE Stable - x86_64                        13 kB/s |  25 kB     00:01    
上次元数据过期检查:0:00:01 前,执行于 2020年09月21日 星期一 13时35分27秒。
可安装的软件包

2.3.7docker设置

这个设置是照抄网上教程,但自己不知道怎么回事,待弄明白。这里先照做。

我看英文的描述是:Enable the nightly or test repositories。但具体翻译过来意思也不是太明白,大概意思是允许什么测试库?

[fabric@localhost yum.repos.d]$ sudo yum-config-manager --enable docker-ce-nightly
[sudo] fabric 的密码:
[fabric@localhost yum.repos.d]$ sudo yum-config-manager --enable docker-ce-test
[fabric@localhost yum.repos.d]$ 

2.3.8安装Docker

直接选择一个最新的版本,可以先去网站浏览:https://download.docker.com/linux/centos/8/x86_64/stable/Packages/

可以看见有:

Fabric学习--环境搭建_第1张图片

接下来就执行命令:

sudo yum install https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm

但出现不兼容错误,解决方法在出错信息就有提示,信息如下:

Docker CE Stable - x86_64                                                                                                               1.6 kB/s | 3.5 kB     00:02    
Docker CE Test - x86_64                                                                                                                  27 kB/s |  65 kB     00:02    
Docker CE Nightly - x86_64                                                                                                               37 kB/s |  91 kB     00:02    
containerd.io-1.3.7-3.1.el8.x86_64.rpm                                                                                                  1.4 MB/s |  29 MB     00:21    
错误:
 问题: problem with installed package podman-1.6.4-10.module_el8.2.0+305+5e198a41.x86_64
  - package podman-1.6.4-10.module_el8.2.0+305+5e198a41.x86_64 requires runc >= 1.0.0-57, but none of the providers can be installed
  - package containerd.io-1.3.7-3.1.el8.x86_64 conflicts with runc provided by runc-1.0.0-65.rc10.module_el8.2.0+305+5e198a41.x86_64
  - package containerd.io-1.3.7-3.1.el8.x86_64 obsoletes runc provided by runc-1.0.0-65.rc10.module_el8.2.0+305+5e198a41.x86_64
  - conflicting requests
  - package runc-1.0.0-64.rc10.module_el8.2.0+304+65a3c2ac.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.10-3.2.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.13-3.1.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.13-3.2.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.2-3.3.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.2-3.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.4-3.1.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.5-3.1.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.6-3.3.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.3.7-3.1.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.1-2.0.rc.0.1.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.11-3.2.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.12-3.1.el7.x86_64 is filtered out by modular filtering
  - package containerd.io-1.2.6-3.2.el7.x86_64 is filtered out by modular filtering
(尝试在命令行中添加 '--allowerasing' 来替换冲突的软件包 或 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)

也就如提示的一样,添加:--allowerasing参数来替换掉冲突的包,重新执行命令:

sudo yum install --allowerasing https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm

结果成功。

安装完docker后,应该把docker权限赋给fabric(我专门建立用于fabic的用户),执行命令如下:

[fabric@localhost ~]$ sudo usermod -aG docker fabric

2.3.9 安装Docker Containerd

sudo yum install docker-ce docker-ce-cli
上次元数据过期检查:0:35:55 前,执行于 2020年09月21日 星期一 14时59分31秒。
依赖关系解决。
========================================================================================================================================================================
 软件包                                  架构                             版本                                         仓库                                        大小
========================================================================================================================================================================
安装:
 docker-ce                               x86_64                           3:19.03.13-3.el7                             docker-ce-stable                            24 M
 docker-ce-cli                           x86_64                           1:19.03.13-3.el7                             docker-ce-stable                            38 M
安装依赖关系:
 libcgroup                               x86_64                           0.41-19.el8                                  base                                        70 k

事务概要
========================================================================================================================================================================
安装  3 软件包

总下载:63 M
安装大小:273 M
确定吗?[y/N]: y
下载软件包:
(1/3): libcgroup-0.41-19.el8.x86_64.rpm                                                                                                 442 kB/s |  70 kB     00:00    
(2/3): docker-ce-cli-19.03.13-3.el7.x86_64.rpm                                                                                          2.2 MB/s |  38 MB     00:17    
(3/3): docker-ce-19.03.13-3.el7.x86_64.rpm                                                                                              745 kB/s |  24 MB     00:33    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                    1.9 MB/s |  63 MB     00:33     
警告:/var/cache/dnf/docker-ce-stable-091d8a9c23201250/packages/docker-ce-19.03.13-3.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY
Docker CE Stable - x86_64                                                                                                               2.0 kB/s | 1.6 kB     00:00    
导入 GPG 公钥 0x621E9F35:
 Userid: "Docker Release (CE rpm) "
 指纹: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
 来自: https://download.docker.com/linux/centos/gpg
确定吗?[y/N]: y
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                         1/1 
  安装    : docker-ce-cli-1:19.03.13-3.el7.x86_64                                                                                                                   1/3 
  运行脚本: docker-ce-cli-1:19.03.13-3.el7.x86_64                                                                                                                   1/3 
  运行脚本: libcgroup-0.41-19.el8.x86_64                                                                                                                            2/3 
  安装    : libcgroup-0.41-19.el8.x86_64                                                                                                                            2/3 
  运行脚本: libcgroup-0.41-19.el8.x86_64                                                                                                                            2/3 
  安装    : docker-ce-3:19.03.13-3.el7.x86_64                                                                                                                       3/3 
  运行脚本: docker-ce-3:19.03.13-3.el7.x86_64                                                                                                                       3/3 
  验证    : libcgroup-0.41-19.el8.x86_64                                                                                                                            1/3 
  验证    : docker-ce-3:19.03.13-3.el7.x86_64                                                                                                                       2/3 
  验证    : docker-ce-cli-1:19.03.13-3.el7.x86_64                                                                                                                   3/3 
Installed products updated.

已安装:
  docker-ce-3:19.03.13-3.el7.x86_64                       docker-ce-cli-1:19.03.13-3.el7.x86_64                       libcgroup-0.41-19.el8.x86_64                      

完毕!

安装完后测试一下,查看docker版本

[fabric@localhost ~]$ docker -v
Docker version 19.03.13, build 4484c46d9d

这就说明docker基本安装成功。

2.3.10 安装Compose

Compose 简介:

Compose 是用于定义和运行多容器 Docker 应用程序的工具。通过 Compose,您可以使用 YML 文件来配置应用程序需要的所有服务。然后,使用一个命令,就可以从 YML 文件配置中创建并启动所有服务。

Compose 使用的三个步骤:

  • 使用 Dockerfile 定义应用程序的环境。

  • 使用 docker-compose.yml 定义构成应用程序的服务,这样它们可以在隔离环境中一起运行。

  • 最后,执行 docker-compose up 命令来启动并运行整个应用程序。

先去https://github.com/docker/compose/releases查询最新版本,我查到的最新版本为:1.27.3。

这里需要用到一个工具:CURL,因为太久没有做过具体工作,所以基本算是小白一个,但不怕,学呗,于是百度查询curl是什么。得出一个解释:

        curl(CommandLine Uniform Resource Locator)是一个命令行工具,通过指定的URL来上传或下载数据,并将数据展示出来。关于curl的具体信息可参考官方网站:https://curl.haxx.se/。

在linux下通过执行命令:

[fabric@localhost ~]$ curl -h

可以查看curl命令帮助,如下图所示:

[fabric@localhost ~]$ curl -h
Usage: curl [options...] 
     --abstract-unix-socket  Connect via abstract Unix domain socket
     --anyauth       Pick any authentication method
 -a, --append        Append to target file when uploading
     --basic         Use HTTP Basic Authentication
     --cacert  CA certificate to verify peer against
     --capath   CA directory to verify peer against
 -E, --cert  Client certificate file and password
     --cert-status   Verify the status of the server certificate
     --cert-type  Certificate file type (DER/PEM/ENG)
     --ciphers  SSL ciphers to use
     --compressed    Request compressed response
     --compressed-ssh Enable SSH compression
 -K, --config  Read config from a file
     --connect-timeout  Maximum time allowed for connection
     --connect-to  Connect to host
 -C, --continue-at  Resumed transfer offset
 -b, --cookie  Send cookies from string/file
 -c, --cookie-jar  Write cookies to  after operation
     --create-dirs   Create necessary local directory hierarchy
     --crlf          Convert LF to CRLF in upload
     --crlfile  Get a CRL list in PEM format from the given file
 -d, --data    HTTP POST data
     --data-ascii  HTTP POST ASCII data
     --data-binary  HTTP POST binary data
     --data-raw  HTTP POST data, '@' allowed
     --data-urlencode  HTTP POST data url encoded
     --delegation  GSS-API delegation permission
     --digest        Use HTTP Digest Authentication
 -q, --disable       Disable .curlrc
     --disable-eprt  Inhibit using EPRT or LPRT
     --disable-epsv  Inhibit using EPSV
     --disallow-username-in-url Disallow username in url
     --dns-interface  Interface to use for DNS requests
     --dns-ipv4-addr 
IPv4 address to use for DNS requests --dns-ipv6-addr
IPv6 address to use for DNS requests --dns-servers DNS server addrs to use -D, --dump-header Write the received headers to --egd-file EGD socket path for random data --engine Crypto engine to use --expect100-timeout How long to wait for 100-continue -f, --fail Fail silently (no output at all) on HTTP errors --fail-early Fail on first transfer error, do not continue --false-start Enable TLS False Start -F, --form Specify multipart MIME data --form-string Specify multipart MIME data --ftp-account Account data string --ftp-alternative-to-user String to replace USER [name] --ftp-create-dirs Create the remote dirs if not present --ftp-method Control CWD usage --ftp-pasv Use PASV/EPSV instead of PORT -P, --ftp-port
Use PORT instead of PASV --ftp-pret Send PRET before PASV --ftp-skip-pasv-ip Skip the IP address for PASV --ftp-ssl-ccc Send CCC after authenticating --ftp-ssl-ccc-mode Set CCC mode --ftp-ssl-control Require SSL/TLS for FTP login, clear for transfer -G, --get Put the post data in the URL and use GET -g, --globoff Disable URL sequences and ranges using {} and [] --happy-eyeballs-timeout-ms How long to wait in milliseconds for IPv6 before trying IPv4 --haproxy-protocol Send HAProxy PROXY protocol v1 header -I, --head Show document info only -H, --header
Pass custom header(s) to server -h, --help This help text --hostpubmd5 Acceptable MD5 hash of the host public key -0, --http1.0 Use HTTP 1.0 --http1.1 Use HTTP 1.1 --http2 Use HTTP 2 --http2-prior-knowledge Use HTTP 2 without HTTP/1.1 Upgrade --ignore-content-length Ignore the size of the remote resource -i, --include Include protocol response headers in the output -k, --insecure Allow insecure server connections when using SSL --interface Use network INTERFACE (or address) -4, --ipv4 Resolve names to IPv4 addresses -6, --ipv6 Resolve names to IPv6 addresses -j, --junk-session-cookies Ignore session cookies read from file --keepalive-time Interval time for keepalive probes --key Private key file name --key-type Private key file type (DER/PEM/ENG) --krb Enable Kerberos with security --libcurl Dump libcurl equivalent code of this command line --limit-rate Limit transfer speed to RATE -l, --list-only List only mode --local-port Force use of RANGE for local port numbers -L, --location Follow redirects --location-trusted Like --location, and send auth to other hosts --login-options Server login options --mail-auth
Originator address of the original email --mail-from
Mail from this address --mail-rcpt
Mail to this address -M, --manual Display the full manual --max-filesize Maximum file size to download --max-redirs Maximum number of redirects allowed -m, --max-time Maximum time allowed for the transfer --metalink Process given URLs as metalink XML file --negotiate Use HTTP Negotiate (SPNEGO) authentication -n, --netrc Must read .netrc for user name and password --netrc-file Specify FILE for netrc --netrc-optional Use either .netrc or URL -:, --next Make next URL use its separate set of options --no-alpn Disable the ALPN TLS extension -N, --no-buffer Disable buffering of the output stream --no-keepalive Disable TCP keepalive on the connection --no-npn Disable the NPN TLS extension --no-sessionid Disable SSL session-ID reusing --noproxy List of hosts which do not use proxy --ntlm Use HTTP NTLM authentication --ntlm-wb Use HTTP NTLM authentication with winbind --oauth2-bearer OAuth 2 Bearer Token -o, --output Write to file instead of stdout --pass Pass phrase for the private key --path-as-is Do not squash .. sequences in URL path --pinnedpubkey FILE/HASHES Public key to verify peer against --post301 Do not switch to GET after following a 301 --post302 Do not switch to GET after following a 302 --post303 Do not switch to GET after following a 303 --preproxy [protocol://]host[:port] Use this proxy first -#, --progress-bar Display transfer progress as a bar --proto Enable/disable PROTOCOLS --proto-default Use PROTOCOL for any URL missing a scheme --proto-redir Enable/disable PROTOCOLS on redirect -x, --proxy [protocol://]host[:port] Use this proxy --proxy-anyauth Pick any proxy authentication method --proxy-basic Use Basic authentication on the proxy --proxy-cacert CA certificate to verify peer against for proxy --proxy-capath CA directory to verify peer against for proxy --proxy-cert Set client certificate for proxy --proxy-cert-type Client certificate type for HTTPS proxy --proxy-ciphers SSL ciphers to use for proxy --proxy-crlfile Set a CRL list for proxy --proxy-digest Use Digest authentication on the proxy --proxy-header
Pass custom header(s) to proxy --proxy-insecure Do HTTPS proxy connections without verifying the proxy --proxy-key Private key for HTTPS proxy --proxy-key-type Private key file type for proxy --proxy-negotiate Use HTTP Negotiate (SPNEGO) authentication on the proxy --proxy-ntlm Use NTLM authentication on the proxy --proxy-pass Pass phrase for the private key for HTTPS proxy --proxy-pinnedpubkey FILE/HASHES public key to verify proxy with --proxy-service-name SPNEGO proxy service name --proxy-ssl-allow-beast Allow security flaw for interop for HTTPS proxy --proxy-tls13-ciphers TLS 1.3 proxy cipher suites --proxy-tlsauthtype TLS authentication type for HTTPS proxy --proxy-tlspassword TLS password for HTTPS proxy --proxy-tlsuser TLS username for HTTPS proxy --proxy-tlsv1 Use TLSv1 for HTTPS proxy -U, --proxy-user Proxy user and password --proxy1.0 Use HTTP/1.0 proxy on given port -p, --proxytunnel Operate through an HTTP proxy tunnel (using CONNECT) --pubkey SSH Public key file name -Q, --quote Send command(s) to server before transfer --random-file File for reading random data from -r, --range Retrieve only the bytes within RANGE --raw Do HTTP "raw"; no transfer decoding -e, --referer Referrer URL -J, --remote-header-name Use the header-provided filename -O, --remote-name Write output to a file named as the remote file --remote-name-all Use the remote file name for all URLs -R, --remote-time Set the remote file's time on the local output -X, --request Specify request command to use --request-target Specify the target for this request --resolve Resolve the host+port to this address --retry Retry request if transient problems occur --retry-connrefused Retry on connection refused (use with --retry) --retry-delay Wait time between retries --retry-max-time Retry only within this period --sasl-ir Enable initial response in SASL authentication --service-name SPNEGO service name -S, --show-error Show error even when -s is used -s, --silent Silent mode --socks4 SOCKS4 proxy on given host + port --socks4a SOCKS4a proxy on given host + port --socks5 SOCKS5 proxy on given host + port --socks5-basic Enable username/password auth for SOCKS5 proxies --socks5-gssapi Enable GSS-API auth for SOCKS5 proxies --socks5-gssapi-nec Compatibility with NEC SOCKS5 server --socks5-gssapi-service SOCKS5 proxy service name for GSS-API --socks5-hostname SOCKS5 proxy, pass host name to proxy -Y, --speed-limit Stop transfers slower than this -y, --speed-time Trigger 'speed-limit' abort after this time --ssl Try SSL/TLS --ssl-allow-beast Allow security flaw to improve interop --ssl-no-revoke Disable cert revocation checks (WinSSL) --ssl-reqd Require SSL/TLS -2, --sslv2 Use SSLv2 -3, --sslv3 Use SSLv3 --stderr Where to redirect stderr --styled-output Enable styled output for HTTP headers --suppress-connect-headers Suppress proxy CONNECT response headers --tcp-fastopen Use TCP Fast Open --tcp-nodelay Use the TCP_NODELAY option -t, --telnet-option Set telnet option --tftp-blksize Set TFTP BLKSIZE option --tftp-no-options Do not send any TFTP options -z, --time-cond

开始通过curl命令安装docker-compose,命令行如下所示:

[fabric@localhost ~]$ sudo curl -L https://github.com/docker/compose/releases/download/1.27.3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
[sudo] fabric 的密码:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   651  100   651    0     0    363      0  0:00:01  0:00:01 --:--:--   363
100 11.6M  100 11.6M    0     0   107k      0  0:01:51  0:01:51 --:--:-- 85862

其中,“uname -s”是查看操作系统“linux”  ,“uname -m” 是查看芯片架构是基于“x86_64”,当然,这是在我的linux上敲命令查看到的。

执行完成后,可以看到/usr/local/bin/目录中增加了一个文件“docker-compose”。

[fabric@localhost ~]$ ll -lrt /usr/local/bin/docker-compose 
-rw-r--r--. 1 root root 12219168 9月  21 16:02 /usr/local/bin/docker-compose

docker-compose是个工具,因此需要执行权限:

chmod +x /usr/local/bin/docker-compose

执行docker-compose测试,查看其版本:

[fabric@localhost ~]$ docker-compose -veriosn
docker-compose version 1.27.3, build 4092ae5d

可以看出fabric是可以执行docker-compose命令,说明已经安装成功。

安装一些linux用的额外第三方包的yum源,可能用不到,但先安装上:

  • EPEL源安装:
[fabric@localhost ~]$ sudo yum -y install epel-release
上次元数据过期检查:0:21:09 前,执行于 2020年09月21日 星期一 15时53分41秒。
依赖关系解决。
========================================================================================================================================================================
 软件包                                      架构                                  版本                                     仓库                                   大小
========================================================================================================================================================================
安装:
 epel-release                                noarch                                8-8.el8                                  extras                                 23 k

事务概要
========================================================================================================================================================================
安装  1 软件包

总下载:23 k
安装大小:32 k
下载软件包:
epel-release-8-8.el8.noarch.rpm                                                                                                         234 kB/s |  23 kB     00:00    
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                    225 kB/s |  23 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                         1/1 
  安装    : epel-release-8-8.el8.noarch                                                                                                                             1/1 
  运行脚本: epel-release-8-8.el8.noarch                                                                                                                             1/1 
  验证    : epel-release-8-8.el8.noarch                                                                                                                             1/1 
Installed products updated.

已安装:
  epel-release-8-8.el8.noarch                                                                                                                                           

完毕!
[fabric@localhost ~]$ 
  • 安装python3.6
[fabric@localhost fabric]$ sudo yum install -y  python36
上次元数据过期检查:1:48:42 前,执行于 2020年09月21日 星期一 16时16分37秒。
软件包 python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!
[fabric@localhost fabric]$ sudo curl -O https://bootstrap.pypa.io/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1841k  100 1841k    0     0  43626      0  0:00:43  0:00:43 --:--:-- 47349
[fabric@localhost fabric]$ sudo /usr/bin/python3.6 get-pip.py
Collecting pip
  Downloading pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 50 kB/s 
Collecting wheel
  Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB)
Installing collected packages: pip, wheel
  Attempting uninstall: pip
    Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
  WARNING: The scripts pip, pip3 and pip3.6 are installed in '/usr/local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script wheel is installed in '/usr/local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.3 wheel-0.35.1

至此,docker相关的安装就结束了。

2.4 Fabric安装

2.4.1 Fabric下载

在fabric用户的根目录下有个“go”目录,到这个目录中建立“src/hyperledger”目录,用于存放下载fabric源代码。

进入“/home/fabric/go/src/hyperledger”目录中,执行下载命令:

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

ps:如果没有git工具,直接输入“yum -y install git ”安装即可。

下载完毕后,检出2.1版本,命令执行如下:

[fabric@localhost fabric]$  sudo git checkout v2.1.0
之前的 HEAD 位置是 5ea85bc54 Fabric v2.2.0 release commit
HEAD 目前位于 1bdf97537 Fabric v2.1.0 release commit

然后,进入fabric/scripts目录,完整目录为:/home/fabric/go/src/hyperledger/fabric/scripts,通过ls命令查看:

[fabric@localhost fabric]$ cd scripts/
[fabric@localhost scripts]$ ls
bootstrap.sh   check_file_name_spaces.sh  check_references.sh      compile_protos.sh  generateHelpDocs.sh  run-integration-tests.sh
changelog.sh   check_go_version.sh        check_spelling.sh        fabric-samples     golinter.sh          run-unit-tests.sh
check_deps.sh  check_license.sh           check_trailingspaces.sh  functions.sh       metrics_doc.sh
[fabric@localhost scripts]$ 

找到bootstrap.sh文件,然后通过sh命令执行bootstrap.sh命令,命令执行如下:

执行这个命令前有个错误就是因为这个fabric目录是属于root/root权限,因此,我执行chown命令,将用户权限赋值给了fabric用户(也就是我当前用的用户)。

[fabric@localhost scripts]$ sh bootstrap.sh 

Clone hyperledger/fabric-samples repo

===> Cloning hyperledger/fabric-samples repo and checkout v2.1.0
正克隆到 'fabric-samples'...
remote: Enumerating objects: 6441, done.
remote: Total 6441 (delta 0), reused 0 (delta 0), pack-reused 6441
接收对象中: 100% (6441/6441), 3.69 MiB | 27.00 KiB/s, 完成.
处理 delta 中: 100% (3364/3364), 完成.
注意:正在检出 'v2.1.0'。

您正处于分离头指针状态。您可以查看、做试验性的修改及提交,并且您可以通过另外
的检出分支操作丢弃在这个状态下所做的任何提交。

如果您想要通过创建分支来保留在此状态下所做的提交,您可以通过在检出命令添加
参数 -b 来实现(现在或稍后)。例如:

  git checkout -b <新分支名>

HEAD 目前位于 d53c1ef making commercial-paper application-java to fit 2.0.0 (#160)

Pull Hyperledger Fabric binaries

===> Downloading version 2.1.0 platform specific fabric binaries
===> Downloading:  https://github.com/hyperledger/fabric/releases/download/v2.1.0/hyperledger-fabric-linux-amd64-2.1.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   667  100   667    0     0    284      0  0:00:02  0:00:02 --:--:--   284
100 72.7M  100 72.7M    0     0   195k      0  0:06:21  0:06:21 --:--:--  682k
==> Done.
===> Downloading version 1.4.6 platform specific fabric-ca-client binary
===> Downloading:  https://github.com/hyperledger/fabric-ca/releases/download/v1.4.6/hyperledger-fabric-ca-linux-amd64-1.4.6.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   670  100   670    0     0    549      0  0:00:01  0:00:01 --:--:--   548
100 23.3M  100 23.3M    0     0   227k      0  0:01:44  0:01:44 --:--:--  290k
==> Done.

Pull Hyperledger Fabric docker images

FABRIC_IMAGES: peer orderer ccenv tools nodeenv baseos javaenv
===> Pulling fabric Images
====> hyperledger/fabric-peer:2.1.0
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-orderer:2.1.0
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-ccenv:2.1.0
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-tools:2.1.0
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-nodeenv:2.1.0
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-baseos:2.1.0
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-javaenv:2.1.0
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
===> Pulling fabric ca Image
====> hyperledger/fabric-ca:1.4.6
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
===> Pulling thirdparty docker images
====> hyperledger/fabric-zookeeper:0.4.18
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-kafka:0.4.18
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
====> hyperledger/fabric-couchdb:0.4.18
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

===> List out hyperledger docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[fabric@localhost scripts]$ 

出现几个问题(老小白太难了):

1、checkout的版本有问题,我checkout版本为2.1,但是实际是2.0;

2、通过“FABRIC_IMAGES: peer orderer ccenv tools nodeenv baseos javaenv”提示,需要安装node.js和java运行环境。

3、在一篇文章中有人提到fabric中所用的nodejs版本只支持python2.7,而我现在装的python是3.6版本,所以,我得把python回退到2.7版本。

然后,查看java和node.js都没有安装,于是,下面又开始补装java和node,因为node是基于java,所以,先装java,再装python2.7,,最后装nodejs。

  • 安装java运行环境

通过yum安装,先检查yum源中是否有java1.8的安装包,命令如下:

[fabric@localhost scripts]$ yum list java-1.8*
Docker CE Stable - x86_64                                                                                                               5.0 kB/s | 3.5 kB     00:00    
Docker CE Test - x86_64                                                                                                                  41 kB/s |  65 kB     00:01    
Docker CE Nightly - x86_64                                                                                                               36 kB/s |  91 kB     00:02    
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                  117 kB/s | 132 kB     00:01    
Extra Packages for Enterprise Linux 8 - x86_64                                                                                          672 kB/s | 8.0 MB     00:12    
可安装的软件包
java-1.8.0-openjdk.x86_64                                                              1:1.8.0.265.b01-0.el8_2                                                 AppStream
java-1.8.0-openjdk-accessibility.x86_64                                                1:1.8.0.265.b01-0.el8_2                                                 AppStream
java-1.8.0-openjdk-demo.x86_64                                                         1:1.8.0.265.b01-0.el8_2                                                 AppStream
java-1.8.0-openjdk-devel.x86_64                                                        1:1.8.0.265.b01-0.el8_2                                                 AppStream
java-1.8.0-openjdk-headless.x86_64                                                     1:1.8.0.265.b01-0.el8_2                                                 AppStream
java-1.8.0-openjdk-javadoc.noarch                                                      1:1.8.0.265.b01-0.el8_2                                                 AppStream
java-1.8.0-openjdk-javadoc-zip.noarch                                                  1:1.8.0.265.b01-0.el8_2                                                 AppStream
java-1.8.0-openjdk-src.x86_64                                                          1:1.8.0.265.b01-0.el8_2                                                 AppStream

可以看出有java1.8的安装包,执行安装命令,如下:

[fabric@localhost scripts]$ sudo yum install java-1.8.0-openjdk* -y
已安装:
  copy-jdk-configs-3.7-1.el8.noarch                                                    java-1.8.0-openjdk-1:1.8.0.265.b01-0.el8_2.x86_64                               
  java-1.8.0-openjdk-accessibility-1:1.8.0.265.b01-0.el8_2.x86_64                      java-1.8.0-openjdk-demo-1:1.8.0.265.b01-0.el8_2.x86_64                          
  java-1.8.0-openjdk-devel-1:1.8.0.265.b01-0.el8_2.x86_64                              java-1.8.0-openjdk-headless-1:1.8.0.265.b01-0.el8_2.x86_64                      
  java-1.8.0-openjdk-javadoc-1:1.8.0.265.b01-0.el8_2.noarch                            java-1.8.0-openjdk-javadoc-zip-1:1.8.0.265.b01-0.el8_2.noarch                   
  java-1.8.0-openjdk-src-1:1.8.0.265.b01-0.el8_2.x86_64                                java-atk-wrapper-0.33.2-6.el8.x86_64                                            
  javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch                    lksctp-tools-1.0.18-3.el8.x86_64                                                
  ttmkfdir-3.0.9-54.el8.x86_64                                                         tzdata-java-2020a-1.el8.noarch                                                  
  xorg-x11-fonts-Type1-7.5-19.el8.noarch                                              

完毕!

可以看出这个命令安装了很多的东西,包括java的源码都给安装进来了,但在无法确定哪些东西有用的情况下,只能全部装了。

执行java -version命令查看一下版本:

[fabric@localhost scripts]$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)

这样就代表java安装成功。

  • 安装python2.7

先查看python装哪儿,有什么版本,命令如下:

[fabric@localhost scripts]$ whereis python
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/lib/python3.6 /usr/lib64/python3.6 /usr/local/lib/python3.6 /usr/include/python3.6m /usr/share/man/man1/python.1.gz

好像目前我就装了一个3.6的版本。现在就可以卸载3.6版本,执行命令如下:

[root@localhost scripts]# rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps

我是直接切换到root用户执行命令,然后通过命令“whereis python3 |xargs rm -frv” 删除残留的文件。

删除时出现错误,导致yum不能用,因为yum命令是基于python,可能我误删除把系统自带的python也给删除了。没有办法,只能暴力解决,先删除所有的python,执行命令如下:

[root@localhost fabric]# rpm -qa|grep python|xargs rpm -e --allmatches --nodeps
[root@localhost fabric]# whereis python|xargs rm -fr
[root@localhost fabric]# whereis python
python:
[root@localhost fabric]# 

卸载yum,执行命令如下:

[root@localhost fabric]# rpm -qa|grep yum|xargs rpm -e --allmatches --nodeps 
[root@localhost fabric]# rm -rf /etc/yum.repos.d/*
[root@localhost fabric]# whereis yum|xargs rm -fr
[root@localhost fabric]# whereis yum
yum:

下载对应版本的python rpm包和yum rpm包

先建立一个/usr/local/src/python目录,用于存放python和yum下载文件。先到https://www.python.org/downloads/上可以找python版本,主要是2.7版本还有小版本号,找到后用wget下载,或者是用其他下载工具下载,然后上传到linux的目录中,也可以,我这里就直接用wget下载了。

Fabric学习--环境搭建_第2张图片

切换到/usr/local/src/python目录,选择Python2.7.18版本下载:

[root@localhost src]# wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tar.xz

因为是直接连接到python网站去下载,所以这个过程有点慢,需要耐心等待。耐心是一种美德,通往成功之路往往是寂寞的,安装环境的过程不能怕出错,只有出错才能探究真理,只有出错才会明白原来自己一开始就错了,否则,你永远不清楚自己在错误的道路上渐行渐远。利用下载时间写了些废话,就下载完了。

按照惯例对下载文件进行解压得到一个目录:/usr/local/src/python/Python-2.7.18,通过ls命令显示:

[root@localhost Python-2.7.18]# ls
aclocal.m4    config.sub  configure.ac  Doc      Include     Lib      Mac              Misc     Objects  PC       pyconfig.h.in  README  setup.py
config.guess  configure   Demo          Grammar  install-sh  LICENSE  Makefile.pre.in  Modules  Parser   PCbuild  Python         RISCOS  Tools
[root@localhost Python-2.7.18]# 

安装前配置安装目录,命令如下:

[root@localhost Python-2.7.18]# ./configure --prefix=/usr/local
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python2.7... no
checking for python3... no
checking for python... no
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux2
checking EXTRAPLATDIR... 
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/python/Python-2.7.18':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

结果,又出错了,仔细观察出错信息,原来是要安装GCC编译器,得,又要出现安装分支,先装gcc吧。

使用“cat /etc/centos-release”命令,查看centos系统版本,得到版本好为:8.2.2004,然后去www.rpmfind.net或者gcc.gnu.org 查找对应的gcc版本。

然后用wget下载,命令如下:(这里有个小技巧就是把鼠标放在连接上,然后右键弹出菜单,复制链接地址,再把地址拷贝到wget后面即可。)。ps:感谢wget啊,始终不让我失望。

[root@localhost myinstall]# wget http://www.rpmfind.net/linux/centos/8.2.2004/AppStream/x86_64/os/Packages/gcc-8.3.1-5.el8.0.2.x86_64.rpm

问题又来了,这种安装需要一堆的依赖包,如下:

Requires

  • /bin/sh
  • /bin/sh
  • /bin/sh
  • /sbin/install-info
  • /sbin/install-info
  • binutils >= 2.30-17
  • cpp = 8.3.1-5.el8.0.2
  • glibc-devel >= 2.2.90-12
  • ld-linux-x86-64.so.2()(64bit)
  • ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)
  • libc.so.6()(64bit)
  • libc.so.6(GLIBC_2.11)(64bit)
  • libc.so.6(GLIBC_2.14)(64bit)
  • libc.so.6(GLIBC_2.2.5)(64bit)
  • libc.so.6(GLIBC_2.3)(64bit)
  • libc.so.6(GLIBC_2.3.3)(64bit)
  • libc.so.6(GLIBC_2.4)(64bit)
  • libdl.so.2()(64bit)
  • libdl.so.2(GLIBC_2.2.5)(64bit)
  • libgcc >= 8.3.1-5.el8.0.2
  • libgmp.so.10()(64bit)
  • libgomp = 8.3.1-5.el8.0.2
  • libgomp.so.1()(64bit)
  • libisl.so.15()(64bit)
  • liblto_plugin.so.0()(64bit)
  • libm.so.6()(64bit)
  • libm.so.6(GLIBC_2.2.5)(64bit)
  • libmpc.so.3()(64bit)
  • libmpfr.so.4()(64bit)
  • libz.so.1()(64bit)
  • rpmlib(CompressedFileNames) <= 3.0.4-1
  • rpmlib(FileDigests) <= 4.6.0-1
  • rpmlib(PartialHardlinkSets) <= 4.0.4-1
  • rpmlib(PayloadFilesHavePrefix) <= 4.0-1
  • rpmlib(PayloadIsXz) <= 5.2-1
  • rtld(GNU_HASH)

没有办法,只能按照列表到 https://pkgs.org/download/zlib上一个个的下载。有些用rpm -qa查看,有的就不用下载了。

这样下载的办法太麻烦了,我实在没有兴趣往下走,突然记得有centos8的镜像文件,因此尝试从iso文件安装。这就简单了,但是问题又来了,就是很多包都全装了一遍,python恐怕又是安装的3版本。

这个就简单点:

1、先映射centos8的iso文件到虚拟机的cdrom;

2、用df -h命令查看iso文件映射到那个盘符,我的是映射到/dev/sr1

3、进入/mnt目录,使用mkdir命令建立一个新目录cdrom,也就是/mnt/cdrom

4、使用mount /dev/sr1 /mnt/cdrom 挂在iso到cdrom上即可。

5、进入cdrom目录,cd /mnt/cdrom

6、查看:

   

7、进入BaseOS目录,里面有个Packages目录,这个目录里面全是rpm包

Fabric学习--环境搭建_第3张图片

里面rpm包太多,就不都截出来。然后执行安装命令:

8、因为不清楚到底缺少哪些包,没办法只能全部安装一遍

    rpm -Uvh *.rpm --nodeps --force

9、安装完后执行gcc -v命令,但找不到gcc命令,这时系统会提示可以从安装包安装,选择安装即可,具体过程如下:

[root@localhost Packages]# gcc -v
bash: gcc: 未找到命令...
安装软件包“gcc”以提供命令“gcc”? [N/y] yy

安装软件包“gcc”以提供命令“gcc”? [N/y] y


 * 正在队列中等待... 
 * 装入软件包列表... 
下列软件包必须安装:
 cpp-8.3.1-5.el8.0.2.x86_64	The C Preprocessor
 gcc-8.3.1-5.el8.0.2.x86_64	Various compilers (C, C++, Objective-C, ...)
 isl-0.16.1-6.el8.x86_64	Integer point manipulation library
继续更改? [N/y] y


 * 正在队列中等待... 
 * 正在等待认证... 
 * 正在队列中等待... 

 * 装入软件包列表... 
 * 正在下载软件包... 
 * 正在请求数据... 
 * 正在测试更改... 
 * 正在安装软件包... 
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
目标:x86_64-redhat-linux
配置为:../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC) 

再次执行gcc -v就正常提示版本信息,这样gcc就装好了,接下来的g++也是同样方法,执行g++ -v命令,然后提示安装包可安装,根据系统提示执行即可。

重新安装python2.7

第一次瞎删把yum搞得不能用了,这次就不删除原有版本,直接重新安装一个版本。直接到下载python目录中执行命令指定安装目录:

 ./configure --prefix=/usr/local

编译:

make && make install

然后,到/usr/local/bin目录可以看到python2.7。这样python就装好了,现在就差nodejs的安装。

安装nodejs

下载:wget https://npm.taobao.org/mirrors/node/v8.9.4/node-v8.9.4-linux-x64.tar.xz

ln -s /opt/app/nodejs/node-v8.9.4-linux-x64/bin/npm /usr/local/bin/

ln -s /opt/app/nodejs/node-v8.9.4-linux-x64/bin/node /usr/local/bin/

https://download.docker.com/linux/centos/8/x86_64/stable/Packages/

 

docker重新安装:

docker安装多次没有成功,后来把containerd.io-1.3.7-3.1.el8.x86_64.rpm单独先安装,然后在安装docker服务端和客户端,就成功了。

dnf install https://download.docker.com/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm

docker-ce和docker-cli直接用yum命令安装即可。

docker安装成功后可以

 

下载fabric镜像

下载多次没有成功,总是卡在某个地方,某天早上安装发现就很顺利,原来是网路问题:

下载很简单就是进入:scripts目录执行:sh bootstrap.sh

中间出现过ssl连接拒绝的问题,上网查了一下,把你要连接的域名去网上查一下ip地址,然后吧ip地址和域名一起加入到/etc/hosts文件中,查询网站为:https://www.ipaddress.com/

下载完后的成功提示如下:

[fabric@localhost scripts]$ sh bootstrap.sh 

Clone hyperledger/fabric-samples repo

===> Checking out v2.1.0 of hyperledger/fabric-samples
HEAD 目前位于 d53c1ef making commercial-paper application-java to fit 2.0.0 (#160)

Pull Hyperledger Fabric binaries

===> Downloading version 2.1.0 platform specific fabric binaries
===> Downloading:  https://github.com/hyperledger/fabric/releases/download/v2.1.0/hyperledger-fabric-linux-amd64-2.1.0.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   667  100   667    0     0    521      0  0:00:01  0:00:01 --:--:--   521
100 72.7M  100 72.7M    0     0   159k      0  0:07:46  0:07:46 --:--:--  383k
==> Done.
===> Downloading version 1.4.6 platform specific fabric-ca-client binary
===> Downloading:  https://github.com/hyperledger/fabric-ca/releases/download/v1.4.6/hyperledger-fabric-ca-linux-amd64-1.4.6.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   670  100   670    0     0     98      0  0:00:06  0:00:06 --:--:--   188
100 23.3M  100 23.3M    0     0   276k      0  0:01:26  0:01:26 --:--:--  278k
==> Done.

Pull Hyperledger Fabric docker images

FABRIC_IMAGES: peer orderer ccenv tools nodeenv baseos javaenv
===> Pulling fabric Images
====> hyperledger/fabric-peer:2.1.0
2.1.0: Pulling from hyperledger/fabric-peer
Digest: sha256:fcf543313b6bbcea3a995d71a673e320e371ca6b19795d107323426a269635cb
Status: Image is up to date for hyperledger/fabric-peer:2.1.0
docker.io/hyperledger/fabric-peer:2.1.0
====> hyperledger/fabric-orderer:2.1.0
2.1.0: Pulling from hyperledger/fabric-orderer
Digest: sha256:91c3208524433717bc859a88c6f4573d07facb4171e53a25eb171242ddd36a93
Status: Image is up to date for hyperledger/fabric-orderer:2.1.0
docker.io/hyperledger/fabric-orderer:2.1.0
====> hyperledger/fabric-ccenv:2.1.0
2.1.0: Pulling from hyperledger/fabric-ccenv
Digest: sha256:5d221d5e6663a81e02c91c5d05cd502d315482009a7c406e246e899e0c68ddb6
Status: Image is up to date for hyperledger/fabric-ccenv:2.1.0
docker.io/hyperledger/fabric-ccenv:2.1.0
====> hyperledger/fabric-tools:2.1.0
2.1.0: Pulling from hyperledger/fabric-tools
Digest: sha256:498e3beaee06ac9184f81570ffbcf25f205146c4a93b50b04a9c221d688c1e96
Status: Image is up to date for hyperledger/fabric-tools:2.1.0
docker.io/hyperledger/fabric-tools:2.1.0
====> hyperledger/fabric-nodeenv:2.1.0
2.1.0: Pulling from hyperledger/fabric-nodeenv
Digest: sha256:0f3b87a19497a3abc00d5e8becec893dc14b12bc0f6417221a3623fd28f59001
Status: Image is up to date for hyperledger/fabric-nodeenv:2.1.0
docker.io/hyperledger/fabric-nodeenv:2.1.0
====> hyperledger/fabric-baseos:2.1.0
2.1.0: Pulling from hyperledger/fabric-baseos
Digest: sha256:87ddbba7b08af7081d6d54205b5fb6748ff3a50f0bcc64c79d0c1e5ae8784706
Status: Image is up to date for hyperledger/fabric-baseos:2.1.0
docker.io/hyperledger/fabric-baseos:2.1.0
====> hyperledger/fabric-javaenv:2.1.0
2.1.0: Pulling from hyperledger/fabric-javaenv
Digest: sha256:62deac7c68ce4e9965142cc8e4885bb2f602565a7e708084df8f14182074243b
Status: Image is up to date for hyperledger/fabric-javaenv:2.1.0
docker.io/hyperledger/fabric-javaenv:2.1.0
===> Pulling fabric ca Image
====> hyperledger/fabric-ca:1.4.6
1.4.6: Pulling from hyperledger/fabric-ca
Digest: sha256:c7eed780d2908155ff2754b65aa3e4e3438f93683c2a45a8546c30a1756bebd3
Status: Image is up to date for hyperledger/fabric-ca:1.4.6
docker.io/hyperledger/fabric-ca:1.4.6
===> Pulling thirdparty docker images
====> hyperledger/fabric-zookeeper:0.4.18
0.4.18: Pulling from hyperledger/fabric-zookeeper
Digest: sha256:ff5f9893355a56ac7dbc53d0b6a68c18cf7adfcc0c34a55a717866cb9c00a442
Status: Image is up to date for hyperledger/fabric-zookeeper:0.4.18
docker.io/hyperledger/fabric-zookeeper:0.4.18
====> hyperledger/fabric-kafka:0.4.18
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
Error response from daemon: No such image: hyperledger/fabric-kafka:0.4.18
Error response from daemon: No such image: hyperledger/fabric-kafka:0.4.18
====> hyperledger/fabric-couchdb:0.4.18
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout
Error response from daemon: No such image: hyperledger/fabric-couchdb:0.4.18
Error response from daemon: No such image: hyperledger/fabric-couchdb:0.4.18

===> List out hyperledger docker images
hyperledger/fabric-tools       2.1                 bf6ec47ac5fd        5 months ago        522MB
hyperledger/fabric-tools       2.1.0               bf6ec47ac5fd        5 months ago        522MB
hyperledger/fabric-tools       latest              bf6ec47ac5fd        5 months ago        522MB
hyperledger/fabric-peer        2.1                 4136ba27e279        5 months ago        56.6MB
hyperledger/fabric-peer        2.1.0               4136ba27e279        5 months ago        56.6MB
hyperledger/fabric-peer        latest              4136ba27e279        5 months ago        56.6MB
hyperledger/fabric-orderer     2.1                 af4fdf2df06c        5 months ago        39.4MB
hyperledger/fabric-orderer     2.1.0               af4fdf2df06c        5 months ago        39.4MB
hyperledger/fabric-orderer     latest              af4fdf2df06c        5 months ago        39.4MB
hyperledger/fabric-ccenv       2.1                 eefa22c7b7e7        5 months ago        554MB
hyperledger/fabric-ccenv       2.1.0               eefa22c7b7e7        5 months ago        554MB
hyperledger/fabric-ccenv       latest              eefa22c7b7e7        5 months ago        554MB
hyperledger/fabric-baseos      2.1                 52bb8d969801        5 months ago        6.94MB
hyperledger/fabric-baseos      2.1.0               52bb8d969801        5 months ago        6.94MB
hyperledger/fabric-baseos      latest              52bb8d969801        5 months ago        6.94MB
hyperledger/fabric-nodeenv     2.1                 8f2b5101881b        5 months ago        292MB
hyperledger/fabric-nodeenv     2.1.0               8f2b5101881b        5 months ago        292MB
hyperledger/fabric-nodeenv     latest              8f2b5101881b        5 months ago        292MB
hyperledger/fabric-javaenv     2.1                 3e83cbc5b332        5 months ago        505MB
hyperledger/fabric-javaenv     2.1.0               3e83cbc5b332        5 months ago        505MB
hyperledger/fabric-javaenv     latest              3e83cbc5b332        5 months ago        505MB
hyperledger/fabric-ca          1.4                 3b96a893c1e4        7 months ago        150MB
hyperledger/fabric-ca          1.4.6               3b96a893c1e4        7 months ago        150MB
hyperledger/fabric-ca          latest              3b96a893c1e4        7 months ago        150MB
hyperledger/fabric-zookeeper   0.4                 ede9389347db        10 months ago       276MB
hyperledger/fabric-zookeeper   0.4.18              ede9389347db        10 months ago       276MB
hyperledger/fabric-zookeeper   latest              ede9389347db        10 months ago       276MB
[fabric@localhost scripts]$ 

启动网络

进入/home/fabric/go/src/hyperledger/fabric/scripts/fabric-samples/first-network目录,执行

sh byfn.sh up

报错:

go: google.golang.org/[email protected]: unrecognized import path "google.golang.org/genproto" (https fetch: Get https://google.golang.org/genproto?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: finding github.com/mitchellh/go-homedir v1.1.0
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/crypto" (https fetch: Get https://golang.org/x/crypto?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: google.golang.org/[email protected]: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/net" (https fetch: Get https://golang.org/x/net?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/sys" (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/net" (https fetch: Get https://golang.org/x/net?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/sync" (https fetch: Get https://golang.org/x/sync?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/tools" (https fetch: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/tools" (https fetch: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: connect: connection refused)

仔细查看了一下,发现是下载go的依赖包,后来发现go的版本太低,我的版本是1.11,但需要1.14.1版本以上,于是,开始升级go。

升级go

卸载go

sudo rm -rf /usr/local/go
sudo rm -rf /usr/bin/go

升级go

到/usr/local目录下下载:

sudo wget --no-check-certificate https://storage.googleapis.com/golang/go1.14.1.linux-amd64.tar.gz
sudo tar xvf go1.14.1.linux-amd64.tar.gz
sudo ln -s /usr/local/go/bin/* /usr/bin/

还是有些go依赖包下不来,没办法,只能更换go的下载源,因为默认的go地址被墙了,所以我们要更换地址,更换为七牛云的镜像,直接运行下面两条命令即可:

go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

防火墙问题

go升级完成后,又报错:

Channel name : mychannel
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=1
+ set +x
Error: failed to create deliver client for orderer: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.21.0.10:7050: connect: no route to host"
!!!!!!!!!!!!!!! Channel creation failed !!!!!!!!!!!!!!!!
========= ERROR !!! FAILED to execute End-2-End Scenario ===========

解决方案:

查看防火墙状态:

systemctl status firewalld.service

查看如下:

Fabric学习--环境搭建_第4张图片

发现防火墙的确是开着,关闭防火墙:

systemctl stop firewalld.service

再次重启,但是又发现错误,错误信息如下:

 Creating network "net_byfn" with the default driver ERROR

又再次百度,经提示,防火墙关闭后,需要重启docker服务,于是又重启docker服务,执行如下:

service docker restart

再次通过命令启动,执行过程信息如下:

[fabric@localhost first-network]$ sh byfn.sh up
Starting for channel 'mychannel' with CLI timeout of '10' seconds and CLI delay of '3' seconds
Continue? [Y/n] y
proceeding ...
LOCAL_VERSION=2.1.0
DOCKER_IMAGE_VERSION=2.1.0
/home/fabric/go/src/hyperledger/fabric/scripts/fabric-samples/bin/cryptogen

##########################################################
##### Generate certificates using cryptogen tool #########
##########################################################
+ cryptogen generate --config=./crypto-config.yaml
org1.example.com
org2.example.com
+ res=0
+ set +x

Generate CCP files for Org1 and Org2
/home/fabric/go/src/hyperledger/fabric/scripts/fabric-samples/bin/configtxgen
##########################################################
#########  Generating Orderer Genesis block ##############
##########################################################
+ configtxgen -profile SampleMultiNodeEtcdRaft -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
2020-09-24 21:41:33.692 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-09-24 21:41:33.727 CST [common.tools.configtxgen.localconfig] completeInitialization -> INFO 002 orderer type: etcdraft
2020-09-24 21:41:33.727 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-09-24 21:41:33.727 CST [common.tools.configtxgen.localconfig] Load -> INFO 004 Loaded configuration: /home/fabric/go/src/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-09-24 21:41:33.729 CST [common.tools.configtxgen] doOutputBlock -> INFO 005 Generating genesis block
2020-09-24 21:41:33.730 CST [common.tools.configtxgen] doOutputBlock -> INFO 006 Writing genesis block
+ res=0
+ set +x

#################################################################
### Generating channel configuration transaction 'channel.tx' ###
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID mychannel
2020-09-24 21:41:33.754 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-09-24 21:41:33.792 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/go/src/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-09-24 21:41:33.792 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 003 Generating new channel configtx
2020-09-24 21:41:33.795 CST [common.tools.configtxgen] doOutputChannelCreateTx -> INFO 004 Writing new channel tx
+ res=0
+ set +x

#################################################################
#######    Generating anchor peer update for Org1MSP   ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID mychannel -asOrg Org1MSP
2020-09-24 21:41:33.820 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-09-24 21:41:33.853 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/go/src/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-09-24 21:41:33.853 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-09-24 21:41:33.855 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
+ res=0
+ set +x

#################################################################
#######    Generating anchor peer update for Org2MSP   ##########
#################################################################
+ configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID mychannel -asOrg Org2MSP
2020-09-24 21:41:33.881 CST [common.tools.configtxgen] main -> INFO 001 Loading configuration
2020-09-24 21:41:33.913 CST [common.tools.configtxgen.localconfig] Load -> INFO 002 Loaded configuration: /home/fabric/go/src/hyperledger/fabric/scripts/fabric-samples/first-network/configtx.yaml
2020-09-24 21:41:33.913 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 003 Generating anchor peer update
2020-09-24 21:41:33.914 CST [common.tools.configtxgen] doOutputAnchorPeersUpdate -> INFO 004 Writing anchor peer update
+ res=0
+ set +x

Creating network "net_byfn" 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_peer1.org1.example.com" with default driver
Creating volume "net_peer0.org2.example.com" with default driver
Creating volume "net_peer1.org2.example.com" with default driver
Creating volume "net_orderer2.example.com" with default driver
Creating volume "net_orderer3.example.com" with default driver
Creating volume "net_orderer4.example.com" with default driver
Creating volume "net_orderer5.example.com" with default driver
Creating peer1.org1.example.com ... done
Creating peer1.org2.example.com ... done
Creating orderer5.example.com   ... done
Creating orderer2.example.com   ... done
Creating orderer.example.com    ... done
Creating peer0.org1.example.com ... done
Creating orderer3.example.com   ... done
Creating orderer4.example.com   ... done
Creating peer0.org2.example.com ... done
Creating cli                    ... done
CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS                  PORTS                                NAMES
c85bdb32bb09        hyperledger/fabric-tools:latest     "/bin/bash"         4 seconds ago       Up Less than a second                                        cli
a3d2175ee966        hyperledger/fabric-orderer:latest   "orderer"           14 seconds ago      Up 1 second             7050/tcp, 0.0.0.0:11050->11050/tcp   orderer5.example.com
bdb22ff904f9        hyperledger/fabric-peer:latest      "peer node start"   14 seconds ago      Up 6 seconds            7051/tcp, 0.0.0.0:10051->10051/tcp   peer1.org2.example.com
12710a646cc0        hyperledger/fabric-orderer:latest   "orderer"           14 seconds ago      Up 2 seconds            7050/tcp, 0.0.0.0:8050->8050/tcp     orderer2.example.com
ded16f3cccd1        hyperledger/fabric-peer:latest      "peer node start"   14 seconds ago      Up 5 seconds            7051/tcp, 0.0.0.0:9051->9051/tcp     peer0.org2.example.com
6a7d312f49b6        hyperledger/fabric-orderer:latest   "orderer"           14 seconds ago      Up 1 second             7050/tcp, 0.0.0.0:10050->10050/tcp   orderer4.example.com
6179e53f3beb        hyperledger/fabric-orderer:latest   "orderer"           14 seconds ago      Up 3 seconds            0.0.0.0:7050->7050/tcp               orderer.example.com
6258df7d0250        hyperledger/fabric-peer:latest      "peer node start"   14 seconds ago      Up 7 seconds            0.0.0.0:7051->7051/tcp               peer0.org1.example.com
c524d03af178        hyperledger/fabric-orderer:latest   "orderer"           14 seconds ago      Up 9 seconds            7050/tcp, 0.0.0.0:9050->9050/tcp     orderer3.example.com
f79756c2a1cf        hyperledger/fabric-peer:latest      "peer node start"   14 seconds ago      Up 9 seconds            7051/tcp, 0.0.0.0:8051->8051/tcp     peer1.org1.example.com
Sleeping 15s to allow Raft cluster to complete booting
Vendoring Go dependencies ...
~/go/src/hyperledger/fabric/scripts/fabric-samples/chaincode/abstore/go ~/go/src/hyperledger/fabric/scripts/fabric-samples/first-network
~/go/src/hyperledger/fabric/scripts/fabric-samples/first-network
Finished vendoring Go dependencies

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

Build your first network (BYFN) end-to-end test

Channel name : mychannel
Creating channel...
+ peer channel create -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/channel.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-09-24 13:42:05.311 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-24 13:42:05.346 UTC [cli.common] readBlock -> INFO 002 Expect block, but got status: &{NOT_FOUND}
2020-09-24 13:42:05.350 UTC [channelCmd] InitCmdFactory -> INFO 003 Endorser and orderer connections initialized
2020-09-24 13:42:05.552 UTC [cli.common] readBlock -> INFO 004 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-09-24 13:42:05.559 UTC [channelCmd] InitCmdFactory -> INFO 005 Endorser and orderer connections initialized
2020-09-24 13:42:05.763 UTC [cli.common] readBlock -> INFO 006 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-09-24 13:42:05.766 UTC [channelCmd] InitCmdFactory -> INFO 007 Endorser and orderer connections initialized
2020-09-24 13:42:05.968 UTC [cli.common] readBlock -> INFO 008 Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-09-24 13:42:05.976 UTC [channelCmd] InitCmdFactory -> INFO 009 Endorser and orderer connections initialized
2020-09-24 13:42:06.179 UTC [cli.common] readBlock -> INFO 00a Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-09-24 13:42:06.182 UTC [channelCmd] InitCmdFactory -> INFO 00b Endorser and orderer connections initialized
2020-09-24 13:42:06.383 UTC [cli.common] readBlock -> INFO 00c Expect block, but got status: &{SERVICE_UNAVAILABLE}
2020-09-24 13:42:06.386 UTC [channelCmd] InitCmdFactory -> INFO 00d Endorser and orderer connections initialized
2020-09-24 13:42:06.594 UTC [cli.common] readBlock -> INFO 00e Received block: 0
===================== Channel 'mychannel' created ===================== 

Having all peers join the channel...
+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-09-24 13:42:06.655 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-24 13:42:06.680 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org1 joined channel 'mychannel' ===================== 

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-09-24 13:42:09.749 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-24 13:42:09.777 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org1 joined channel 'mychannel' ===================== 

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-09-24 13:42:12.846 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-24 13:42:12.870 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer0.org2 joined channel 'mychannel' ===================== 

+ peer channel join -b mychannel.block
+ res=0
+ set +x
2020-09-24 13:42:15.961 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-24 13:42:15.988 UTC [channelCmd] executeJoin -> INFO 002 Successfully submitted proposal to join channel
===================== peer1.org2 joined channel 'mychannel' ===================== 

Updating anchor peers for org1...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org1MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-09-24 13:42:19.061 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-24 13:42:19.074 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org1MSP' on channel 'mychannel' ===================== 

Updating anchor peers for org2...
+ peer channel update -o orderer.example.com:7050 -c mychannel -f ./channel-artifacts/Org2MSPanchors.tx --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
+ res=0
+ set +x
2020-09-24 13:42:22.172 UTC [channelCmd] InitCmdFactory -> INFO 001 Endorser and orderer connections initialized
2020-09-24 13:42:22.190 UTC [channelCmd] update -> INFO 002 Successfully submitted channel update
===================== Anchor peers updated for org 'Org2MSP' on channel 'mychannel' ===================== 

+ peer lifecycle chaincode package mycc.tar.gz --path github.com/hyperledger/fabric-samples/chaincode/abstore/go/ --lang golang --label mycc_1
+ res=0
+ set +x
===================== Chaincode is packaged on peer0.org1 ===================== 

Installing chaincode on peer0.org1...
+ peer lifecycle chaincode install mycc.tar.gz
+ res=0
+ set +x
2020-09-24 13:43:04.972 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response: 
2020-09-24 13:43:04.976 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
===================== Chaincode is installed on peer0.org1 ===================== 

Install chaincode on peer0.org2...
+ peer lifecycle chaincode install mycc.tar.gz
+ res=0
+ set +x
2020-09-24 13:43:33.935 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response: 
2020-09-24 13:43:33.940 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
===================== Chaincode is installed on peer0.org2 ===================== 

+ peer lifecycle chaincode queryinstalled
+ res=0
+ set +x
Installed chaincodes on peer:
Package ID: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f, Label: mycc_1
PackageID is mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
===================== Query installed successful on peer0.org1 on channel ===================== 

+ peer lifecycle chaincode approveformyorg --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f --sequence 1 --waitForEvent
+ set +x
2020-09-24 13:43:34.130 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
2020-09-24 13:43:36.295 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [d200d8dc662890c45e72d9788416b0ad2247db17be14677575c619eaddb25776] committed with status (VALID) at 
===================== Chaincode definition approved on peer0.org1 on channel 'mychannel' ===================== 

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... ===================== 
Attempting to check the commit readiness of the chaincode definition on peer0.org1 ...3 secs
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
+ res=0
+ set +x

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": false
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' ===================== 
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... ===================== 
Attempting to check the commit readiness of the chaincode definition on peer0.org2 ...3 secs
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
+ res=0
+ set +x
+ peer lifecycle chaincode approveformyorg --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --version 1 --init-required --package-id mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f --sequence 1 --waitForEvent

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": false
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' ===================== 
+ set +x
2020-09-24 13:43:42.525 UTC [cli.lifecycle.chaincode] setOrdererClient -> INFO 001 Retrieved channel (mychannel) orderer endpoint: orderer.example.com:7050
2020-09-24 13:43:44.587 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [c3065e609d99bdac3154c6982e60fcd30322de4c095c75237455a6eb1dcefad5] committed with status (VALID) at 
===================== Chaincode definition approved on peer0.org2 on channel 'mychannel' ===================== 

===================== Checking the commit readiness of the chaincode definition on peer0.org1 on channel 'mychannel'... ===================== 
Attempting to check the commit readiness of the chaincode definition on peer0.org1 ...3 secs
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
+ res=0
+ set +x

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": true
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org1 on channel 'mychannel' ===================== 
===================== Checking the commit readiness of the chaincode definition on peer0.org2 on channel 'mychannel'... ===================== 
Attempting to check the commit readiness of the chaincode definition on peer0.org2 ...3 secs
+ peer lifecycle chaincode checkcommitreadiness --channelID mychannel --name mycc --version 1 --sequence 1 --output json --init-required
+ res=0
+ set +x

{
	"approvals": {
		"Org1MSP": true,
		"Org2MSP": true
	}
}
===================== Checking the commit readiness of the chaincode definition successful on peer0.org2 on channel 'mychannel' ===================== 
+ peer lifecycle chaincode commit -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem --channelID mychannel --name mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --version 1 --sequence 1 --init-required
+ res=0
+ set +x
2020-09-24 13:43:53.281 UTC [chaincodeCmd] ClientWait -> INFO 001 txid [d6c6f4da613e14acbad124c50e0cd3783a2568ad67794182719307110be01111] committed with status (VALID) at peer0.org2.example.com:9051
2020-09-24 13:43:53.289 UTC [chaincodeCmd] ClientWait -> INFO 002 txid [d6c6f4da613e14acbad124c50e0cd3783a2568ad67794182719307110be01111] committed with status (VALID) at peer0.org1.example.com:7051
===================== Chaincode definition committed on channel 'mychannel' ===================== 

===================== Querying chaincode definition on peer0.org1 on channel 'mychannel'... ===================== 
Attempting to Query committed status on peer0.org1 ...3 secs
+ peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
+ res=0
+ set +x

Committed chaincode definition for chaincode 'mycc' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org1 on channel 'mychannel' ===================== 
===================== Querying chaincode definition on peer0.org2 on channel 'mychannel'... ===================== 
Attempting to Query committed status on peer0.org2 ...3 secs
+ peer lifecycle chaincode querycommitted --channelID mychannel --name mycc
+ res=0
+ set +x
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt --isInit -c '{"Args":["Init","a","100","b","100"]}'

Committed chaincode definition for chaincode 'mycc' on channel 'mychannel':
Version: 1, Sequence: 1, Endorsement Plugin: escc, Validation Plugin: vscc, Approvals: [Org1MSP: true, Org2MSP: true]
===================== Query chaincode definition successful on peer0.org2 on channel 'mychannel' ===================== 
+ res=0
+ set +x
2020-09-24 13:43:59.539 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' ===================== 

Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... ===================== 
Attempting to Query peer0.org1 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

100
===================== Query successful on peer0.org1 on channel 'mychannel' ===================== 
Sending invoke transaction on peer0.org1 peer0.org2...
+ peer chaincode invoke -o orderer.example.com:7050 --tls true --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n mycc --peerAddresses peer0.org1.example.com:7051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt --peerAddresses peer0.org2.example.com:9051 --tlsRootCertFiles /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt -c '{"Args":["invoke","a","b","10"]}'
+ res=0
+ set +x
2020-09-24 13:44:02.747 UTC [chaincodeCmd] chaincodeInvokeOrQuery -> INFO 001 Chaincode invoke successful. result: status:200 
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' ===================== 

Querying chaincode on peer0.org1...
===================== Querying on peer0.org1 on channel 'mychannel'... ===================== 
Attempting to Query peer0.org1 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x
+ peer lifecycle chaincode install mycc.tar.gz

90
===================== Query successful on peer0.org1 on channel 'mychannel' ===================== 
Installing chaincode on peer1.org2...
+ res=0
+ set +x
2020-09-24 13:44:35.026 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 001 Installed remotely: response: 
2020-09-24 13:44:35.031 UTC [cli.lifecycle.chaincode] submitInstallProposal -> INFO 002 Chaincode code package identifier: mycc_1:40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
===================== Chaincode is installed on peer1.org2 ===================== 

Querying chaincode on peer1.org2...
===================== Querying on peer1.org2 on channel 'mychannel'... ===================== 
Attempting to Query peer1.org2 ...3 secs
+ peer chaincode query -C mychannel -n mycc -c '{"Args":["query","a"]}'
+ res=0
+ set +x

90
===================== Query successful on peer1.org2 on channel 'mychannel' ===================== 

========= All GOOD, BYFN execution completed =========== 


 _____   _   _   ____   
| ____| | \ | | |  _ \  
|  _|   |  \| | | | | | 
| |___  | |\  | | |_| | 
|_____| |_| \_| |____/  

[fabric@localhost first-network]$ 

可以看出,这次没有出错,终于成功执行完了,现在通过docker命令查看一下服务:

[fabric@localhost first-network]$ docker ps
CONTAINER ID        IMAGE                                                                                                                                                                 COMMAND                  CREATED              STATUS              PORTS                                NAMES
daedfd32a9d6        dev-peer1.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f-861731f1fb7a4568b5c4b97482e41ca66bb213f7eb7dd7215635fd371dbc2745   "chaincode -peer.add…"   About a minute ago   Up About a minute                                        dev-peer1.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
e6f093b3b915        dev-peer0.org1.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f-4c20bb52326acfebc71426bf7ea2fb83967081e00ca3fe383d464a100bc1177f   "chaincode -peer.add…"   2 minutes ago        Up 2 minutes                                             dev-peer0.org1.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
f4972fd217da        dev-peer0.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f-667281c6b976fdf7176d974a284355bf1ff337baaab300e5129540a948115e2c   "chaincode -peer.add…"   2 minutes ago        Up 2 minutes                                             dev-peer0.org2.example.com-mycc_1-40aec53f0ee0193b0bd6b63862425298d90e9c3496a840bb54366b2fd66bd18f
c85bdb32bb09        hyperledger/fabric-tools:latest                                                                                                                                       "/bin/bash"              4 minutes ago        Up 4 minutes                                             cli
a3d2175ee966        hyperledger/fabric-orderer:latest                                                                                                                                     "orderer"                4 minutes ago        Up 4 minutes        7050/tcp, 0.0.0.0:11050->11050/tcp   orderer5.example.com
bdb22ff904f9        hyperledger/fabric-peer:latest                                                                                                                                        "peer node start"        4 minutes ago        Up 4 minutes        7051/tcp, 0.0.0.0:10051->10051/tcp   peer1.org2.example.com
12710a646cc0        hyperledger/fabric-orderer:latest                                                                                                                                     "orderer"                4 minutes ago        Up 4 minutes        7050/tcp, 0.0.0.0:8050->8050/tcp     orderer2.example.com
ded16f3cccd1        hyperledger/fabric-peer:latest                                                                                                                                        "peer node start"        4 minutes ago        Up 4 minutes        7051/tcp, 0.0.0.0:9051->9051/tcp     peer0.org2.example.com
6a7d312f49b6        hyperledger/fabric-orderer:latest                                                                                                                                     "orderer"                4 minutes ago        Up 4 minutes        7050/tcp, 0.0.0.0:10050->10050/tcp   orderer4.example.com
6179e53f3beb        hyperledger/fabric-orderer:latest                                                                                                                                     "orderer"                4 minutes ago        Up 4 minutes        0.0.0.0:7050->7050/tcp               orderer.example.com
6258df7d0250        hyperledger/fabric-peer:latest                                                                                                                                        "peer node start"        4 minutes ago        Up 4 minutes        0.0.0.0:7051->7051/tcp               peer0.org1.example.com
c524d03af178        hyperledger/fabric-orderer:latest                                                                                                                                     "orderer"                4 minutes ago        Up 4 minutes        7050/tcp, 0.0.0.0:9050->9050/tcp     orderer3.example.com
f79756c2a1cf        hyperledger/fabric-peer:latest                                                                                                                                        "peer node start"        4 minutes ago        Up 4 minutes        7051/tcp, 0.0.0.0:8051->8051/tcp     peer1.org1.example.com

大功告成!

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