一、參考地址:https://hyperledger-fabric.readthedocs.io/en/latest/prereqs.html#install-curlhtml
1、前置條件和系統配置node
一、安裝dockergit
http://www.cnblogs.com/bjlhx/p/7121875.htmlgithub
二、系統配置golang
Node.js-v2.1.8 及更高版本sql
在Centos7 64位上安裝node.jsdocker
yum install npm
查看npm版本:npm -v
三、安裝curl npm
yum install curl
四、安裝golangbash
yum install golang
2、安裝fabric網絡
一、下載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
二、配置環境變量
執行上述命令時候回產生一個bin文件夾,配置這個環境變量
export PATH=<path to download location>/bin:$PATH
安裝完畢
3、示例
一、安裝git
yum install git
二、獲取fabric-samples代碼
git clone https://github.com/hyperledger/fabric-samples.git cd fabric-samples
三、在目錄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
執行相關命令