Fabric v1.4.0 installation and deployment
First, preparation
Numbering | tool | version number |
---|---|---|
1 | cURL | The latest version (7.63.0) |
2 | Docker | 17.06.2-ce and above |
3 | Docker Compose | 1.14.0 and above |
4 | Go | 1.11.x |
-
cURL install the latest version
The default curl does not support https, you need to configure curl https protocol
Installation openssl:
wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz sudo tar -zxvpf openssl-1.1.0g.tar.gz cd openssl-1.1.0g ./config #默认安装路径/usr/local/ssl make sudo make install #创建软连接 sudo ln -s /usr/local/lib/libssl.so.1.1 /usr/lib/libssl.so.1.1 sudo ln -s /usr/local/lib/libcrypto.so.1.1 /usr/lib/libcrypto.so.1.1 #查看版本 openssl version
# 下载最新版的cURL并将其解压到指定目录(此处以/opt目录为例) wget https://curl.haxx.se/download/curl-7.63.0.tar.gz # 下一步:::: sudo tar xzvf curl-7.63.0.tar.gz -C /opt # 编译并安装cURL cd /opt/curl-7.63.0 ./configure -with-ssh=/usr/local/ssl make sudo make install
By running
curl --version
to see if the installation was successful, if the node is displayed curl version, the installation was successful.If you do not find the curl command, you need to follow the steps below.
# 在/etc/ld.so.conf加入/usr/local/lib这一行内容 sudo echo "/usr/local/lib" >> /etc/ld.so.conf # 执行下列命令使加入的内容生效 sudo /sbin/ldconfig -v
-
Docker Docker Compose and installation
-
Docker (refer to the Get docker the CE for the Ubuntu )
to begin the installationSince docker official version apt repository may be older, so uninstall the old version may exist:
sudo apt-get remove docker docker-engine docker-ce docker.io
Update apt Package Index:
sudo apt-get update
Install the package to allow the use of apt repository via HTTPS:
sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
The official added Docker GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Use the following command to set the stable repository:
sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
And then update the look apt Package Index:
sudo apt-get update
Install the latest version of Docker CE:
sudo apt-get install -y docker-ce
Verify docker, see docker service is started:
systemctl status docker
If not started, start the docker services:
sudo systemctl start docker
The classic hello world:
sudo docker run hello-world
-
Docker Compose
# 下载Docker Compose二进制文件 # !下载特别慢 后来下载速度为0 sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose # 备用:curl -L https://get.daocloud.io/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
-
-
Go installation
# 下载go1.11.linux-amd64.tar.gz并将其解压到指定目录(此处为/usr/local) wget https://studygolang.com/dl/golang/go1.11.linux-amd64.tar.gz tar xzvf go1.11.linux-amd64.tar.gz -C /usr/local # 创建$GOPATH mkdir /home/ubuntu mkdir /home/ubuntu/gopath # 编辑goenvset.sh文件 vim 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中写入相应的环境变量 # 更改goenvset.sh的权限使其可执行 sudo chmod 705 goenvset.sh # 执行goenvset.sh脚本 sudo ./goenvset.sh # 使环境变量生效 source /etc/profile
Two, Fabric-line installation
-
The fabric-samples downloaded to
$GOPATH/src/github.com/hyperledger
directorymkdir -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
-
Fabric Fabric Binaries installation and related Docker image
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
It is noteworthy that, if due to network problems, through here
bootstrap.sh
may be wrong installation script, then you can install it manually. Installation steps are as follows:-
The specific version of a specific installation Hyperledger Fabric to fabric-samples of the bin and the config directory platform binaries and configuration files
#! 这一步失败 原因为网络 但是使用后面的wget也同样无法下载 所以从百度网盘下载后再传到ubuntu # 两个文件的压缩文件下载链接:https://download.csdn.net/download/qq_36254699/12154763 wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/linux-amd64-1.4.0/hyperledger-fabric-linux-amd64-1.4.0.tar.gz wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/linux-amd64-1.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
-
Download Docker image
# 下载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
-
(Optional) backup and recovery of mirroring
# 将上述Docker镜像存储到fabric-images文件中 docker save $(docker images | grep fabric | grep latest | awk '{print $1}') -o fabric-images # 若需要多机部署,则通过下列命令将其分发到其他机器 scp fabric-images [email protected]:~ # 在192.168.70.21上加载上述镜像 docker load -o fabric-images
-
-
By running
Build your first network
to test the sample,cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network # 编译通过Golang开发的chaincode并启动相关的容器 ./byfn.sh up ./byfn.sh up -l node ./byfn.sh up -o kafka #停止first-network网络中所有的容器,删除crypto材料和4个artifacts(genesis.block、mychannel.block、Org1MSPanchor.tx、Org2MSPanchor.tx)以及chaincode镜像 ./byfn.sh down
supplement:
# 华为云Ubuntu16.4在执行up遇到的问题: Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: context deadline exceeded # 解决办法: vim /etc/resolv.conf # 将options那一行注释掉就好了
-
The download of the fabric related installation files (including
fabric-samples
,hyperledger-fabric-linux-amd64-1.4.0.tar.gz
,hyperledger-fabric-ca-linux-amd64-1.4.0.tar.gz
andfabric-images
) together in one folder and compress generationfabric-offline-install.tar.gz
Three, Fabric offline installation
This section describes how to Fabric install mentioned section fabric-offline-install.tar.gz
to install offline Fabric.
tar xzvf fabric-offline-install.tar.gz
unzip xzvf fabric-offline-install.tar.gz
cd fabric-offline-install
cp -rf fabric-samples $GOPATH/src/github.com/hyperledger
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/
sudo echo 'export PATH=$GOPATH/src/github.com/hyperledger/fabric-samples/bin:$PATH' >> /etc/profile
source /etc/profile
docker load -i fabric-images
Reference material
Use couchdb database
cd $GOPATH/src/github.com/hyperledger/fabric-samples/first-network
./byfn.sh up -s couchdb
./byfn.sh -m down
Intelligent contract block data structure analysis
Into the docker container:
docker exec -it cli bash
View block information
peer channel getinfo -c mychannel