vagrant從安裝到使用

都知道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.6
5、啓動虛擬機:

D:\testFabric>vagrant up
6、連接虛擬機

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# ls
10、開啓memberrvc服務

root@ubuntu-1404:/opt/gopath/src/github.com/hyperledger/fabric/build/bin# ./membersrvc
11、新開一個cmd窗口,開啓peer服務,和上面步驟差不多(進入到剛新建的文件夾裏),直接連接(vagrant ssh),不需要啓動虛擬機了(vagrant up)

root@ubuntu-1404:/opt/gopath/src/github.com/hyperledger/fabric/build/bin# ./peer node start --peer-chaincodedev
12、兩個服務啓動後,不用管這兩個窗口了,再新開一個窗口,得到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_NAME
CHAINCODE_ID_NAME可以是任意的,我這裏是mycc01,但需要與需測試的文件裏的id一致


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章