Ubuntu上安装部署Fabric1.4(炒鸡详细)

安装虚拟机和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的版本搞到了本地,我们可以在此基础上修改和使用。

参考:老师的fabric视频 and

https://yongshengcao.blog.csdn.net/article/details/124291080

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值