如何在Amazon Elastic Beanstalk实例中安装Oracle Java 7

时间:2022-09-09 23:18:19

Has anyone one come up with a good config script to install Oracle Java 1.7 in to an Elastic Beanstalk instance using the config files stored in .ebextensions. I am using a tomcat7 version of elastic beanstalk and I was able to install openJDK with yum using the following:

有没有人想出一个好的配置脚本,使用存储在.ebextensions中的配置文件将Oracle Java 1.7安装到Elastic Beanstalk实例中。我正在使用tomcat7版本的弹性beanstalk,我可以使用以下命令安装openJDK和yum:

packages:
  yum:
    java-1.7.0-openjdk: []
    java-1.7.0-openjdk-devel: []

commands:
  use_java7:
    command: alternatives --set java /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

How ever I would like to use Oracle Java 1.7 not OpenJDK and yum does not have that in it's repo natively.

我怎么想使用Oracle Java 1.7而不是OpenJDK和yum本身就没有它的回购。

3 个解决方案

#1


11  

try this configuration file

试试这个配置文件

files:
  "/home/ec2-user/install-oracle-jdk.sh":
    mode: "000755"
    owner: ec2-user
    group: ec2-user
    content: |
      #!/usr/bin/env bash
      wget -O jdk-7u25-linux-x64.rpm --no-cookies --no-check-certificate --header 'Cookie:gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup-cookie' 'http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.rpm'      
      rpm -Uvh /home/ec2-user/jdk-7u25-linux-x64.rpm
      alternatives --install /usr/bin/java java /usr/java/default/bin/java 3
      alternatives --set java /usr/java/default/bin/java

commands:
  execute-install-oracle-jdk-script:
    command: ./install-oracle-jdk.sh
    cwd: /home/ec2-user

#2


1  

You could alternately install it as you would normally do and use this ami as your ami for creating new ec2 instances.

您可以像往常一样安装它,并使用此ami作为创建新ec2实例的ami。

#3


0  

The accepted answer no longer works, its outdated. This worked for me:

接受的答案不再有效,它已经过时了。这对我有用:

# Install Oracle JDK
rpm --erase --nodeps java-1.6.0-openjdk java-1.6.0-openjdk-devel
rpm -Uvh .ebextensions/jdk-6u45-linux-amd64.rpm
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/default/bin/java 3
/usr/sbin/alternatives --set java /usr/java/default/bin/java
/usr/sbin/alternatives --install /usr/bin/java_sdk java_sdk /usr/java/default/bin/java 3
/usr/sbin/alternatives --set java_sdk /usr/java/default/bin/java

This is for java 6, since I needed it to be. Also, the jdk downloaded from oracle is actually a bin file now (oracle's custom sh script extractor), so what I did is I downloaded the bin file from oracle, extracted it to get the RPM, and then included the RPM inside the ebextensions.

这是针对java 6的,因为我需要它。另外,从oracle下载的jdk现在实际上是一个bin文件(oracle的自定义sh脚本提取器),所以我所做的是从oracle下载bin文件,将其解压缩以获取RPM,然后在ebextensions中包含RPM。

Just include that sh script to run in an ebextensions config file (google ebextenions config if you're unsure).

只需包含sh脚本即可在ebextensions配置文件中运行(如果您不确定,请使用google ebextenions config)。

Hope this helps somebody.

希望这有助于某人。

#1


11  

try this configuration file

试试这个配置文件

files:
  "/home/ec2-user/install-oracle-jdk.sh":
    mode: "000755"
    owner: ec2-user
    group: ec2-user
    content: |
      #!/usr/bin/env bash
      wget -O jdk-7u25-linux-x64.rpm --no-cookies --no-check-certificate --header 'Cookie:gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup-cookie' 'http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.rpm'      
      rpm -Uvh /home/ec2-user/jdk-7u25-linux-x64.rpm
      alternatives --install /usr/bin/java java /usr/java/default/bin/java 3
      alternatives --set java /usr/java/default/bin/java

commands:
  execute-install-oracle-jdk-script:
    command: ./install-oracle-jdk.sh
    cwd: /home/ec2-user

#2


1  

You could alternately install it as you would normally do and use this ami as your ami for creating new ec2 instances.

您可以像往常一样安装它,并使用此ami作为创建新ec2实例的ami。

#3


0  

The accepted answer no longer works, its outdated. This worked for me:

接受的答案不再有效,它已经过时了。这对我有用:

# Install Oracle JDK
rpm --erase --nodeps java-1.6.0-openjdk java-1.6.0-openjdk-devel
rpm -Uvh .ebextensions/jdk-6u45-linux-amd64.rpm
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/default/bin/java 3
/usr/sbin/alternatives --set java /usr/java/default/bin/java
/usr/sbin/alternatives --install /usr/bin/java_sdk java_sdk /usr/java/default/bin/java 3
/usr/sbin/alternatives --set java_sdk /usr/java/default/bin/java

This is for java 6, since I needed it to be. Also, the jdk downloaded from oracle is actually a bin file now (oracle's custom sh script extractor), so what I did is I downloaded the bin file from oracle, extracted it to get the RPM, and then included the RPM inside the ebextensions.

这是针对java 6的,因为我需要它。另外,从oracle下载的jdk现在实际上是一个bin文件(oracle的自定义sh脚本提取器),所以我所做的是从oracle下载bin文件,将其解压缩以获取RPM,然后在ebextensions中包含RPM。

Just include that sh script to run in an ebextensions config file (google ebextenions config if you're unsure).

只需包含sh脚本即可在ebextensions配置文件中运行(如果您不确定,请使用google ebextenions config)。

Hope this helps somebody.

希望这有助于某人。