使用Vagrant设置Java dev环境时出错

时间:2016-04-07 12:19:04

标签: java vagrant

我有以下Vagrantfile:

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

Vagrant.configure(2) do |config|

  config.vm.box = "ubuntu/trusty64"
  config.vm.network "private_network", ip: "55.55.55.102"
  config.vm.synced_folder ".", "/home/vagrant/shared/"

  #config.vm.provision "file", source: "conf/sbt.sh", destination: "/home/vagrant/bin/sbt"

  config.vm.provision "shell", inline: <<-SHELL    
    #
    # Update and install basic linux programs for development
    #
    sudo apt-get update     
    sudo apt-get install -y wget
    sudo apt-get install -y curl
    sudo apt-get install -y vim
    sudo apt-get install -y git    
    sudo apt-get install -y build-essential
    sudo apt-get install -y unzip 
    #
    # Install Java 8 
    #
    cd /opt
    sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz"
    sudo tar -xzvf jdk-8u45-linux-x64.tar.gz
    sudo rm -rf jdk-8u45-linux-x64.tar.gz
  SHELL

end

我收到以下错误:

==> default: --2016-04-07 12:15:44--  http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
==> default: Resolving download.oracle.com (download.oracle.com)... 
==> default: 217.7.48.90
==> default: , 
==> default: 217.7.48.190
==> default: Connecting to download.oracle.com (download.oracle.com)|217.7.48.90|:80... 
==> default: connected.
==> default: HTTP request sent, awaiting response... 
==> default: 302 Moved Temporarily
==> default: Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz [following]
==> default: --2016-04-07 12:15:47--  https://edelivery.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz
==> default: Resolving edelivery.oracle.com (edelivery.oracle.com)... 
==> default: failed: Name or service not known.
==> default: wget: unable to resolve host address ‘edelivery.oracle.com’

有关我为何会收到此错误的任何线索?

1 个答案:

答案 0 :(得分:1)

  1. 您的脚本中不需要sudo,因为脚本已经以root用户身份运行。您可以查看https://stackoverflow.com/a/36384265/4296747以获取更多信息/示例

  2. 只是解压缩文件不足以安装它但我猜你一旦通过当前问题就会动起来

  3. 我尝试使用完全相同的文件并且有效,但我不认为将私有IP设置为&#34; 55.55.55.102&#34;是一种很好的做法

  4. 我会更改网络部分 - 尝试使用网桥适配器查看是否通过了问题,如果需要私有IP,请在192.168.xxx.xxx范围内取一个