我需要2个虚拟流浪网络通过一个“网关”相互通信。我正在建模将在许多服务器上部署的多层应用程序。我需要这样的事情:
db-server-- --db-server
| |
--distributor **** distributor--
| |
app-server- -app-server
db-server
,app-server
和distributor
建立私人网络。该网络只能从第二个虚拟网络的distributor
访问。我有Vagrantfile
:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
# db-server
config.vm.define "db" do |db|
db.vm.hostname = "db"
db.vm.provider "virtualbox" do |v|
v.customize [ "modifyvm", :id, "--cpus", "1" ]
v.customize [ "modifyvm", :id, "--memory", "512" ]
end
db.vm.network "private_network", ip: "192.168.10.11"
end
# application server
config.vm.define "app" do |app|
app.vm.hostname = "app"
app.vm.provider "virtualbox" do |v|
v.customize [ "modifyvm", :id, "--cpus", "1" ]
v.customize [ "modifyvm", :id, "--memory", "512" ]
end
app.vm.network "private_network", ip: "192.168.10.12"
end
# distributor server
config.vm.define "distributor" do |distributor|
distributor.vm.hostname = "distributor"
distributor.vm.provider "virtualbox" do |v|
v.customize [ "modifyvm", :id, "--cpus", "1" ]
v.customize [ "modifyvm", :id, "--memory", "512" ]
end
distributor.vm.network "private_network", ip: "192.168.10.13"
end
end
我应该如何配置distributor
?我找到的唯一方法就是添加config.vm.network "public_network", ip: "192.168.10.14"
之类的smth
但是我应该将什么IP分配给经销商2?我可以在同一Vagrantfile
中指定第二台网络计算机吗?
答案 0 :(得分:1)
您可以从this answer(其他详细信息)进行推断:
db-server-1=[192.168.1.3] [192.168.2.3]=db-server-2
[192.168.1.1]=distributor=[192.168.2.1]
app-server-1=[192.168.1.5] [192.168.2.5]=app-server-2
Vagrant
档案复制&粘贴:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "libvirt"
config.vm.define "rhel7_minion" do |rhel7_minion|
rhel7_minion.vm.box = "uvsmtid/centos-7.1-1503-gnome"
rhel7_minion.vm.synced_folder '.', '/vagrant', disabled: true
rhel7_minion.vm.network 'private_network',
:libvirt__network_name => 'primary_vagrant_private_net',
ip: '192.168.1.2',
:libvirt__netmask => '255.255.255.0',
:libvirt__forward_mode => 'route',
:libvirt__dhcp_enabled => true
end
config.vm.define "rhel5_minion" do |rhel5_minion|
rhel5_minion.vm.box = "uvsmtid/centos-5.5-minimal"
rhel5_minion.vm.synced_folder '.', '/vagrant', disabled: true
rhel5_minion.vm.network 'private_network',
:libvirt__network_name => 'secondary_vagrant_private_net',
ip: '192.168.2.3',
:libvirt__netmask => '255.255.255.0',
:libvirt__forward_mode => 'route',
:libvirt__dhcp_enabled => true
end
end
distributor
可以是您的物理主机。rhel7_minion
=>来获得图表的上半部分 db-server-1
和rhel5_minion
=> db-server-2
。app-server-1
和app-server-2
。答案 1 :(得分:0)
在您的Vagrantfile应用程序中,Db和分发服务器都在专用网络上,因此这三者都可以相互通信。您可以将应用程序放在专用网络上,公共网络上的数据库以及公共网络和专用网络上的分发服务器。此配置允许分发服务器通过专用网络与应用程序通过公共网络与数据库通信,但应用程序和数据库无法相互通信,因为应用程序位于专用网络上且数据库已公开。现在,在分发服务器上安装一些程序的king = d,它可以像app和db之间的代理一样。