[JAVA] [Oracle Cloud] Install the free Oracle JDK 11 (LTS) on a virtual instance of OCI

Introduction

It was announced that the Oracle JDK is now available for commercial use free of charge when used with Oracle Cloud Infrastructure (OCI). https://blogs.oracle.com/developers/support-for-oracle-java-se-now-included-with-oracle-cloud-infrastructure

Describes how to build CentOS on OCI and install Oracle JDK 11. The reasons for choosing Oracle JDK 11 are as follows.

--Oracle JDK version 11 is subject to LTS and the Premier Support period is from September 2018 to September 2023.

Points to remember

The Repository referenced by Default is disabled by CentOS and switched to the Repository provided by OCI. You can continue to use the one provided by OCI, but if you are concerned, please restore it after installing the JDK.

Install Oracle JDK

Build Compute Instance with OCI

Stand up properly on CentOS7. See the tutorials below https://community.oracle.com/docs/DOC-1019313

Change Yum Repository reference

First, switch to root

sudo su -

Download GPG KEY to connect to ULN (Unbreakable Linux Network)

wget https://yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

Apply GPG KEY

# gpg --quiet --with-fingerprint /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
pub  2048R/EC551F03 2010-07-01 Oracle OSS group (Open Source Software group) <[email protected]>
      Key fingerprint = 4214 4123 FECF C55B 9086  313D 72F9 7B74 EC55 1F03

Disable CentOS Defaule references

mkdir /etc/yum.repos.d/old
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/old

Create a temporary file to reference the Repository on the ULN side.

cat <<'EOF' > /etc/yum.repos.d/ol7-temp.repo
[ol7_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
EOF

Check if you can refer to it normally with yum repolist

# yum repolist
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repo id                    repo name                                 status
ol7_latest/x86_64          Oracle Linux 7Server Latest (x86_64)      13,163
repolist: 13,163

Install the package to reference the repository

yum install -y oraclelinux-release-el7

The following packages will be installed

Dependencies Resolved

==============================================================================================================
Package                           Arch             Version                        Repository            Size
==============================================================================================================
Installing:
 oraclelinux-release-el7           x86_64           1.0-6.el7                      ol7_latest            18 k
Installing for dependencies:
 python-kitchen                    noarch           1.1.1-5.el7                    ol7_latest           265 k
 yum-utils                         noarch           1.1.31-50.0.1.el7              ol7_latest           121 k

Transaction Summary
==============================================================================================================

The yum.repo.d directory has the following structure

# ls -la 
total 28 
drwxr-xr-x.  3 root root  108 Jul 16 16:01 .
drwxr-xr-x. 90 root root 8192 Jul 16 13:10 ..
-rw-r--r--.  1 root root  203 Jul 16 16:01 ol7-temp.repo
drwxr-xr-x.  2 root root  229 Jul 16 16:01 old
-rw-r--r--.  1 root root 3586 Jul 16 16:01 oracle-linux-ol7.repo
-rw-r--r--.  1 root root 2108 Jul 16 16:01 uek-ol7.repo
-rw-r--r--.  1 root root  225 Jul 16 16:01 virt-ol7.repo

Disable the Temporarily Created Repository

mv /etc/yum.repos.d/ol7-temp.repo /etc/yum.repos.d/old/

Each Region of OCI has a yum mirror server for fast package downloads. To access it, configure the following settings. First, install the jq command to format the JSON

sudo curl -o /usr/local/bin/jq -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && sudo chmod +x /usr/local/bin/jq

Get the Region name where Compute Instance is running and store it in / etc / yum / vars / ociregion.

export OCIREGION=`curl -sfm 3 http://169.254.169.254/opc/v1/instance/ | jq -r '.region' | cut -d '-' -f 2`
echo "-$OCIREGION" > /etc/yum/vars/ociregion

Check the contents of the file

# cat /etc/yum/vars/ociregion 
-tokyo 

Check yum repolist. It is OK if you can refer to the following 5 types of Repository.

# yum repolist
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
repo id                    repo name                                                                    status
ol7_UEKR5/x86_64           Latest Unbreakable Enterprise Kernel Release 5 for Oracle Linux 7Server (x86    154
ol7_addons/x86_64          Oracle Linux 7Server Add ons (x86_64)                                           340
ol7_latest/x86_64          Oracle Linux 7Server Latest (x86_64)                                         13,163
ol7_ociyum_config          OCI specific release packages Oracle Linux 7Server (x86_64)                      27
ol7_optional_latest/x86_64 Oracle Linux 7Server Optional Latest (x86_64)                                 9,978
repolist: 23,662

I will try installing vim to see if it can be installed normally.

yum install -y vim

The following dependencies will be resolved and the installation will be successful.

==============================================================================================================
Package                          Arch             Version                         Repository            Size
==============================================================================================================
Installing:
 vim-enhanced                     x86_64           2:7.4.160-6.el7_6               ol7_latest           1.0 M
Installing for dependencies:
 gpm-libs                         x86_64           1.20.7-5.el7                    ol7_latest            31 k
 perl                             x86_64           4:5.16.3-294.el7_6              ol7_latest           8.0 M
 perl-Carp                        noarch           1.26-244.el7                    ol7_latest            19 k
 perl-Encode                      x86_64           2.51-7.el7                      ol7_latest           1.5 M
 perl-Exporter                    noarch           5.68-3.el7                      ol7_latest            28 k
 perl-File-Path                   noarch           2.09-2.el7                      ol7_latest            26 k
 perl-File-Temp                   noarch           0.23.01-3.el7                   ol7_latest            56 k
 perl-Filter                      x86_64           1.49-3.el7                      ol7_latest            76 k
 perl-Getopt-Long                 noarch           2.40-3.el7                      ol7_latest            55 k
 perl-HTTP-Tiny                   noarch           0.033-3.el7                     ol7_latest            38 k
 perl-PathTools                   x86_64           3.40-5.el7                      ol7_latest            82 k
 perl-Pod-Escapes                 noarch           1:1.04-294.el7_6                ol7_latest            51 k
 perl-Pod-Perldoc                 noarch           3.20-4.el7                      ol7_latest            86 k
 perl-Pod-Simple                  noarch           1:3.28-4.el7                    ol7_latest           216 k
 perl-Pod-Usage                   noarch           1.63-3.el7                      ol7_latest            26 k
 perl-Scalar-List-Utils           x86_64           1.27-248.el7                    ol7_latest            35 k
 perl-Socket                      x86_64           2.010-4.el7                     ol7_latest            48 k
 perl-Storable                    x86_64           2.45-3.el7                      ol7_latest            76 k
 perl-Text-ParseWords             noarch           3.29-4.el7                      ol7_latest            13 k
 perl-Time-HiRes                  x86_64           4:1.9725-3.el7                  ol7_latest            44 k
 perl-Time-Local                  noarch           1.2300-2.el7                    ol7_latest            24 k
 perl-constant                    noarch           1.27-2.el7                      ol7_latest            18 k
 perl-libs                        x86_64           4:5.16.3-294.el7_6              ol7_latest           688 k
 perl-macros                      x86_64           4:5.16.3-294.el7_6              ol7_latest            43 k
 perl-parent                      noarch           1:0.225-244.el7                 ol7_latest            12 k
 perl-podlators                   noarch           2.5.1-3.el7                     ol7_latest           111 k
 perl-threads                     x86_64           1.87-4.el7                      ol7_latest            48 k
 perl-threads-shared              x86_64           1.43-6.el7                      ol7_latest            38 k
 vim-common                       x86_64           2:7.4.160-6.el7_6               ol7_latest           5.9 M
 vim-filesystem                   x86_64           2:7.4.160-6.el7_6               ol7_latest           9.8 k

Transaction Summary
==============================================================================================================

Install Oracle JDK 11

Check the Oracle JDK package. A search on jdk will also catch the Open JDK, but at the bottom you will find the Oracle JDKs 11 and 12.

# yum search jdk
abridgement
jdk-11.0.3.x86_64 : Java Platform Standard Edition Development Kit
jdk-12.0.1.x86_64 : Java Platform Standard Edition Development Kit
jdk1.8.x86_64 : Java Platform Standard Edition Development Kit
abridgement

The Oracle JDK is available for commercial use free of charge with OCI. Since JDK 11 is LTS in it, install JDK 11.

yum install -y jdk-11.0.3.x86_64

Java version confirmation

# java --version 
java 11.0.3 2019-04-16 LTS 
Java(TM) SE Runtime Environment 18.9 (build 11.0.3+12-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)

Reference URL

See Yum Repository in OCI https://yum.oracle.com/getting-started.html

Install Java with OCI https://orablogs-jp.blogspot.com/2019/06/how-to-install-oracle-java-in-oracle.html

Recommended Posts

[Oracle Cloud] Install the free Oracle JDK 11 (LTS) on a virtual instance of OCI
[Oracle Cloud] Build a 4-Node RAC environment of Oracle Database 19c with Docker on OCI Compute
Oracle Cloud [OCI]: Create a CentOS Stream instance using Compute's cloud-init
A quick note on using jshell with the official Docker image of the JDK
Install the latest version of Jenkins on Ubuntu 16
How to Install Oracle JDK 1.8 in Ubuntu 18.04 LTS?
Is there a performance difference between Oracle JDK and OpenJDK at the end of 2017?
Installation of Oracle Database XE on CentOS7 (t2.micro instance)
Install Ubuntu MATE 20.04 LTS on older MacBook Early 2008 (MB402 * / A, MB403 * / A, MB404 * / A)
Create a Docker image with the Oracle JDK installed (yum
A note about the seed function of Ruby on Rails
How to install JDK 8 on Windows without using the installer
Comparison of vendors that provide long-term commercial support (LTS) for the JDK (also mentions free use)