工具: VMware 14 PRO + Centos 7

1、Fabric所需的工具:

   Docker-ce;

   Docker-compose;

   nodejs(gcc编辑器)

2、Docker-ce安装:

(1)安装所需要的依赖包

[[email protected] ~]# yum install -y yum-utils device-mapper-persistent-data

(2)配置稳定的仓库

[[email protected] ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

(3)安装指定版本的docker-ce

[[email protected] ~]# yum list docker-ce --showduplicates | sort -r

VMware + Centos 7下安装Hyperledger Fabric

[[email protected] ~]# yum install docker-ce-17.12.1.ce-1.el7.centos.x86_64

VMware + Centos 7下安装Hyperledger Fabric

(4)启动docker以及开机自启动

[[email protected] ~]# systemctl start docker

[[email protected] ~]# systemctl enable docker

(5)查看docker版本

[[email protected] ~]# docker version

VMware + Centos 7下安装Hyperledger Fabric

3、docker-compose安装

(1)首先检查是否安装python-pip

[[email protected] ~]# pip -v

(2)执行

[[email protected] ~]# yum -y install epel-release

(3)[[email protected] ~]# yum -y install python-pip

VMware + Centos 7下安装Hyperledger Fabric

(4)对安装的pip进行升级

[[email protected] ~]#  pip install --upgrade pip

(5)检查pip安装

[[email protected] ~]# pip -V

(6)安装docker-compose

[[email protected] ~]# pip install docker-compose

(7)遇到的问题:

VMware + Centos 7下安装Hyperledger Fabric

    1、安装jinja2

     下载jinja2

     wget https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz

    解压

   [[email protected] ~]# tar xvf Jinja2-2.7.3.tar.gz

    安装

    [[email protected] Jinja2-2.7.3]# python setup.py install

VMware + Centos 7下安装Hyperledger Fabric

   2 安装pyudev

     安装git    [[email protected] ~]# sudo yum install git

    下载pyudev   [[email protected] ~]# git clone https://github.com/lunaryorn/pyudev.git

    进入 pyudev文件夹  [[email protected] ~]# cd pyudev

    安装  [[email protected] pyudev]# python setup.py install

   3 安装dnspython 

   下载dnspython [[email protected]~]# wget http://www.dnspython.org/kits/1.15.0/dnspython-1.15.0.tar.gz  

   解压  [[email protected] ~]# tar -zxvf dnspython-1.15.0.tar.gz 

   进入  [[email protected] ~]# cd dnspython-1.15.0

   安装 [[email protected] dnspython-1.9.4]# python setup.py install 

   4 运行 [[email protected] dnspython-1.15.0]#  pip install --ignore-installed requests

             [[email protected] ~]# pip install docker-compose

   5 查看docker-compose版本  [[email protected] ~]# docker-compose version

4、安装go语言

(1)使用yum工具安装  [[email protected] ~]# yum install golang -y

(2)打开  etc/profile   [[email protected] ~]# vim /etc/profile

添加:export GOROOT=/usr/lib/golangexport GOPATH=/home

4)保存配置 [[email protected] ~]# source /etc/profile

(5)查看go环境 [[email protected] ~]# go env

VMware + Centos 7下安装Hyperledger Fabric

5、安装node.js

(1)下载nodejs [[email protected] ~]# wget https://npm.taobao.org/mirrors/node/v9.9.0/node-v9.9.0.tar.gz

(2)解压 [[email protected] ~]#  tar -C /usr/local -xzf node-v9.9.0.tar.gz

(3)安装编译软件 [[email protected] ~]# yum install gcc gcc-c++

(4)查看编译软件版本 [[email protected] ~]# gcc -v

VMware + Centos 7下安装Hyperledger Fabric

(5)4.8.5版本过低,若已为最新版请跳过至步骤,升级gcc,前往http://ftp.gnu.org/gnu/gcc/下载你想要的版本

(6)下载新版本[[email protected] ~]# wget http://ftp.gnu.org/gnu/gcc/gcc-8.1.0/gcc-8.1.0.tar.gz

(7)解压 [[email protected] ~]#  tar -C /usr/local -xzf gcc-8.1.0.tar.gz

(8)[[email protected] ~]# cd /usr/local/gcc-8.1.0

(9)[[email protected] gcc-8.1.0]#  ./contrib/download_prerequisites 

VMware + Centos 7下安装Hyperledger Fabric

(10) [[email protected] gcc-8.1.0]# mkdir build && [[email protected] gcc-8.1.0]# cd build

(11)[[email protected] build]#  ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib  

(12)[[email protected] build]#  yum groupinstall "Development Tools"

(13)[[email protected] build]# make

(14)[[email protected] build]# make install

(15)重启系统

(16)查看gcc的版本 [[email protected] /]# gcc -v

VMware + Centos 7下安装Hyperledger Fabric

(17)[[email protected] /]# cd /usr/local/node-v9.9.0/ 进入node安装的目录

(18)[[email protected] node-v9.9.0]# ./configure

(19)[[email protected] node-v9.9.0]# make

这是可能会遇到一个问题:

/usr/local/node-v9.9.0/out/Release/mksnapshot: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/node-v9.9.0/out/Release/mksnapshot)

/usr/local/node-v9.9.0/out/Release/mksnapshot: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/node-v9.9.0/out/Release/mksnapshot)

(20)运行下面的命令,查找最新安装的gcc动态库:

[[email protected] node-v9.9.0]# find / -name "libstdc++.so*"

VMware + Centos 7下安装Hyperledger Fabric

(21)[[email protected] node-v9.9.0]# cp /usr/local/gcc-8.1.0/build/stage1-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.25 /usr/lib64

(22)[[email protected] node-v9.9.0]# cd /usr/lib64

(23)[[email protected] lib64]# rm -rf libstdc++.so.6

(24)[[email protected] lib64]# ln -s libstdc++.so.6.0.25 libstdc++.so.6

(25)[[email protected] lib64]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC

VMware + Centos 7下安装Hyperledger Fabric

(26)[[email protected] /]# cd /usr/local/node-v9.9.0/

(27)[[email protected] node-v9.9.0]# make

(28)[[email protected] node-v9.9.0]# make install

(29)[[email protected] node-v9.9.0]# node -v

6、安装npm

(1)[[email protected] node-v9.9.0]#  npm install npm -g

VMware + Centos 7下安装Hyperledger Fabric

(2)[[email protected] /]# npm -v

7、下载fabric源码

(1)[[email protected] /]# mkdir -p $GOPATH/src/github.com/hyperledger

(2)[[email protected] /]# cd $GOPATH/src/github.com/hyperledger

(3)[[email protected] hyperledger]# git clone https://github.com/hyperledger/fabric.git

如果连接不到网站运行

[[email protected] hyperledger]# systemctl stop firewalld

(4)[[email protected] hyperledger]# cd fabric

(5)[[email protected] fabric]# git checkout v1.0.0

(6)[[email protected] fabric]# cd examples

(7)[[email protected] examples]# cd e2e_cli

(8)[[email protected] e2e_cli]#  source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0

(9)[[email protected] e2e_cli]# docker images

VMware + Centos 7下安装Hyperledger Fabric

(10)开启fabric客户端

[[email protected] e2e_cli]# ./network_setup.sh up

如果出现以下问题

Creating network "e2e_cli_default" with the default driver

ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule:  (iptables failed: iptables --wait -t nat -I DOCKER -i br-fd4ac061fe5d -j RETURN: iptables: No chain/target/match by that name.

需要重开docker服务

[[email protected] e2e_cli]# ./network_setup.sh down

[[email protected] e2e_cli]#systemctl restart docker

[[email protected] e2e_cli]# ./network_setup.sh up

如果之后遇到

Error: Error endorsing chaincode: rpc error: code = Unknown desc = Error starting container: API error (404): {"message":"network e2ecli_default not found"}
[[email protected] e2e_cli]# cd base

[[email protected] base]# vim peer-base.yaml

修改:- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=e2e_cli_default

[[email protected] e2e_cli]# ./network_setup.sh down

[[email protected] e2e_cli]# ./network_setup.sh up

VMware + Centos 7下安装Hyperledger Fabric


相关文章: