curl -sSL https://get.daocloud.io/docker | sh
docker -v
先安装python-pip,具体安装步奏如下:
sudo yum -y install epel-release
sudo yum -y install python-pip
sudo yum clean all
下面开始安装docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
下面配置一下docker镜像加速,目的是下载镜像速度更快:
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://860eaa91.m.daocloud.io
最后重启一下docker服务:
sudo service docker restart
1.安装依赖包:
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
2.下载git源码并解压:
$ wget https://github.com/git/git/archive/v2.3.0.zip
$ unzip v2.3.0.zip
$ cd git-2.3.0
3.编译安装:
make prefix=/usr/local/git all
sudo make prefix=/usr/local/git install
4.修改环境变量:
sudo vim /etc/profile
然后在文件的最后一行,添加下面的内容,然后保存退出。
export PATH=/usr/local/git/bin:$PATH
5.使用source命令立即保存:
source /etc/profile
6.查看版本
git version
- 下载镜像命令如下:
docker pull yeasy/hyperledger-fabric-base:latest \
&& docker pull yeasy/hyperledger-fabric-peer:latest \
&& docker pull yeasy/hyperledger-fabric-orderer:latest \
&& docker pull yeasy/hyperledger-fabric-ca:latest \
&& docker pull yeasy/blockchain-explorer:latest \
&& docker tag yeasy/hyperledger-fabric-peer hyperledger/fabric-peer \
&& docker tag yeasy/hyperledger-fabric-orderer hyperledger/fabric-orderer \
&& docker tag yeasy/hyperledger-fabric-ca hyperledger/fabric-ca \
&& docker tag yeasy/hyperledger-fabric-base hyperledger/fabric-baseimage \
&& docker tag yeasy/hyperledger-fabric-base hyperledger/fabric-ccenv:x86_64-1.0.0-preview
- 下载完成后,查看下载镜像
docker images
创建2个docker网络,如下:
docker network create fabric_noops
docker network create fabric_pbft
git clone https://github.com/yeasy/docker-compose-files
docker-compose up
docker ps -a
容器如下:
c10f128ab8f5 hyperledger/fabric-peer "peer node start" 16 hours ago Up 16 hours 7050/tcp, 7052-7059/tcp, 0.0.0.0:7051->7051/tcp fabric-vp0
443083f3b2b9 hyperledger/fabric-orderer "orderer" 16 hours ago Up 16 hours 0.0.0.0:7050->7050/tcp fabric-orderer
08330f858c6f hyperledger/fabric-cop "cop server start ..." 16 hours ago Up 16 hours 0.0.0.0:8888->8888/tcp fabric-cop
容器如图:
docker exec -it fabric-vp0 bash
peer chaincode deploy -n testname -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c '{"Args":["init","a","100","b","200"]}'
peer chaincode invoke -n testname -c '{"Args":["query","a"]}'
a的值如下:
peer chaincode invoke -n testname -c '{"Args":["query","b"]}'
b的值如下:
交易,a向b转账10元,如下:
peer chaincode invoke -n testname -c '{"Args":["invoke","a","b","10"]}'
查询a的值,结果如下:
peer chaincode invoke -n testname -c '{"Args":["query","a"]}'
再次查询b的值,结果如下:
peer chaincode invoke -n testname -c '{"Args":["query","b"]}'
已经完成超级账本的 转账的实例,每转一次,都会记录一个块。
到此,整个Hyperledger Fabric1.0超级账本环境已经部署完成。