hyperledger-fabric1.4

一. 通过脚本安装

1. 创建安装目录

1
mkdir -p /opt/gopath/src/github.com/hyperledger/ && cd /opt/gopath/src/github.com/hyperledger

2. 克隆fabric-sample项目

1
git clone -b v1.4.3 https://github.com/hyperledger/fabric-samples.git  && cd fabric-samples

3. 执行bootstrap脚本

1
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s -- 1.4.3 1.4.3 0.4.15

一般执行该命令会消耗较长时间,且可能出现下载失败,所以可以采取以下方式:

进入目录/opt/gopath/src/github.com/hyperledger,从github上拉取fabric源码

1
2
3
4
5
git clone https://gerrit.hyperledger.org/r/fabric.git
cd fabric
git checkout v1.4.3
make release
cd release/linux-amd64/bin

若bin文件夹中出现以下文件说明编译成功

1
2
[root@localhost bin]# ls
configtxgen configtxlator cryptogen discover idemixgen orderer peer

将生成文件添加进环境变量

1
2
vim /etc/profile
export PATH=$PATH:$GOPATH/src/github.com/hyperledger/fabric/release/linux-amd64/bin

wq保存退出,并更新

1
source /etc/profile

二、手动下载安装

1. 定义变量

1
2
3
4
5
6
7
8
9
10
11
12
13
VERSION=1.4.3
CA_VERSION=1.4.3
THIRDPARTY_IMAGE_VERSION=0.4.15

CA_TAG=$CA_VERSION
FABRIC_TAG=$VERSION
THIRDPARTY_TAG=$THIRDPARTY_IMAGE_VERSION

ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')")
MARCH=$(uname -m)

BINARY_FILE=hyperledger-fabric-${ARCH}-${VERSION}.tar.gz
CA_BINARY_FILE=hyperledger-fabric-ca-${ARCH}-${CA_VERSION}.tar.gz

2. 创建项目目录

1
mkdir -p /opt/gopath/src/github.com/hyperledger/ && cd /opt/gopath/src/github.com/hyperledger

3. 克隆fabric-sample,并切换到对应版本(可选)

1
git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples && git checkout v${VERSION}

4. 下载二进制可执行文件压缩包并解压

4.1 通过链接下载压缩包并解压(很慢,耗时过长,且容易出现下载失败)
1
2
3
curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/${BINARY_FILE} | tar xz

curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${CA_VERSION}/${CA_BINARY_FILE} | tar xz
4.2 通过源码编译生成(建议使用该方法)
1
2
3
4
5
6
7
git clone https://gerrit.hyperledger.org/r/fabric.git
cd fabric
git checkout release-1.4
make release
cd release/linux-amd64/bin
[root@localhost bin]# ls
configtxgen configtxlator cryptogen discover idemixgen orderer peer
1
2
3
4
5
6
7
git clone https://github.com/hyperledger/fabric-ca.git
cd fabric-ca
git checkout v1.4.3
make release
cd release/linux-amd64/bin
[root@localhost bin]# ls
fabric-ca-client

将生成文件移到同一个文件夹并添加进环境变量

1
2
3
mv fabric-ca-client /opt/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/
vim /etc/profile
export PATH=$PATH:$GOPATH/src/github.com/hyperledger/fabric/release/linux-amd64/bin

wq保存退出,并更新

1
source /etc/profile

5. 拉取镜像

5.1 拉取fabric镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
docker pull "hyperledger/fabric-peer:$FABRIC_TAG"
docker tag "hyperledger/fabric-peer:$FABRIC_TAG" "hyperledger/fabric-peer"

docker pull "hyperledger/fabric-orderer:$FABRIC_TAG"
docker tag "hyperledger/fabric-orderer:$FABRIC_TAG" "hyperledger/fabric-orderer"

docker pull "hyperledger/fabric-ccenv:$FABRIC_TAG"
docker tag "hyperledger/fabric-ccenv:$FABRIC_TAG" "hyperledger/fabric-ccenv"

docker pull "hyperledger/fabric-tools:$FABRIC_TAG"
docker tag "hyperledger/fabric-tools:$FABRIC_TAG" "hyperledger/fabric-tools"

docker pull "hyperledger/fabric-baseos:$FABRIC_TAG"
docker tag "hyperledger/fabric-baseos:$FABRIC_TAG" "hyperledger/fabric-baseos"

docker pull "hyperledger/fabric-nodeenv:$FABRIC_TAG"
docker tag "hyperledger/fabric-nodeenv:$FABRIC_TAG" "hyperledger/fabric-nodeenv"

docker pull "hyperledger/fabric-javaenv:$FABRIC_TAG"
docker tag "hyperledger/fabric-javaenv:$FABRIC_TAG" "hyperledger/fabric-javaenv"
5.2 拉取第三方镜像
1
2
3
4
5
6
7
8
docker pull "hyperledger/fabric-couchdb:$THIRDPARTY_TAG"
docker tag "hyperledger/fabric-couchdb:$THIRDPARTY_TAG" "hyperledger/fabric-couchdb"

docker pull "hyperledger/fabric-kafka:$THIRDPARTY_TAG"
docker tag "hyperledger/fabric-kafka:$THIRDPARTY_TAG" "hyperledger/fabric-kafka"

docker pull "hyperledger/fabric-zookeeper:$THIRDPARTY_TAG"
docker tag "hyperledger/fabric-zookeeper:$THIRDPARTY_TAG" "hyperledger/fabric-zookeeper"
5.3 拉取fabric-ca镜像
1
2
docker pull "hyperledger/fabric-ca:$CA_TAG"
docker tag "hyperledger/fabric-ca:$CA_TAG" "hyperledger/fabric-ca"

拉取结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-tools 1.4.3 18ed4db0cd57 7 weeks ago 1.55GB
hyperledger/fabric-tools latest 18ed4db0cd57 7 weeks ago 1.55GB
hyperledger/fabric-ca 1.4.3 c18a0d3cc958 7 weeks ago 253MB
hyperledger/fabric-ca latest c18a0d3cc958 7 weeks ago 253MB
hyperledger/fabric-ccenv 1.4.3 3d31661a812a 7 weeks ago 1.45GB
hyperledger/fabric-ccenv latest 3d31661a812a 7 weeks ago 1.45GB
hyperledger/fabric-orderer 1.4.3 b666a6ebbe09 7 weeks ago 173MB
hyperledger/fabric-orderer latest b666a6ebbe09 7 weeks ago 173MB
hyperledger/fabric-peer 1.4.3 fa87ccaed0ef 7 weeks ago 179MB
hyperledger/fabric-peer latest fa87ccaed0ef 7 weeks ago 179MB
hyperledger/fabric-zookeeper 0.4.15 20c6045930c8 7 months ago 1.43GB
hyperledger/fabric-zookeeper latest 20c6045930c8 7 months ago 1.43GB
hyperledger/fabric-kafka 0.4.15 b4ab82bbaf2f 7 months ago 1.44GB
hyperledger/fabric-kafka latest b4ab82bbaf2f 7 months ago 1.44GB
hyperledger/fabric-couchdb 0.4.15 8de128a55539 7 months ago 1.5GB
hyperledger/fabric-couchdb latest 8de128a55539 7 months ago 1.5GB

三、启动第一个fabric网络

1
2
cd /opt/gopath/src/github.com/hyperledger/fabric-sample/first-network
./byfn up

若最后输出以下内容,说明fabric网络启动成功

1
2
3
4
5
6
7
8
9
10
===================== Query successful on peer1.org2 on channel 'mychannel' ===================== 

========= All GOOD, BYFN execution completed ===========


_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/

关闭启动的fabric网络,同时删除链码镜像

1
./byfn down

最后更新: 2019年10月21日 17:25

原始链接: https://silence-linhl.github.io/blog/2019/10/21/fabric1-4-download/

× 请我吃糖~
打赏二维码