You are on page 1of 31

OCI Quick Start (VCN, Compute and Block

Volume)
Table of Contents
Overview

Pre-Requisites

Sign in to OCI Console and create VCN

Creat ssh keys, compute instance and Block Volume. Attach block volume to compute instance

Install httpd on compute instance and install an app on Block Volume

Detach the block volume and launch second compute instance using boot volume and attach Block Volume

Delete the resources

Appendix A: ISCSI Method to Attach Block Volume to Compute Instance

Appendix B: ISCSI Method to Detach block volume

Overview
In this lab we will create a compute instance, install httpd server on it, attach block volume to it and install an app on
the Block Volume We will then create a second compute instance using the boot volume of the first compute instance
and move the Block Volume to the second compute instance (with the app installed). The goal of the lab is to
demonstrate launching VCN, Compute Instance, using Boot volume of compute instance and how easy it is to move
additional storage with applicatons/tools installed between compute instances

Some Key points;

We recommend using Chrome or Edge as the broswer. Also set your browser zoom to 80%

All screen shots are examples ONLY. Screen shots can be enlarged by Clicking on them
Login credentials are provided later in the guide (scroll down). Every User MUST keep these credentials handy.

Do NOT use compartment name and other data from screen shots.Only use data(including compartment name)
provided in the content section of the lab

Mac OS Users should use ctrl+C / ctrl+V to copy and paste inside the OCI Console

Login credentials are provided later in the guide (scroll down). Every User MUST keep these credentials handy.

Cloud Tenant Name User Name Password Compartment Name (Provided Later)

Note: OCI UI is being updated thus some screenshots in the instructions might be different than actual UI

Pre-Requisites
Oracle Cloud Infrastructure account credentials (User, Password, Tenant, and Compartment)

1.
OCI Training : https://cloud.oracle.com/en_US/iaas/training

2.
Familiarity with OCI console: https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Concepts/console.htm

3.
Overview of Networking: https://docs.us-phoenix-1.oraclecloud.com/Content/Network/Concepts/overview.htm

4.
Familiarity with Compartment: https://docs.us-phoenix-1.oraclecloud.com/Content/GSG/Concepts/concepts.htm

5.
Connecting to a compute instance:
https://docs.us-phoenix-1.oraclecloud.com/Content/Compute/Tasks/accessinginstance.htm

6.

Sign in to OCI Console and create VCN


Tenant Name: OCISPL54

User Name: angelfreiredba6642

Password: Effortless69#

Compartment:TL-OCISPL54-33

Sign in using your tenant name, user name and password. Use the login option under Oracle Cloud Infrastructure

From the OCI Services menu,click Virtual Cloud Network under Networking and click Create Virtual Cloud Network

1.
Select the compartment assigned to you from drop down menu on left part of the screen

2.

NOTE: Ensure the correct Compartment is selected under COMPARTMENT list


Fill out the dialog box:

1.
Create in Compartment: Has the correct compartment

2.
Name: Enter easy to re¬member name

3.
Create Virtual Cloud Network Plus Related Resources: Select this option.
4.
Click Create Virtual Cloud Network

5.
Click Close

6.

1. We will open port 80 on this VCN to provide http access to app on the compute instance(to be installed later on.
Click Security List2. and then Default Security list for
1. In Security list details page, Click Edit All Rules2. and Click +Another Ingress Rule3. under Allow Rules for
Ingress and add below rule:
Make sure STATELESS Flag in un-checked
SOURCE TYPE:4. CIDR
SOURCE CIDR:5. 0.0.0.0/0
IP PROTOCOL:6. TCP
SOURCE PORT RANGE:7. ALL
DESTINATION PORT RANGE:8. 80
1. Click Save Security List Rules2. at the bottom

Creat ssh keys, compute instance and Block Volume.


Attach block volume to compute instance
1. Click the Apps icon in the toolbar and select Git-Bash to open a terminal window.

1. Enter command
ssh-keygen

HINT:2. You can swap between OCI window, git-bash sessions and any other application (Notepad, etc.) by clicking
the Switch Window icon
1. Press Enter When asked for 'Enter File in which to save the key', 'Created Directory, 'Enter passphrase', and 'Enter
Passphrase again.

1. You should now have the Public and Private keys:

/C/Users/ PhotonUser/.ssh/id_rsa (Private Key)

/C/Users/PhotonUser/.ssh/id_rsa.pub (Public Key)

NOTE: id_rsa.pub will be used to create Compute instance and id_rsa to connect via SSH into compute instance.
HINT: Enter command

cd /C/Users/PhotonUser/.ssh (No Spaces)

and then

ls

to verify the two files exist.

1. In git-bash Enter command


cat /C/Users/PhotonUser/.ssh/id_rsa.pub

2. , highlight the key and copy

1. Click the apps icon, launch notepad and paste the key in Notepad (as backup)
Switch to the OCI console. From OCI servies menu, Click Instances under Compute

1.
Click Create Instance. Fill out the dialog box:

2.
Name: Enter a name

3.
Availability Domain: Select availability domain

4.
Image Operating System: For the image, we recommend using the Latest Oracle Linux available.

5.
Choose Instance Type: Select Virtual Machine

6.
Choose Instance Shape: Select VM shape

7.
Configure Boot Volume: Leave the default

8.
Add SSH Keys: Choose 'Paste SSH Keys' and paste the Public Key saved earlier.

9.
Virtual Cloud Network Compartment: Choose your compartment

10.
Virtual Cloud Network: Select the VCN you created in the previous section.

11.
Subnet Compartment: Choose your compartment.

12.
Subnet: Choose the first Subnet

13.
Click Create

14.

NOTE: If 'Service limit' error is displayed choose a different shape such as VM.Standard.E2.2 OR VM.Standard2.2 OR
choose a different AD

Wait for Instance to be in Running state. In git-bash Enter Command:


1.
cd /C/Users/PhotonUser/.ssh

Enter ls and verify id_rsa file exists

2.
Enter command

3.
ssh -i id_rsa_user opc@<PUBLIC_IP_OF_COMPUTE>

HINT: If 'Permission denied error' is seen, ensure you are using '-i' in the ssh command. You MUST type the command,
do NOT copy and paste ssh command

1. Enter 'Yes' when prompted for security message

Verify opc@ appears on the prompt

1.
From OCI services menu Click Block Volumes under Block Storage, then Click Create Block Volume.

2.
Fill out the dialog box:
3.
Create in Compartment: Has the correct compartment selected.

4.
Name: Enter a name for the block volume (e.g. "block_vm).

5.
Availability Domain: Select the first available domain (must be same as Compute).

6.
SIZE: Set to 50

7.
BACKUP POLICY:þÿ Set to None (If this field shows Error Retrieving Value then leave it as is)

8.
Click Create Block Volume. Wait for volume to become available. Wait for Block Volume state to change from
'Provisioning' to 'Available'

9.

Attach Block volume to your compute instance. From OCI services menu Click Instance under Compute

1.
For the compute instance created earlier click Action item. Click Attach Block Volume.

2.

1. Fill out the dialog box:


2. Choose how you want to attach your block volume:Check Paravirtualized

NOTE: We can also use ISCSI mode, in which case we will not have to use ISCSI commands as detailed later on. For
more information please refer to ;
https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/overview.htm#attachtype OR refer Appendix section
at the end of the lab.

BLOCK VOLUME COMPARTMENT: Ensure correct compartment is selected

Block Volume: Choose the volume created earlire

Access: Choose READ/WRITE

Click Attach.

Click Close.

We now have a block volume created and attached to the Compute instance.
1. Verify the Block Volume is attached by clicking the Compute Instance name.

Install httpd on compute instance and install an app on


Block Volume
1. Switch to ssh session to compute install. Install httpd server, Enter Command:
sudo yum -y install httpd

2. Configure Compute instance firewall, Enter commands:


sudo firewall-cmd --permanent --add-port=80/tcp `

3. (Open port 80 on the firewall to allow http and https traffic).

NOTE: Despite the line wrapping, the --add-port flag has no spaces.

sudo firewall-cmd --reload

(Reload the firewall to activate the rules).

Start httpd, Enter command:

1.
sudo systemctl start httpd

Enter commad lsblk to verify the Block volume storage is initialized. This could be sda, sdb or somethig else strting
with 'sd'. In below example this volume is called sdb. Below screen shot shows a 1 TB volume though in this lab we
have created a 50GB volume thus the size in your compute instance will be 50GB.

2.

HINT: The Name sdb is the block volume storage. This name could change for your specific attachment (i.e sdc)

To format the block volume, Enter Command:

1.
sudo fdisk /dev/<VOLUME_NAME> -l

For example sudo fdisk /dev/sdb -lWait for formatting to complete

2.
Create a file system on the block volume, Enter Command:

3.
sudo mkfs.ext4 -L datapartition /dev/<VOLUME_NAME>

This will create the file system on the entire disk. Enter y when prompted with 'Proceed anyway'

NOTE: For this lab we will not be creating additional partitions

Create a directory where the disk will be mounted,Enter commands:


1.
sudo mkdir -p /mnt/www/html

Mount the disk to the newly created directory, Enter command:

2.
sudo mount /dev/<VOLUME_NAME> /mnt/www/html

Verify /dev/ volume is now mounted to /mnt/www/html directory, Enter command

3.
lsblk

(in this case the volume is called sdc)

4.

Next we will download an app and install it. Enter command:

1.
cd /home/opc

Enter Command:

2.
wget https://github.com/snafuz/oci-quickstart-lab/archive/master.zip

Enter Command:

3.
unzip master.zip

Enter Command:

4.
sudo cp -R oci-quickstart-lab-master/static/* /mnt/www/html/

Modify httpd.conf file, Enter Command:

5.
sudo vi /etc/httpd/conf/httpd.conf (for vi)

OR

6.
sudo nano /etc/httpd/conf/httpd.conf (for nano)

NOTE: in vi you can save the file after modification by using Esc :wq

1. Search for string /var/www and replace it with /mnt/www/html . This will be done in 3 locations
Save and Exit (in vi user Esc :wq)

1.
Enter command:

2.
sudo chcon -R --type=httpd_sys_rw_content_t /mnt

Restart httpd server, Enter command:

3.
sudo systemctl restart httpd

Launch a web browser and Enter compute Instance's public IP:

4.
http://<COMPUTE_INSTANCE_PUBLIC_IP>

Screen like below should appear.

5.
We have initialized httpd.conf file. Next we will create a second compute instance using the boot volume of
the first compute instance and attach Block Volume to it

Detach the block volume and launch second compute


instance using boot volume and attach Block Volume
In this section we will detach the block volume, Stop the compute instance, use its boot volume to launch a
second compute instnace and delete the second compute instance

1. In ssh session to the compute instance unmount the directory from block volume, Enter command:
sudo umount /dev/<VOLUME_NAME>

2. In OCI console window, click your compute instance name and in Attached Block Volume3. section click the action
icon and click Detach
1. Stop your compute instance by Clicking Stop2. in compute instance details page and then OK3. in Confirm window

1. Once the instance is in Stopped state, click Boot Volume2. , Click action icon and click Detach3. . Click OK4. in
Confirm window.
Once the Boot volume is detached, Click Terminate to Terminate the instance.

1.
Click the action icon, click View Boot Volume Details.

2.

1. In the Boot Volume Details window click Create Instance:


Name:2. Enter a name (e.g. "boot volume instance").
Availability Domain:3. Make sure its same AD as where the block volume was created
NOTE : Boot Volume field is set to BOOT VOLUME and to the boot volume you detached from the original Instance.

Intance Type: Select Virtual Machine


Instance Shape: Choose the shape with least OCPU
SSH Keys:þÿ Choose Paste SSH Keys and paste the Public Key saved earlier.
Virtual Cloud Network Compartment: Select yor compartment
Virtual Cloud Network: Select the VCN created earlier
Subnet compartment: Select yor compartment
Subnet: Select the Public subnet.
Click Create Instance.

NOTE: If 'Service limit' error is displayed choose a different shape such as VM.Standard.E2.2 OR VM.Standard2.2 OR
Choose a different AD
Once the instance is in Running state, attach the block volume to this new instance using OCI Console.Ensure to use
Paravirtualized mode.

1.
Mount the block volume as before, Enter Command:

2.
sudo mount /dev/<VOLUME_NAME> /mnt/www/html

Restart httpd, Enter command

3.
sudo systemctl restart httpd

Launch a web browser and Enter compute Instance's public IP, http://

4.
Screen like below should appear, Enter the required information

5.
We have now successfully launched a compute instance using another instance's boot volume and
re-attached a block volume that was attached to another instance. The block volume preserved all the data on
it during this process. Moreover the compute instance launched using the boot volume had httpd server and
fire wall configuration already present

Delete the resources


Switch to OCI console window

1.
If your Compute instance is not displayed, From OCI services menu Click Instances under Compute

2.
Locate first compute instance, Click Action icon and then Terminat

3.
1. Make sure Permanently delete the attached Boot Volume is checked, Click Terminate Instance. Wait for instance to
fully Terminate

From OCI services menu Click Block Volumes under Block Storage

1.
Find the storage block volume you created.

2.
HINT: If multiple storage block volumes are listed, scroll down to find the one you created.

Click the Action icon and select Terminate

1.
Click OK in the confirmation window.

2.

From OCI services menu Click Virtual Cloud Networks under Networking, list of all VCNs will appear.

1.
Locate your VCN , Click Action icon and then Terminate. Click Delete All in the Confirmation window. Click Close
once VCN is deleted

2.
1. From OCI services menu Click Networking2. , then Public IPs3. ,locate the Reserved Public IP you created. Click
Action icon and then Terminate

*Congratulations! You have successfully completed the lab. *

Appendix A: ISCSI Method to Attach Block Volume to


Compute Instance
1. Click Action icon for the Block Volume, then ISCSI Commands & Information
NOTE: The iSCSI Commands and Information dialog box displays specific identifying information about your volume
and the iSCSI commands you'll need. The commands are ready to use with the appropriate information included. You
can copy and paste the commands into your instance once you login.

1. Click Copy2. in ATTACH COMMANDS3. section.

Click Close to close the window

1.
In OCI Console Window, click the Apps icon and click Notepad.
2.

HINT: You can swap between the OCI window and any other application (Notepad etc.) by clicking the Switch Window
icon

1. Paste the ISCSI commands in Notepad using your mouse/touch pad or Ctrl v.

To attach ssh to the compute instance and paste the ISCSI commands copied earlier

Appendix B: ISCSI Method to Detach block volume


Click Action icon for the Block Volume, then ISCSI Commands & Information

1.
Click Copy in DETACH COMMANDS section.

2.

Paste the detach command in the ssh session to the compute instance

1.
In OCI console window, click your compute instance name and in Attached Block Volumes section click the action
icon and click Detach

2.

You might also like