Ubuntu18.04安装Fabric
本文介绍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的更多相关文章
- Ubuntu18.04 安装 Fabric & 使用 Fabric 测试网络
前言: 本文介绍在 Ubuntu 18.04 中安装 Fabric, 并对 官方文档中的一个小案例(Using the Fabric test network)进行测试. 目的: 初步了解 Fabri ...
- Ubuntu18.04安装mysql5.7
Ubuntu18.04安装mysql5.7 1.1安装 首先执行下面三条命令: # 安装mysql服务 sudo apt-get install mysql-server # 安装客户端 sudo a ...
- Ubuntu18.04安装RabbitMQ
Ubuntu18.04安装RabbitMQ 2018年06月10日 19:32:38 dmfrm 阅读数:2492 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog ...
- ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题(装)
ubuntu18.04 安装mysql不出现设置 root 帐户的密码问题 https://blog.csdn.net/NeptuneClouds/article/details/80995 ...
- 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 ...
- Ubuntu18.04安装Virtualenv虚拟环境
在Ubuntu18.04安装Virtualenv虚拟环境 [实验环境]: 在这台电脑上已经安装了python3 [安装参考] 1.查看是否已安装virtualenv virtualenv --vers ...
- Ubuntu18.04安装thunderbird并设置中文
Ubuntu18.04安装thunderbird并设置中文 安装thunderbird sudo apt-get install thunderbird 安装中文包 sudo apt-get inst ...
- Ubuntu18.04安装Docker, centos7安装Docker
Ubuntu18.04安装Docker 第一种方法从Ubuntu的仓库直接下载安装: 安装比较简单,这种安装的Docker不是最新版本,不过对于学习够用了,依次执行下面命令进行安装. $ sudo a ...
- Ubuntu18.04安装和配置Java JDK11并卸载自带OpenJDK
卸载自带的OpenJDK方法: 在终端执行命令:sudo apt-get remove openjdk* Ubuntu18.04安装JDK11.0.2 前面步骤一样,可参考:https://www.c ...
随机推荐
- 关于本人:-D(必读)
关于本人 本人目前从事iOS开发,但心中也有一个全栈的梦想,希望与大家共勉! 关于博客内容 自己会不时分享一些iOS方面的技术点.总结的一些经验及工具类.还有学习其他语言过程中的笔记.技术.总结及心得 ...
- 追踪tracking
追踪 追踪部分的主要思路是在当前帧和(局部)地图之间寻找尽可能多的对应关系,来优化当前帧的位姿. 作者在追踪这部分主要用了几种模型:运动模型(Tracking with motion model).关 ...
- idea远程调试tomcat部署项目(windows环境)
1.tomcat启动之前,修改apache-tomcat-8.5.34\bin\catalina.bat文件,设置调试端口 如下设置(windows环境): rem ----------------- ...
- 一个帖子csrf的例子
服务端 <?php $conn=mysqli_connect('localhost','root','root','csrf'); $data=$_POST; $user=$_POST['use ...
- PAT甲级——1152.Google Recruitment (20分)
1152 Google Recruitment (20分) In July 2004, Google posted on a giant billboard along Highway 101 in ...
- Java中Arrays详解
一.Arrays类的定义 Arrays类位于 java.util 包中,主要包含了操纵数组的各种方法 使用时导包:import java.util.Arrays 二.Arrays常用函数(都是静态的) ...
- centos7_安装jira7
centos7 安装jira7 参考文档:http://www.cnblogs.com/kevingrace/p/7608813.html 1.准备环境 centos7 memory:8G stora ...
- 吴裕雄--天生自然python学习笔记:python 用 Open CV通过人脸识别进行登录
人脸识别登录功能的基本原理是通过对比两张图片的差异度来判断两张图片是 否是同 一人的面部 . 对比图片 差异度 的算法有很多种,本例中使用“颜色直方图” 算法来实现对人脸图像的识别. 下面为比较 im ...
- vue实现动态绑定class--多个按钮点击一个有一个
<template> //v-for循环出来多个按钮,便于获取index <span v-for="(item,index) in list" : ...
- [flask]Restful接口测试简单的应用
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : shenqiang from flask import Flask,make_res ...