都知道vagrant是什么了吧,Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境。它 使用Oracle的开源VirtualBox虚拟化系统,使用 Chef创建自动化虚拟环境。(百度百科)
下面就来介绍怎么安装和使用:
1、准备:vagrant,box文件
2、新建一个文件夹用来存放vagrant文件,然后打开cmd命令
3、把镜像文件添加到虚拟机中 :
D:\testFabric>vagrant box add fabric0.6D:\testFabric\fabric0.6.box 4、初始化虚拟机: D:\testFabric>vagrant init fabric0.65、启动虚拟机: D:\testFabric>vagrant up6、连接虚拟机 D:\testFabric>vagrant ssh 输入密码:第一个直接回车,其他的密码为vagrant 7、得到root权限: vagrant@ubuntu-1404:~$ su其他命令: root@ubuntu-1404:/home/vagrant# cd / --回到主目录 root@ubuntu-1404:/# ls --浏览主目录文件8、跳转到虚拟机bin
root@ubuntu-1404:/# cd opt/gopath/src/github.com/hyperledger/fabric/build/bin/9、浏览bin目录的文件 root@ubuntu-1404:/opt/gopath/src/github.com/hyperledger/fabric/build/bin# ls10、开启memberrvc服务 root@ubuntu-1404:/opt/gopath/src/github.com/hyperledger/fabric/build/bin# ./membersrvc11、新开一个cmd窗口,开启peer服务,和上面步骤差不多(进入到刚新建的文件夹里),直接连接(vagrant ssh),不需要启动虚拟机了(vagrant up) root@ubuntu-1404:/opt/gopath/src/github.com/hyperledger/fabric/build/bin# ./peer node start --peer-chaincodedev12、两个服务启动后,不用管这两个窗口了,再新开一个窗口,得到root权限后:以下命令依次进行 cd / 跳转到主目录 cd opt/gopath/src 转到src目录下 root@ubuntu-1404:/opt/gopath/src# cp -a /vagrant/integralApplication/ . 将要编译的go文件进行放到虚拟机上 root@ubuntu-1404:/opt/gopath/src# ls 浏览虚拟机上的文件 root@ubuntu-1404:/opt/gopath/src# cd integralApplication/ 跳到该文件目录 root@ubuntu-1404:/opt/gopath/src/integralApplication# go build 对该文件进行编译 root@ubuntu-1404:/opt/gopath/src/integralApplication# CORE_CHAINCODE_ID_NAME=mycc01 CORE_PEER_ADDRESS=0.0.0.0:7051 ./in tegralApplication 看到很多 [shim] 就表示成功了 CHAINCODE_ID_NAMECHAINCODE_ID_NAME可以是任意的,我这里是mycc01,但需要与需测试的文件里的id一致