fabric devenv Vagrantfile配置
Vagrantfile文件只会在第一次执行vagrant up时调用执行,其后如果不明确使用vagrant reload,则不会被强制重新加载。
# This is the mount point for the sync_folders of the source
SRCMOUNT = "/hyperledger"
LOCALDEV = "/local-dev"
变量script为执行完基本配置后,需要执行的脚本
$script = <<SCRIPT
set -x export DOCKER_STORAGE_BACKEND="#{ENV['DOCKER_STORAGE_BACKEND']}" cd #{SRCMOUNT}/devenv
./setup.sh SCRIPT
baseimage_release = File.read '../.baseimage-release'
Vagrant.require_version ">= 1.7.4"
box设置:配置虚拟机主机名
config.vm.box = "hyperledger/fabric-baseimage"
auto download box from
config.vm.box_version = ENV['USE_LOCAL_BASEIMAGE'] ? "": baseimage_release # Vagrant does not support versioning local images, the local version is always implicitly version
端口转发,设置主机与虚拟机之间的端口的映射关系.要转发到虚拟机(guest)上的端口是 7050,转发的是主机(host)上的7050 端口。也就是你在访问主机上的7050端口的时候,实际上访问的是虚拟机上的 7050端口
config.vm.network :forwarded_port, guest: 7050, host: 7050 # Openchain REST services
config.vm.network :forwarded_port, guest: 7051, host: 7051 # Openchain gRPC services
config.vm.network :forwarded_port, guest: 7054, host: 7054 # Membership service
config.vm.network :forwarded_port, guest: 7053, host: 7053 # GRPCCient gRPC services
同步目录:synced_folder方法的第一个参数为主机上要跟虚拟机同步的目录,第二个参数为要挂载到虚拟机上的路径。
config.vm.synced_folder "..", "#{SRCMOUNT}" #Copy /opt/gopath/src/github.com/hyperledger/fabric folder to /hyperledger
config.vm.synced_folder "..", "/opt/gopath/src/github.com/hyperledger/fabric" #Copy /opt/gopath/src/github.com/hyperledger/fabric folder to /opt/gopath/src/github.com/hyperledger/fabric
config.vm.synced_folder ENV.fetch('LOCALDEVDIR', ".."), "#{LOCALDEV}" #Copy /opt/gopath/src/github.com/hyperledger/fabric folder to /opt/gopath/src/github.com/hyperledger/fabric
#/vagrant => /opt/gopath/src/github.com/hyperledger/fabric/devenv 默认配置下,虚拟机中的/vagrant目录与主机上的项目目录是同一个目录,该目录中的所有操作都会自动同步。
#注意的是,在该虚拟机上进行rm -fr /操作的时候请谨慎一些,因为在该虚拟机中,挂载了/vagrant目录,该目录是与你主机的项目共享的,删除的话会将项目删除掉。
内存和cpu核心
config.vm.provider :virtualbox do |vb|
#Customize the amount of memory on the VM:
vb.name = "hyperledger"
vb.customize ['modifyvm', :id, '--memory', '']
vb.cpus = 2 storage_backend = ENV['DOCKER_STORAGE_BACKEND']
case storage_backend
when nil,"","aufs","AUFS"
# No extra work to be done
when "btrfs","BTRFS"
# Add a second disk for the btrfs volume
IO.popen("VBoxManage list systemproperties") { |f| success = false
while line = f.gets do
# Find the directory where the machine images are stored
machine_folder = line.sub(/^Default machine folder:\s*/,"") if line != machine_folder
btrfs_disk = File.join(machine_folder, vb.name, 'btrfs.vdi') unless File.exist?(btrfs_disk)
# Create the disk if it doesn't already exist
vb.customize ['createhd', '--filename', btrfs_disk, '--format', 'VDI', '--size', 20 * 1024]
end # Add the disk to the VM
vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', btrfs_disk]
success = true break
end
end
raise Vagrant::Errors::VagrantError.new, "Could not provision btrfs disk" if !success
}
else
raise Vagrant::Errors::VagrantError.new, "Unknown storage backend type: #{storage_backend}"
end
Vagrant使用提供者(provider)来启动隔离的虚拟环境。默认的提供者是Virtualbox
The Vagrant Shell provisioner allows you to upload and execute a script within the guest machine.Reference to Shell Provisioner
config.vm.provision :shell, inline: $script #run scripts
config.vm.provision :shell, path =>"boot.sh" #run scripts in boot.sh file using ssh provider method like running command 'vagrant ssh'
vagrant up (启动虚拟机)
vagrant halt (关闭虚拟机——对应就是关机)
vagrant suspend (暂停虚拟机——只是暂停,虚拟机内存等信息将以状态文件的方式保存在本地,可以执行恢复操作后继续使用)
vagrant resume (恢复虚拟机 —— 与前面的暂停相对应)
vagrant destroy (删除虚拟机,删除后在当前虚拟机所做进行的除开Vagrantfile中的配置都不会保留)
vagrant package --output NAME --vagrantfile FILE(当在启动Vagrant后,对于虚拟机有进行过安装环境相关的配置,如果并不希望写在Vagrant的启动shell里面每次都重新安装配置一遍,可以将当前配置好的虚拟机打包成box.(可选)设置通过NAME来指定输出的文件名/(可选)可以将Vagrantfile直接封进box中)注:如果网络模式中使用 private_network 的话,在打包之前需要清除一下private_network的设置,避免不必要的错误:sudo rm -f /etc/udev/rule.d/70-persistent-net.rules
参考网站:
fabric devenv Vagrantfile配置的更多相关文章
- Hyperledger Fabric 中channel配置相关数据结构
channel Configuration Transaction Hyperledger Fabric区块链网络中的配置存储在一个configuration-transaction的集合中,每个ch ...
- Vagrant 手册之 Vagrantfile - 配置版本
原文地址 配置版本是 Vagrant 1.1+(引入了大量新功能和配置选项) 能够与 Vagrant 1.0.x Vagrantfiles 保持向后兼容的机制. 现在运行 vagrant init 时 ...
- Fabric docker-compose volumes配置解析
chaincode: container_name: chaincode image: hyperledger/fabric-ccenv tty: true environment: - GOPATH ...
- vagrantfile 配置
config.vm.network "forwarded_port", guest: 22, host: 2222, id: "ssh", disabled: ...
- linux安装open block chain
Compile the source code Step 1. 安装git sudo apt-get install git Step 2. 安装vagrant(ubuntu系统) 下载地址https ...
- Python Fabric ssh 配置解读
Python Fabric ssh 配置解读 Fabric 2.4简介: Fabric is a high level Python (2.7, 3.4+) library designed to e ...
- windows 搭建 IBM Hyperledger Fabric(超级账本)开发环境
一.概述 Hyperledge fabric项目是IBM开源的区块链项目.Github地址:https://github.com/hyperledger/fabric 想对fabric有具体的认识,可 ...
- 在window下搭建即时即用的hyperledger fabric 的环境
有版本号的严格按要求,遇到不少坑 1)安装git 版本无要求 2)安装go 1.9 配置环境变量 3)安装Vagrant 1.9.4 4)安装VirtualBox 5.1.28 5)在go ...
- HyperLedger Fabric部署与链码解读
1.Fabric简介 Fabric是超级账本中的一个项目,用以推进区块链技术.和其他区块链类似,它也有一个账本,使用智能合约,且是一个参与者可以分别管理自身交易的系统.它是一个联盟链.Fabric与其 ...
随机推荐
- WinNTSetup v3.8.7 正式版绿色增强版
最强系统安装利器:WinNTSetup 现已更新至 v3.8.7 正式版!这次更新修复调整了诸多问题,新版非常好用接近完美!WinNTSetup 现在已经自带BCDBoot 选项,并且完全支持Wind ...
- php 读取csv 乱码
在php手册里面有这样一个例子,为什么读出的是乱码<?php$row = 1;$handle = fopen("test.csv","r");while ...
- Notepad++编写Markdown
Markdown语法高亮 下载userDefineLang_markdown.xml 打开Notepad++的 Language 菜单,选中底部的 Define your language... 在 ...
- TypeScript Type Compatibility(类型兼容)
TypeScript中的类型兼容是基于结构归类的.在普通分类的相比之下,结构归类是一种纯粹用于将其成员的类型进行关联的方法.思考下面的代码: interface Named { name: strin ...
- jQuery animate动画 stop()方法详解~
一.动画格式: 格式一:jQueryObject.animate( cssProperties, options ) 格式二:$('#id').animate( styles[, duration ] ...
- Google Map API V3开发(5)
Google Map API V3开发(1) Google Map API V3开发(2) Google Map API V3开发(3) Google Map API V3开发(4) Google M ...
- 精简高效的css命名准则
对于css,为了避免样式冲突,我们总会赋予相当特殊的命名,或是在选择符上添加html标记,或是使用层级.我们为避免在冲突上做文章,就会把代码的命名变得复杂化. 如果css的重用性越高,相比就越高效.如 ...
- html传参数
var request = { QueryString: function (paramName) { var url = window.location.search; paramValue = & ...
- 全文搜索 Lucene.Net
Lucene简介 首先说明的是--Lucene.Net只是一个全文检索开发包,不是一个成型的搜索引擎, 它的功能就是负责将文本数据按照某种分词算法进行切词,分词后的结果存储在索引库中,从索引库检索数据 ...
- [Head First设计模式]抢票中的设计模式——代理模式
系列文章 [Head First设计模式]山西面馆中的设计模式——装饰者模式 [Head First设计模式]山西面馆中的设计模式——观察者模式 [Head First设计模式]山西面馆中的设计模式— ...