1、参考地址:https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html#install-curl
一、前置条件和系统配置
1、安装docker
http://www.cnblogs.com/bjlhx/p/7121875.html
2、系统配置
Node.js-v2.1.8 及更高版本
在Centos7 64位上安装node.js
yum install npm
查看npm版本:npm -v
3、安装curl
yum install curl
4、安装golang
yum install golang
二、安装fabric
1、下载fabric
curl -sSL https://goo.gl/iX9dek | bash
可能会出现如下问题“Peer's Certificate has expired”
解决方案可能是本地时间问题
a>查看ssl更多信息
curl https://www.baidu.com -v
* About to connect() to www.baidu.com port 443 (#0) * Trying 180.97.33.107... * Connected to www.baidu.com (180.97.33.107) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * Server certificate: * subject: CN=baidu.com,OU=service operation department,O="Beijing Baidu Netcom Science Technology Co., Ltd.",L=Beijing,ST=Beijing,C=CN * start date: Sep 17 00:00:00 2015 GMT * expire date: Aug 31 23:59:59 2016 GMT * common name: baidu.com * issuer: CN=VeriSign Class 3 International Server CA - G3,OU=Terms of use at https://www.verisign.com/rpa (c)10,OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US * NSS error -8181 (SEC_ERROR_EXPIRED_CERTIFICATE) * Peer's Certificate has expired. * Closing connection 0 curl: (60) Peer's Certificate has expired. More details here: http://curl.haxx.se/docs/sslcerts.html
根据SEC_ERROR_EXPIRED_CERTIFICATE
的错误说明,进行搜索,发现该命令是由于本地的时间不正确造成的。进行一次ntp时间同步
ntpdate pool.ntp.org
2、配置环境变量
执行上述命令时候回产生一个bin文件夹,配置这个环境变量
export PATH=<path to download location>/bin:$PATH
安装完毕
三、示例
1、安装git
yum install git
2、获取fabric-samples代码
git clone https://github.com/hyperledger/fabric-samples.git cd fabric-samples
3、在目录fabric-samples中建立子目录 first-network
mkdir first-network
cd fabric-network
在first-network中增加byfn.sh文件
./byfn.sh -h Usage: byfn.sh -m up|down|restart|generate [-c <channel name>] [-t <timeout>] byfn.sh -h|--help (print this message) -m <mode> - one of 'up', 'down', 'restart' or 'generate' - 'up' - bring up the network with docker-compose up - 'down' - clear the network with docker-compose down - 'restart' - restart the network - 'generate' - generate required certificates and genesis block -c <channel name> - config name to use (defaults to "mychannel") -t <timeout> - CLI timeout duration in microseconds (defaults to 10000) Typically, one would first generate the required certificates and genesis block, then bring up the network. e.g.: byfn.sh -m generate -c <channelname> byfn.sh -m up -c <channelname>
这里直接使用first-samples自代示例直接运行
./byfn.sh -m generate
开启网络
./byfn.sh -m up
关闭
./byfn.sh -m down
执行相关命令