6

Hyperledger Fabric环境搭建 - idealclover

 2 years ago
source link: https://idealclover.top/archives/341/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Hyperledger Fabric 环境搭建

2018.07.11 | 零零碎碎 | 1839 浏览 | 0 赞 | 0 条评论


请注意,本文编写于 1230 天前,最后修改于 931 天前,其中某些信息可能已经过时。

系统环境:ubuntu18.04

安装 Go 语言环境

首先到 https://golang.google.cn/dl/ 下载安装包并解压

tar -xvf go1.10.linux-amd64.tar.gz sudo mv go /usr/local
apache

编辑环境变量:

vim ~/.profile
nginx

在环境变量中增加如下几行:

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

:wq 保存并退出,回到命令行状态即刻应用更改

source ~/.profile

在 Home 目录下创建 go 文件夹

mkdir go

安装 Docker

安装 Docker 的方法有多种,使用 apt-get 安装的版本较低。一些教程上的安装方法不适合国内环境

sudo apt-get update
csharp

添加使用 HTTPS 传输的软件包以及 CA 证书:

sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
csharp

添加软件源的 GPG 密钥(此处用中科大的源):

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
nginx

向 source.list 中添加 Docker 软件源:

sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \ $(lsb_release -cs) stable "

安装和启动 docker-ce:

sudo apt-get update sudo apt-get install docker-ce sudo systemctl enable docker sudo systemctl start docker

增加 docker 用户组:

sudo groupadd docker sudo usermod -aG docker $USER
nginx

安装 Docker-compose(需要安装好 pip 工具):

sudo pip install docker-compose
nginx

可以使用 docker version 命令查看版本

Tip:使用阿里云加速

拉取官方镜像时由于 docker 官网连接速度较慢,可以使用阿里云的镜像。

具体操作方法是到 https://cr.console.aliyun.com/#/accelerator 申请,需要阿里云账号(emmm... 淘宝账号...)

之后会看到如下图所示:

复制加速地址并执行以下命令:

$sudo mkdir -p /etc/docker $sudo tee /etc/docker/daemon.json <<-'EOF' "registry-mirrors": ["加速地址"] $sudo systemctl daemon-reload $sudo systemctl restart docker

Fabric 源码下载

需要安装 git 工具

mkdir -p ~/go/src/github.com/hyperledger cd ~/go/src/github.com/hyperledger git clone https://github.com/hyperledger/fabric.git
javascript

切换到 v1.0.0 版本:

cd ~/go/src/github.com/hyperledger/fabric git checkout v1.0.0
apache

拉取 Fabric Docker 镜像:

cd ~/go/src/github.com/hyperledger/fabric/examples/e2e_cli/ source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0
apache

启动示例网络:

./network_setup.sh up

当这个象征胜利的图案出现时:

恭喜我们跳入了这个巨坑!

如果没有... 看看下面的 bug fix 吧 qwq

Bug fix 1:

如果出现以下错误:

Error: Error endorsing chaincode: rpc error: code = Unknown dest = error starting container: API error (404): {"message": "network e2e2ecli_default not found"} Chaincode instanttiation on PEER2 on channel 'mychannel' failed

是由于相应配置文件的 bug 导致,需要做的修改是打开当前目录下 base/peer-base.yaml

vim base/peer-base.yaml
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=e2ecli_default
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=e2e_cli_default

Bug fix 2:

如果出现以下问题:

WARNING: Error loading config file: .../.docker/config.json: permission denied

权限问题... 第一次用 sudo su 跑起来吧,之后亲测非 sudo 也可以跑

Bug fix 3:

重启大法好...

./network_setup.sh down ./network_setup.sh up

本文链接:https://idealclover.top/archives/341/

本作品由 idealclover 采用 知识共享署名 - 非商业性使用 - 相同方式共享 4.0 国际许可协议 进行许可,转载请注明出处。

标签: tar, usr, 证书 , 文件 , install, docker, sudo, path


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK