如何在Vagrant中增加RAM并设置仅主机网络? [英] How do I increase the RAM and set up host-only networking in Vagrant?

查看:86
本文介绍了如何在Vagrant中增加RAM并设置仅主机网络?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将RAM增加到至少1 GB,并且我想将仅主机"网络配置为使用"199.188.44.20".

I would like to increase the RAM to at least 1 GB and I would like to configure "Host-Only" networking to use "199.188.44.20".

这是我的Vagrantfile:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run do |config|

    config.vm.customize ["modifyvm", :id, "--memory", 1024]

    config.vm.network :hostonly, "199.188.44.20"

    config.vm.define :web do |web_config|
        web_config.vm.box = "lucid32"
        web_config.vm.forward_port 80, 8080

        web_config.vm.provision :puppet do |puppet|
            puppet.manifests_path = "manifests"
            puppet.manifest_file = "lucid32.pp"
        end
    end

    config.vm.define :web2 do |web2_config| 
        web2_config.vm.box = "lucid32"
        web2_config.vm.forward_port 80, 8081

        web2_config.vm.provision :puppet do |puppet|
            puppet.manifests_path = "manifests"
            puppet.manifest_file = "myweb.pp"
        end
    end
end

但是,当我运行vagrant up时,我得到了:

However, when I run vagrant up I am getting:

在尝试引导时,VM无法保持在运行"状态.这通常是由于配置错误或主机系统不兼容引起的.请打开VirtualBox GUI并尝试手动启动虚拟机,以获取更多有用的错误消息

而且,尝试登录VM时出现connection refuse错误.

And, I am getting a connection refuse error when I try to log in to the VM.

推荐答案

您可以通过添加以下配置(

You can modify various VM properties by adding the following configuration (see the Vagrant docs for a bit more info):

  # Configure VM Ram usage
  config.vm.customize [
                        "modifyvm", :id,
                        "--name", "Test_Environment",
                        "--memory", "1024"
                      ]

您可以从VirtualBox命令行选项的文档中获取要更改的属性:

You can obtain the properties that you want to change from the documents for VirtualBox command-line options:

无用文档包含有关如何更改IP地址的部分:

The vagrant documentation has the section on how to change IP address:

Vagrant::Config.run do |config|
  config.vm.network :hostonly, "192.168.50.4"
end

您还可以像这样重组配置,结束是使用end而不嵌套它. 这比较简单.

Also you can restructure the configuration like this, ending is do with end without nesting it. This is simpler.

config.vm.define :web do |web_config|
    web_config.vm.box = "lucid32"
    web_config.vm.forward_port 80, 8080
end
web_config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "manifests"
    puppet.manifest_file = "lucid32.pp"
end

这篇关于如何在Vagrant中增加RAM并设置仅主机网络?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆