OCI Lab 1 Compute VM - Create Oracle Linux Server
OCI Lab 1 Compute VM - Create Oracle Linux Server
2. Click Download
4. Open the folder where the file is saved from step 3, and then click the executable file to install
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
To connect a GUI session on our Compute VM Oracle Linux Instance we will require Real VNC Viewer
This task will take approximately 10 minutes to complete
4. Open the folder you have saved the file in and click the executable to install
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
2
Section 2: Create secure Public/Private Key authentication
If you already have a public private key set, you may skip this section
3. You will be Prompted for a Passphrase (or hit enter for blank)
4. You will be Prompted to repeat the Passphrase (or hit enter for blank)
a. If you entered a Passphrase, be sure to make note of it
5. You will be Prompted for path (or hit enter for default)
a. Default path is c:\users\username\.ssh\
b. 2 files will be created:
i. id_rsa (private key)
ii. id_rsa.pub (public key)
c. Make a note of where these files are located
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
3
Section 3: Create an Always Free Compute Instance with Oracle Linux 7
This task will take approximately 10 minutes to complete. You can create/own 2 (two) Always Free Instances.
1. Sign into your Oracle Cloud Tenancy
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
4
3. Accept defaults for:
a. Placement
c. Networking
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
5
4. Add SSH keys:
b. Drag id_rsa.pub that you saved in Section 2, Step 5 into the “Drop .pub files here”
5. Click “Create”
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
6
6. Your new Compute VM Instance will now be created
b. When completed with Provisioning, you will see your Compute Instance in green (Running)
c. Once provisioned, take note of the public IP address assigned to your Instance
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
7
Section 4: Connect to the Compute VM Instance
This task will take approximately 5 minutes to complete.
1. Open a Git Bash Terminal window
Note: You can have multiple Git Bash Terminal windows open
2. Execute the following command using your public IP address (from Section 3, Step 6c) to SSH Connect to your Compute VM Instance:
ssh opc@public IP address
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
8
3. If prompted to continue, enter “yes”
If you entered a Passphrase in Section 2 (Steps 3 and 4), you will be prompted to enter it here
The first time you connect, you will see a message that the new IP address has been added to a list of known hosts.
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
9
Section 5: Install JDK 8
To Install JDK 8 follow these steps:
1. In the Git Bash terminal window execute the following command to install the latest version of the repository:
sudo yum install -y --enablerepo=ol7_ociyum_config oci-included-release-el7
2. Once step 1 is completed, execute the following command to list the available JDK versions:
yum list jdk*
Note: As of this writing, the repository contains Oracle Java 8, 11,12,13, 14, 15, 16
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
10
3. To install Oracle Java 8, version 1.8.0 Execute the following command
sudo yum install jdk1.8.x86_64
Follow the on-screen instructions to download and install. If prompted to accept download size – type y.
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
11
4. To confirm the Java version, execute the following command
java -version
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
12
Section 6: Create, Compile and Run a Java Program
1. Create a new folder in your user directory (opc) by entering the command:
mkdir java
3. To start the vi editor and open a .java file, enter the command
vi HelloWorld.java
4. To begin editing the file, enter Insert Mode by typing the letter “i”
i
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
13
9. To compile the .java program, enter the command
javac HelloWorld.java
11. You should see Hello, World! displayed in the command line like below:
Copyright © 2021, Oracle and/or its affiliates. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
14