具体见:https://hyperledger-fabric.readthedocs.io/en/release/prereqs.html
注意版本
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
Installthe latest version of Docker CE on RHEL:
sudo yum -y install docker-ce
curl -Lhttps://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname-s`-`uname -m` > /usr/local/bin/docker-compose
参考文档
https://docs.docker.com/compose/install/#install-compose
wget https://www.golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz
解压到:/usr/local/go下,并设置:exportPATH=$PATH:/usr/local/go/bin
https://nodejs.org/dist/v8.9.3/node-v8.9.3-linux-x64.tar.xz
解压到:/usr/local/nodejs下,并设置:export PATH=$PATH:/usr/local/nodejs/bin
执行:npminstallnpm@3.10.10 -g
具体见:https://hyperledger-fabric.readthedocs.io/en/release/prereqs.html
如果报下面的错误:
Got permission denied while trying toconnect to the Docker daemon socket at unix:///var/run/docker.sock: Posthttp://%2Fvar%2Frun%2Fdocker.sock/v1.32/images/hyperledger/fabric-ca:x86_64-1.0.4/tag?repo=hyperledger%2Ffabric-ca&tag=latest:dial unix/var/run/docker.sock: connect: permissiondenied
解决:
su – root, chmod 777 /var/run/docker.sock
get sample: gitclonehttps://github.com/hyperledger/fabric-samples.git
/home/oracle/fabric/fabric-samples/first-network
具体见:https://hyperledger-fabric.readthedocs.io/en/release/samples.html
执行:gitclonehttps://github.com/hyperledger/fabric-samples.git
执行:curl -sSLhttps://goo.gl/byy2Qj | bash -s1.0.5
如果访问不了,可访问:
goo.gl/byy2Qj对应的是:
https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap-1.0.3.sh
可wget https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap-1.0.3.sh该文件, 然后在本地执行:
sh bootstrap-1.0.3.sh 1.0.5
下载完成后,参考https://hyperledger-fabric.readthedocs.io/en/release/write_first_app.html把SAMPLE跑起来
注意:registerUser.js 需要把:
returnfabric_ca_client.register({enrollmentID: 'user1', affiliation:'org1.department1'}, admin_user);
修改为:
returnfabric_ca_client.register({enrollmentID: 'user1', affiliation:'org1.department1',role: 'client'}, admin_user);
才能跑起来
把前面的SAMPLE 停止
参考:https://hyperledger-fabric.readthedocs.io/en/release/chaincode4ade.html
感觉要先跑一下SAMPLE,然后再执行
docker-compose -fdocker-compose-simple.yamlup等命令,否则报:
orderer | 2017-12-23 13:15:24.155 UTC [common/configtx] addToMap -> DEBU 19a Adding to config map: [Values] /Channel/Consortium
orderer | 2017-12-23 13:15:24.155 UTC [orderer/common/broadcast] Handle -> WARN 19b Rejecting CONFIG_UPDATE because: Error authorizing update: Error validating ReadSet: Readset expected key [Groups] /Channel/Application at version 0, but got version 1
orderer | 2017-12-23 13:15:24.155 UTC [orderer/main] func1 -> DEBU 19c Closing Broadcast stream
orderer | 2017-12-23 13:15:24.167 UTC [orderer/common/deliver] Handle -> WARN 19d Error reading from stream: rpc error: code = Canceled desc = context canceled
orderer | 2017-12-23 13:15:24.168 UTC [orderer/main] func1 -> DEBU 19e Closing Deliver stream
docker rm -f$(docker ps -aq)
dockernetworkprune
dockerrmidev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba
Failed to register: Error: fabric-carequest register failed with errors[[{"code":0,"message":"No identity type provided.Please provide identity type"}]]
到fabric-samples/fabcar下执行:startFabric.sh
然后执行下面的命令停止并清理环境:
docker rm -f$(docker ps -aq)
dockernetworkprune
dockerrmidev-peer0.org1.example.com-fabcar-1.0-5c906e402ed29f20260ae42283216aa75549c571e2e380f3615826365d8269ba
到/home/oracle/fabric-samples/chaincode-docker-devmode 下面执行:
docker-compose-fdocker-compose-simple.yamlup
确保启动过程不报错。然后就可以按https://hyperledger-fabric.readthedocs.io/en/release/chaincode4ade.html中的步骤开发,编译,部署,测试了。
更多精彩内容,欢迎关注本人的公众号: 书生老徐