Fabric学习--环境搭建

本文详细记录了在CentOS8虚拟机中搭建Hyperledger Fabric区块链环境的全过程,包括环境准备、安装wget、Go语言、Docker及其相关组件,以及遇到的错误和解决方案。在安装过程中,重点介绍了Go环境配置、Docker的yum源设置、依赖包安装和防火墙问题的处理。
摘要由CSDN通过智能技术生成

前言:这是本人学习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/

可以看见有:

接下来就执行命令:

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秒。
依赖关系解决。
===================================================================================
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值