6

私は浮浪者ツールが初めてです。

Ubuntu 13.04 を使用しています

私のプロジェクト ディレクトリは「/var/www/project」です。

次のコマンドで Vagrantfile をセットアップしました。

vagrant init test_box http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box

Vagrantfile が正常に作成されました。

以下、ファイルの中身

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

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # All Vagrant configuration is done here. The most common configuration
  # options are documented and commented below. For a complete reference,
  # please see the online documentation at vagrantup.com.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "test_box"

  # The url from where the 'config.vm.box' box will be fetched if it
  # doesn't already exist on the user's system.
  config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/current/saucy-server-cloudimg-amd64-vagrant-disk1.box"

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # If true, then any SSH connections made will enable agent forwarding.
  # Default value: false
  # config.ssh.forward_agent = true

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
   config.vm.provider "virtualbox" do |vb|
  #   # Don't boot with headless mode
     vb.gui = true
  #
  #   # Use VBoxManage to customize the VM. For example to change memory:
     vb.customize ["modifyvm", :id, "--memory", "1024"]
   end
  #
  # View the documentation for the provider you're using for more
  # information on available options.

  # Enable provisioning with Puppet stand alone.  Puppet manifests
  # are contained in a directory path relative to this Vagrantfile.
  # You will need to create the manifests directory and a manifest in
  # the file test_box.pp in the manifests_path directory.
  #
  # An example Puppet manifest to provision the message of the day:
  #
  # # group { "puppet":
  # #   ensure => "present",
  # # }
  # #
  # # File { owner => 0, group => 0, mode => 0644 }
  # #
  # # file { '/etc/motd':
  # #   content => "Welcome to your Vagrant-built virtual machine!
  # #               Managed by Puppet.\n"
  # # }
  #
  # config.vm.provision "puppet" do |puppet|
  #   puppet.manifests_path = "manifests"
  #   puppet.manifest_file  = "site.pp"
  # end

  # Enable provisioning with chef solo, specifying a cookbooks path, roles
  # path, and data_bags path (all relative to this Vagrantfile), and adding
  # some recipes and/or roles.
  #
  # config.vm.provision "chef_solo" do |chef|
  #   chef.cookbooks_path = "../my-recipes/cookbooks"
  #   chef.roles_path = "../my-recipes/roles"
  #   chef.data_bags_path = "../my-recipes/data_bags"
  #   chef.add_recipe "mysql"
  #   chef.add_role "web"
  #
  #   # You may also specify custom JSON attributes:
  #   chef.json = { :mysql_password => "foo" }
  # end

  # Enable provisioning with chef server, specifying the chef server URL,
  # and the path to the validation key (relative to this Vagrantfile).
  #
  # The Opscode Platform uses HTTPS. Substitute your organization for
  # ORGNAME in the URL and validation key.
  #
  # If you have your own Chef Server, use the appropriate URL, which may be
  # HTTP instead of HTTPS depending on your configuration. Also change the
  # validation key to validation.pem.
  #
  # config.vm.provision "chef_client" do |chef|
  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
  #   chef.validation_key_path = "ORGNAME-validator.pem"
  # end
  #
  # If you're using the Opscode platform, your validator client is
  # ORGNAME-validator, replacing ORGNAME with your organization name.
  #
  # If you have your own Chef Server, the default validation client name is
  # chef-validator, unless you changed the configuration.
  #
  #   chef.validation_client_name = "ORGNAME-validator"
end

command を実行するvagrant upと、空白の画面で仮想ボックスが開き、端末で取得しているコマンドのログは次のようになります。

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...
    default: Error: Connection timeout. Retrying...

vagrant のバージョン: Vagrant 1.5.1

仮想ボックスのバージョン: 4.3.10r93012

どこがうまくいかないかについて、このプロセスで親切に案内してください。

事前設定が必要な場合は、教えてください。

前もって感謝します。

4

5 に答える 5

3

こんにちは@Ghanshyam Dobariya、

次の手順は私のために働いた

ステップ 1 次の virtualbox apt を/etc/apt/sources.listに追加します

deb http://download.virtualbox.org/virtualbox/debian precise contrib 

ステップ 2キーをダウンロードして登録する

wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -

sudo apt-get update               

ステップ 3 https://www.virtualbox.org/wiki/Linux_Downloadsから適切な VirtualBox セットアップをダウンロードし(私は Debian 7 wheezy x64 で行いました)、次のコマンドを使用してインストールします。

dpkg -i virtualbox-4.3_4.3.10-93012~Debian~wheezy_amd64.deb 

#Fix dependence issues (if exists)
apt-get -f install

ステップ 4必要なパッケージをインストールする

sudo apt-get install dkms
sudo apt-get install dpkg-dev virtualbox-dkms

#install linux headers for your distro
sudo apt-get install linux-headers-$(uname -r)

#reconfigure virtualbox-dkms 
sudo dpkg-reconfigure virtualbox-dkms

ステップ5次のURLからprecision32.boxイメージをダウンロードします

http://hashicorp-files.vagrantup.com/precise32.box

ステップ 6 vagrant ボックスを追加する

$vagrant box add precise32 ~/Downloads/precise32.box   

成功すると、以下のような出力が得られるはずです

==> box: Adding box 'precise32' (v0) for provider: 
    box: Downloading: file:///home/ravi/Downloads/precise32.box
==> box: Successfully added box 'precise32' (v0) for 'virtualbox'!

ステップ 7プロジェクトのルート ディレクトリを作成し、そこに移動します

mkdir test_project
cd test_project

次に、初期化コマンドを実行します。

vagrant init

これにより、プロジェクト構成の中心的なファイルとなる Vagrantfile がこのフォルダーに作成されます。ただし、追加したばかりのボックスを使用してゲスト マシンをデプロイする前に、Vagrantfile を編集します。

次の行を見つけます。

config.vm.box = "base"

そしてそれを次のように置き換えます:

config.vm.box = "precise32"

これにより、この新しいボックスを使用するように指示されます。ファイルを保存して終了します。これで、次のコマンドを使用してゲスト マシンをデプロイできます。

vagrant up

これにより、Ubuntu 12.04 LTS を実行する VPS が表示されます。これを利用するには、簡単に SSH 接続できます。

$vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
 * Documentation:  https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@precise32:~$ _

詳細については、お読みください

于 2014-04-02T12:03:07.223 に答える
2

64 ビットの vm を実行している場合は、ローカル マシンの BIOS 設定を調べて、VM 機能を有効にする必要がある場合があります。Windows 7 をローカルで実行しており、Lenovo ラップトップで ubuntu/trusty64 を実行しています。BIOS で仮想化設定を有効にする必要がありましたが、接続タイムアウトがなくなりました。

于 2014-06-04T14:40:08.430 に答える
1

ファイアウォールでポート 22 を開いてみてください。

Oracle VM VirtualBox Manager を使用して、VM を直接起動するか、

これを Vagrantfile に追加します

config.vm.provider :virtualbox do |vb|
  vb.gui = true
end

「vagrant up」を実行します

デフォルトの vagrant 資格情報を使用してログインする

user: vagrant
pass: vagrant

ファイアウォール ルールを追加

sudo ufw allow 22
于 2014-07-29T11:18:49.253 に答える
1

画像 [Ubuntu 正確な 32 VirtualBox] -http://files.vagrantup.com/precise32.box正常に動作しています。

公式の Ubuntu 13.04 の毎日のクラウド イメージ i386 (ゲストの追加なし)公式の Ubuntu 13.04 の毎日のクラウド イメージ amd64 (ゲストの追加なし) に問題がある可能性があります。

サイトは : http://www.vagrantbox.es/

于 2014-04-02T14:53:21.340 に答える