本文介绍Ubuntu 18.04环境下如何配置Fabric开发环境。

安装Golang

因为Fabric是基于Go语言开发的,所以首先需要配置好Golang开发环境。

由于某些原因,国内无法从Golang官网上下载Golang,不过好在国内的Golang开发者们搭建的可供国内Golang爱好者分享的平台,可以从这里下载Golang的开发包。

下载完成后,执行如下操作:

$ sudo tar -zxvf ./go1.14.2.linux-amd64.tar.gz -C /usr/local
$ sudo echo "export GOPATH=$HOME/go" >> /etc/profile
$ sudo echo "export GOROOT=/usr/local/go" >> /etc/profile
$ sudo echo "export PATH=$GOPATH/bin:$GOROOT/bin:$PATH"
$ source /etc/profile

安装docker

在Fabric网络中,通过docker启动的话,可以简化很多设置,所以接下来我们来安装docker。这里使用阿里源,操作如下:

# 安装一些必要的系统工具
$ sudo apt update
$ sudo apt install -y git apt-transport-https ca-certificates curl software-properties-common
# 安装GPG证书
$ curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# 更新并安装docker-ce
$ sudo apt update -y
$ sudo apt install -y docker-ce docker-compose
$ sudo systemctl enable docker
$ sudo systemctl start docker
$ sudo usermod -aG docker $(whoami)

下载Fabric-samples

对于初学者,Fabric官方提供了可供初学者学习使用的Fabric-samples。该repo中提供了first-network,执行其中的byfn.sh脚本,可以确认fabric环境是否配置完成。

Fabric-samples提供了bootstrap.sh脚本,执行该脚本不仅可以完成Fabric-samples的下载,还能将fabric网络运行时需要的docker镜像下载完成,操作如下:

$ cd $GOPATH/src/github.com/hyperledger
$ curl -sS https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh -o bootstrap.sh
$ chmod +x bootstrap.sh
$ ./bootstrap.sh

默认情况下,bootstrap.sh会下载最新版本的fabric。当然也可以通过bootstrap.sh --help来查看更多选项。

bootstrap.sh执行完后,执行如下命令来查看环境是否搭建完成:

$ cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
$ ./byfn up

之后,脚本会自动创建一个fabric网络,创建一个chaincode以及执行简单的操作。最后,执行成功之后,会出现下面的内容:


......
===================== Invoke transaction successful on peer0.org1 peer0.org2 on channel 'mychannel' ===================== Installing chaincode on peer1.org2...
+ peer chaincode install -n mycc -v 1.0 -l golang -p github.com/chaincode/chaincode_example02/go/
+ res=0
+ set +x
2020-04-25 07:12:55.347 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 001 Using default escc
2020-04-25 07:12:55.347 UTC [chaincodeCmd] checkChaincodeCmdParams -> INFO 002 Using default vscc
2020-04-25 07:12:55.637 UTC [chaincodeCmd] install -> INFO 003 Installed remotely response:<status:200 payload:"OK" >
===================== 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网络,操作如下:

$ ./byfn down

本文采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。

Ubuntu18.04安装Fabric的更多相关文章

  1. Ubuntu18.04 安装 Fabric & 使用 Fabric 测试网络

    前言: 本文介绍在 Ubuntu 18.04 中安装 Fabric, 并对 官方文档中的一个小案例(Using the Fabric test network)进行测试. 目的: 初步了解 Fabri ...

  2. Ubuntu18.04安装mysql5.7

    Ubuntu18.04安装mysql5.7 1.1安装 首先执行下面三条命令: # 安装mysql服务 sudo apt-get install mysql-server # 安装客户端 sudo a ...

  3. Ubuntu18.04安装RabbitMQ

    Ubuntu18.04安装RabbitMQ 2018年06月10日 19:32:38 dmfrm 阅读数:2492    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog ...

  4. ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题(装)

    ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题      https://blog.csdn.net/NeptuneClouds/article/details/80995 ...

  5. ubuntu18.04 安装hadoop 2.7.3+hive 2.3.4

    1. 安装hadoop 详细请参见本人的另外一片博文<Hadoop 2.7.3 分布式集群安装> 2. 下载hive 2.3.4 解压文件到/opt/software -bin.tar.g ...

  6. Ubuntu18.04安装Virtualenv虚拟环境

    在Ubuntu18.04安装Virtualenv虚拟环境 [实验环境]: 在这台电脑上已经安装了python3 [安装参考] 1.查看是否已安装virtualenv virtualenv --vers ...

  7. Ubuntu18.04安装thunderbird并设置中文

    Ubuntu18.04安装thunderbird并设置中文 安装thunderbird sudo apt-get install thunderbird 安装中文包 sudo apt-get inst ...

  8. Ubuntu18.04安装Docker, centos7安装Docker

    Ubuntu18.04安装Docker 第一种方法从Ubuntu的仓库直接下载安装: 安装比较简单,这种安装的Docker不是最新版本,不过对于学习够用了,依次执行下面命令进行安装. $ sudo a ...

  9. Ubuntu18.04安装和配置Java JDK11并卸载自带OpenJDK

    卸载自带的OpenJDK方法: 在终端执行命令:sudo apt-get remove openjdk* Ubuntu18.04安装JDK11.0.2 前面步骤一样,可参考:https://www.c ...

随机推荐

  1. Maven--Maven 安装最佳实践

    1.设置 MAVEN_OPTS 环境变量 运行 mvn 命令实际上是执行了 Java 命令,既然是运行 Java,那么运行 Java 命令可用的参数当然也应该在运行 mvn 命令时使用.这个时候,MA ...

  2. 两个tomcat使用同一个jvm可能会出错

    如果两个tomcat中的项目的某些类具有完全相同的包路径和类名的话,jvm可能会“弄混”这两个类,所以一般要求包名“必须”唯一. 当然,如果两个类中的代码和import的类完全一样,弄混了也就弄混了, ...

  3. docker可视化工具

    介绍两款Docker可视化工具 DockerUI(特点:轻量) 下载镜像 docker pull abh1nav/dockerui 启动容器 docker run -d --privileged -- ...

  4. numpy 加速 以及 ipython

    先安装openblas, 然后用pip 安装numpy sudo ln -s /usr/lib64/libopenblas-r0.2.14.so /usr/lib64/libopenblas.so 为 ...

  5. bat脚本修改dns(判断系统版本)

    @echo off systeminfo if "%OS 名称%"=="%7%" goto windows7:windows7echo 正在设置本机主DNS , ...

  6. 吴裕雄--天生自然python学习笔记:python 文件批量查找

    在多个文本文件中查找 我们首先来学习文本文件的查找字符 . 我们通过 os.walk 扩大查找范围, 查找指定目录和子目录下的文件. 应用程序总览 读取 当 前目录及子目录下的所有 PY 和 txt ...

  7. mysql 子查询不支持limit

    mysql执行如下语句 : SELECT * FROM `xxx_base_info` where yn =1 and xxx_keeper_id in (SELECT id FROM `user`w ...

  8. gene cluster|DPG|拉马克主义变异|达尔文主义变异

    生命组学 A gene cluster is part of a gene family. A gene cluster is a group of two or more genes found w ...

  9. qsub|pasta|

    cd /xxx/genome_stat/Annotation ln -s /xxx/02.annotation/gff_v2/*.homolog.v2.gff /xxx/genome_stat/Ann ...

  10. Div水平垂直居中的三种方法

    百度了很多种方法,很多是不起作用的.下面这些方法是我亲自试过的.希望对大家有帮助! 下面是一波代码水军. <!DOCTYPE html> <html lang="en&qu ...