fabric环境搭建一直是困扰开发人员很苦恼的问题,不同的版本、不同的电脑出现的问题也各不一样,希望这篇文章能给你一些帮助。
一、Ubuntu的安装(Ubuntu16.04版本)
这里不做详细介绍,推荐两篇博客
参考博客:https://www.cnblogs.com/ddbear/p/7736912.html
简易安装:https://blog.csdn.net/weixin_34248487/article/details/94470617
二、更换Ubuntu的下载源
先备份原来的源文件
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
这里的文件名也可能是source.list(根据自己的情况)
打开source.list文件,删除原来的内容
$ sudo vim /etc/apt/source.list
替换成一下下载源任意一个都行
下载源:
易源
deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
阿里源
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
复制进去后,使用:wq保存,然后使用如下命令更新一下
$ sudo apt-get update
三、安装工具,方便后续的安装
安装 git、curl、pip
sudo apt-get install git
sudo apt-get install curl
sudo apt-get install python-pip
pip install --upgrade pip
四、安装go
推荐这篇博客,很详细
https://blog.csdn.net/Sun_Hui_/article/details/100578467
五、
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs
安装完成后,能使用 node -v 命令查看版本号,则说明安装成功。由于 node.js 自带了 npm,只需安装 nodejs 就行,不放心的可以 npm -v 验证一下。
六、升级gcc
用 gcc -v 看一下,如果版本是 5.4.0 的,应该是不影响的,可以不用升级,我就是 5.4.0 的版本。低于 5.4.0 的可以自行搜索升级方法,这里就不再列出
七、安装docker
推荐博客
https://blog.csdn.net/Sun_Hui_/article/details/100581161
八、
pip install docker-compose
验证是否安装成功
docker-compose --version
九、
1.创建并进入 hyperledger 目录 :
mkdir -p $GOPATH/src/github.com/hyperledger
cd $GOPATH/src/github.com/hyperledger
2.下载 fabric 源码
git clone https://github.com/hyperledger/fabric.git
3.将 fabric 切换至 1.0.0 版本:(可以是你想要的版本)
由于Fabric一直在更新,而我们并不需要使用最新的源码,所有将版本切换到v1.0.0
cd $GOPATH/src/github.com/hyperledger/fabric
git checkout v1.0.0
4.####下载Fabric Docker镜像
由于刚才设置了Docker Hub镜像的地址,并且官方文件中也提供了批量下载的脚本,所有我们只需运行下面命令即可
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/
source download-dockerimages.sh -c x86_64-1.0.0 -f x86_64-1.0.0
由于刚才设置的是国内的镜像站,在本地网速还不错的情况下下载数度还是很快的。当下载完成后,使用如下命令检查镜像列表
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hyperledger/fabric-tools latest 0403fd1c72c7 10 months ago 1.32GB
hyperledger/fabric-tools x86_64-1.0.0 0403fd1c72c7 10 months ago 1.32GB
hyperledger/fabric-couchdb latest 2fbdbf3ab945 10 months ago 1.48GB
hyperledger/fabric-couchdb x86_64-1.0.0 2fbdbf3ab945 10 months ago 1.48GB
hyperledger/fabric-kafka latest dbd3f94de4b5 10 months ago 1.3GB
hyperledger/fabric-kafka x86_64-1.0.0 dbd3f94de4b5 10 months ago 1.3GB
hyperledger/fabric-zookeeper latest e545dbf1c6af 10 months ago 1.31GB
hyperledger/fabric-zookeeper x86_64-1.0.0 e545dbf1c6af 10 months ago 1.31GB
hyperledger/fabric-orderer latest e317ca5638ba 10 months ago 179MB
hyperledger/fabric-orderer x86_64-1.0.0 e317ca5638ba 10 months ago 179MB
hyperledger/fabric-peer latest 6830dcd7b9b5 10 months ago 182MB
hyperledger/fabric-peer x86_64-1.0.0 6830dcd7b9b5 10 months ago 182MB
hyperledger/fabric-Javaenv latest 8948126f0935 10 months ago 1.42GB
hyperledger/fabric-javaenv x86_64-1.0.0 8948126f0935 10 months ago 1.42GB
hyperledger/fabric-ccenv latest 7182c260a5ca 10 months ago 1.29GB
hyperledger/fabric-ccenv x86_64-1.0.0 7182c260a5ca 10 months ago 1.29GB
hyperledger/fabric-ca latest a15c59ecda5b 10 months ago 238MB
hyperledger/fabric-ca x86_64-1.0.0 a15c59ecda5b 10 months ago 238MB
hyperledger/fabric-baseos x86_64-0.3.1 4b0cab202084 12 months ago 157MB
出现以上结果说明镜像已经下载成功
十、
进入e2e_cli目录,并执行启动命令
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/
./network_setup.sh up
如果最后出现`END-E2E`,那么说明安装成功,当然可能会出现一些问题
十一、常见的启动问题(v1.0参考)
参考文档:https://blog.csdn.net/Anderson_REN/article/details/80633314
十二、
###当使用 ./network_setup.sh down 可能遇到以下问题
1.org2.example.com/tls/server.crt': Permission denied
rm: cannot remove 'cryptoconfig/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/tls/server.key': Permission denied
这是因为权限不够导致不能完全关闭节点,加sudo就可以解决了
十三、fabric环境搭建其他参考文章: