网上有个2.0的部署教程,要先下载代码再通过make all 编译生成二进制文件,但并没有错,但这种编译方式我执行了一天一夜还没执行完,只能放弃,重新研究官方手册(https://hyperledger-fabric.readthedocs.io/zh_CN/latest/install.html),发现官方的方法其实不需要编译,人家已经编译好,我们只需要下载就好。
最简单的方式就是直接执行下面的命令就好
curl -sSL https://bit.ly/2ysbOFE | bash -s
它其实是下载一个bash文件并开始执行它,而这个bash文件实现自动下载 hyperledger/fabric-samples 仓库,fabric和fabric-ca二进制文件(就是上面make all要生成的文件)
但我的服务器直接执行会报下面的错误,手册说是curl版本的问题,但我确认我的版本已经是centos7下最新的版本了的
还好官网手册有说到这个问题并给出解决方案
就是通过在浏览器中打开未缩写的 URL下载bootstrap.sh
https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh
悲剧的是我连这个地址都打不开,好在多试几次终于下载回来了,执行的时候发现它下载的速度也非常感人:需要15天12个小时啊~~~(也可能是我没用梯子的原因)
无奈只能先提前下载(我是在服务器上通过nohup wget 的方式下载了一个晚上下回来的)
https://github.com/hyperledger/fabric/releases/download/v2.0.0/hyperledger-fabric-linux-amd64-2.0.0.tar.gz
https://github.com/hyperledger/fabric-ca/releases/download/v1.4.6/hyperledger-fabric-ca-linux-amd64-1.4.6.tar.gz
然后打开bootstrap.sh ,把download方法
把上面下载回来的两个文件放到bootsrap.sh相同的目录下,然后解压得到bin和config两个目录
- tar -xzvf hyperledger-fabric-linux-amd64-2.0.0.tar.gz
- tar -xzvf hyperledger-fabric-ca-linux-amd64-1.4.6.tar.gz
然后打开bootstrap.sh ,把download方法
This will download the .tar.gz
download() {
local BINARY_FILE=$1
local URL=$2
echo "===> Downloading: " "${URL}"
curl -L --retry 5 --retry-delay 3 "${URL}" | tar xz || rc=$?
if [ -n "$rc" ]; then
echo "==> There was an error downloading the binary file."
return 22
else
echo "==> Done."
fi
}
修改为
This will download the .tar.gz
download() { echo "==> Done." }
然后执行它
./bootstrap.sh
接着又是一个漫长的安装过程,不过由于之前配置了国内的镜像,因此里面涉及到的一些下载速度还是蛮快的
安装完成后
重要:把上面bin和config目录复制到fabric-samples下,否则下一章节启动网址时会提示这个
-
[root@192 test-network]# ./network.sh up
-
Starting nodes with CLI timeout of '5' tries and CLI delay of '3' seconds and using database 'leveldb' with crypto from 'cryptogen'
-
ERROR! Peer binary and configuration files not found..
-
Follow the instructions in the Fabric docs to install the Fabric Binaries:
-
https://hyperledger-fabric.readthedocs.io/en/latest/install.html
最后把里面的bin目录放到PATH环境变量vi /etc/profile
最后增加一行,/root/test 是我的测试目录,这里要换成你自己的export PATH=/root/test/fabric-samples/bin:$PATH
保存,退出,运行使其生效source /etc/profile
测试echo $PATH
本文由小韦云原创,转载请注明出处:https://www.bctos.cn/doc/5/1811,否则追究其法律责任