安装虚拟机和Ubuntu
参考以往博客
安装预备工具(以/opt目录为例)
安装vim:
sudo apt-get install vim
安装git:
sudo apt-get install git
安装CURL:
sudo apt-get install curl
安装wget:
sudo apt-get install wget
安装docker:
sudo apt-get -y install docker
安装docker-compose:
sudo apt-get -y install docker-compose
检查docker和docker-compose是否安装成功:
$ docker --version
$ docker-compose --version
安装Go:
wget https://studygolang.com/dl/golang/go1.11.linux-amd64.tar.gz
tar xzvf go1.11.linux-amd64.tar.gz -C /usr/local
配置环境变量:
新建goenvset.sh文件添加如下内容:
cat >> /etc/profile << EOF
export GOROOT=/usr/local/go
export GOARCH=amd64
export GOOS=linux
export GOPATH=/home/ubuntu/gopath
export GOBIN=$GOPATH/bin
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
EOF
执行操作:
# 执行已有的goenvset.sh向/etc/profile中写入相应的环境变量
sudo chmod 705 goenvset.sh # 更改goenvset.sh的权限使其可执行
sudo ./goenvset.sh # 执行goenvset.sh脚本
# 使环境变量生效
source /etc/profile
安装Fabric
1、将fabric-samples下载到$GOPATH/src/github.com/hyperledger
目录中
mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
# 克隆fabric-samples项目并切换到v1.4tag
git clone https://github.com/hyperledger/fabric-samples.git
cd fabric-samples
git checkout -b sample v1.4.0
2.安装Fabric、Fabric-ca以及第三方Docker镜像
cd $GOPATH/src/github.com/hyperledger/fabric-samples/scripts
# 安装Fabric、Fabric-ca以及第三方Docker镜像(./bootstrap.sh <fabric> <fabric-ca> <thirdparty>)
./bootstrap.sh 1.4.0 1.4.0 0.4.14
#若上个命令失败则手动安装
#将指定版本的Hyperledger Fabric特定于平台的二进制文件和配置文件安装到fabric-samples的bin和config目录中
wget https://github.com/hyperledger/fabric/releases/download/v1.4.0/hyperledger-fabric-linux-amd64-1.4.0.tar.gz
wget https://github.com/hyperledger/fabric-ca/releases/download/v1.4.0/hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz
tar xzvf hyperledger-fabric-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
tar xzvf hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz -C $GOPATH/src/github.com/hyperledger/fabric-samples/
#向/etc/profile中写入环境变量
sudo echo 'export PATH=$GOPATH/src/github.com/hyperledger/fabric-samples/bin:$PATH' >> /etc/profile
#使环境变量生效
source /etc/profile
下载Docker镜像:
# 下载Fabric相关镜像(fabric-peer、fabric-orderer、fabric-ccenv、fabric-tools),此处以fabric-peer镜像为例,其他镜像同理
docker pull hyperledger/fabric-peer:1.4.0
docker tag hyperledger/fabric-peer:1.4.0 hyperledger/fabric-peer:latest
docker pull hyperledger/fabric-orderer:1.4.0
docker tag hyperledger/fabric-orderer:1.4.0 hyperledger/fabric-orderer:latest
docker pull hyperledger/fabric-ccenv:1.4.0
docker tag hyperledger/fabric-ccenv:1.4.0 hyperledger/fabric-ccenv:latest
docker pull hyperledger/fabric-tools:1.4.0
docker tag hyperledger/fabric-tools:1.4.0 hyperledger/fabric-tools:latest
# 下载Fabric第三方镜像(fabric-couchdb、fabric-kafka、fabric-zookeeper),此处以fabric-couchdb为例,其他镜像同理
docker pull hyperledger/fabric-couchdb:0.4.14
docker tag hyperledger/fabric-couchdb:0.4.14 hyperledger/fabric-couchdb:latest
docker pull hyperledger/fabric-kafka:0.4.14
docker tag hyperledger/fabric-kafka:0.4.14 hyperledger/fabric-kafka:latest
docker pull hyperledger/fabric-zookeeper:0.4.14
docker tag hyperledger/fabric-zookeeper:0.4.14 hyperledger/fabric-zookeeper:latest
# 下载Fabric CA镜像
docker pull hyperledger/fabric-ca:1.4.0
docker tag hyperledger/fabric-ca:1.4.0 hyperledger/fabric-ca:latest
3.通过运行Build your first network
样例来进行测试
cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
# 编译通过Golang开发的chaincode并启动相关的容器
./byfn.sh up
报错解决:
Error: error getting endorser client for channel: endorser client failed to connect to peer0.org1.example.com:7051: failed to create new connection: context deadline exceeded !!!!!!!!!!!!!!! After 10 attempts, peer0.org1 has failed to join channel 'mychanel'
解决:https://blog.csdn.net/djklsajdklsajdlk/article/details/125588854
./byfn.sh up -l node
#以kafka启动
./byfn.sh up -o kafka
#停止first-network网络中所有的容器,删除crypto材料和4个artifacts(genesis.block、mychannel.block、Org1MSPanchor.tx、Org2MSPanchor.tx)以及chaincode镜像
./byfn.sh down
这样就把官方fabric1.4的版本搞到了本地,我们可以在此基础上修改和使用。文章来源:https://www.toymoban.com/news/detail-516978.html
参考:老师的fabric视频 and文章来源地址https://www.toymoban.com/news/detail-516978.html
https://yongshengcao.blog.csdn.net/article/details/124291080
到了这里,关于Ubuntu上安装部署Fabric1.4(炒鸡详细)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!