Hello and welcome to this presentation about creating KVM Guest from an Oracle Linux KVM
Host for Oracle Cloud Infrastructure.
For our objectives today, after viewing this video, you should be able to:
Describe the steps needed to create a KVM guest from an Oracle Linux KVM host on Oracle
Cloud Infrastructure Use the oci-kvm utility to create and destroy
a KVM guest And use the virsh utility to manage KVM guest
domains This slide shows a KVM host instance created
from the KVM image that we will use in the demonstration portion of this video.
View the "Use Oracle Linux KVM Image" video at www.oracle.com/goto/linuxcloudlearning
to see how this KVM host instance was created.
The KVM host uses virtlib so it is useful to know virt-install and virsh commands and
options to create KVM guests.
The image also includes the oci-kvm utility for virtualization management.
You use the oci-kvm utility to create and destroy KVM domains or guests in the host.
The oci-kvm utility works in coordination with oci-utils utility to manage block storage
and network resources for KVM guests.
This slide provides the syntax for the oci-kvm create command, and the oci-kvm destroy command.
The oci-kvm utility that is included in the image is a wrapper for virt-install.
This utility requires you to specify a domain name and optionally a disk or IP address along
with all other virt-install arguments.
When you are done with a KVM guests, use the virsh destroy command and follow up with the
oci-kvm utility command to destroy the domain or guests.
Automation with oci-kvm works with oci-utils to assign storage and network resources on
creation and to free up resources when the KVM guest is destroyed.
Now we'll begin the demonstration portion of this video.
I’m going to switch to a terminal window.
I’m already logged in to our KVM-host-192.
First we’ll look at attached storage using the sudo oci-iscsi-config -s.
At the bottom of this output we see sda, this is our boot device.
This was created with the instance and configured as it would be for any other instance created
using the console defaults for the boot device.
If I scroll up, you’ll see our utility device is sdb.
It’s a 50 Gig device.
This is one of the attached block volumes.
And this is the one that holds the ISO image for the operating system for the KVM guest.
And then sdc is not currently mounted.
It is available to be used for KVM guests.
I’ll clear the screen and I’ll run ls /u01/stage/iso.
And here you can see the output is V980739-01.iso.
This is Oracle Linux release 7 update 6 for x86 ISO file that I downloaded from edelivery.oracle.com
and I staged in this directory.
We’ll use this /u01/stage/iso location when we create the guest.
Next we’ll look at the network interfaces.
We’ll run a command sudo oci-network-config –s.
If we scroll up here, we’ll see the two attached vnics.
This was the primary with and address of .25 and this was the secondary.
And this is the one that will be available for KVM guests.
And then I’ve prepared the command that we’re going to run and stored it into a
file.
We’ll run this command but you run this as root so it’s sudo then oci-kvm create
and then the name of the domain or guest.
After –V, these are all the virt-install arguments for our KVM guest.
You can see the location here.
This argument, /u01/stage/iso, and then the name of the file, this is our ISO image for
the operating system that will be installed on this KVM guest.
It happens to be Oracle Linux 7 Update 6.
So I’ll just copy this command into the buffer and then I’ll just paste it.
And we’ll run this command.
As soon as I hit ENTER, you see that the IP address is assigned.
This is the address of the secondary vnic on the KVM host.
When the system prompt returns we can run the virsh console kvmguest01 command.
And within a few seconds we get the terminal interface for configuring the Linux operating
system.
So from here we’ll choose the installation destination option 5.
Ensure that option 1, the 50 Gig vda disk, is selected and we’ll press c to continue.
And now we’ll select option 1 to replace existing Linux systems and press c to continue.
We’re going to leave the LVM option 3.
So we’ll press c to continue.
We’ll select to set the time zone so I’ll select 2 and then I’ll enter 1 to set the
time zone.
And I’m going to choose 3 for America.
And then I’m going to hit ENTER until all the locations have been displayed.
And I‘m going to choose 45 for Denver, or US Mountain Time which is where I am.
And then we can set the root password so I’ll enter option 8.
And I’m just going to give it a simple password, and confirm.
And then I get the warning that the password is weak but for this purpose I’ll go ahead
and take that and I’ll enter yes.
And then I’ll press b to begin the installation.
The console displays messages while the installation continues.
This process takes about 5 minutes so I'll fast forward through this.
The installation is complete.
I’ll press RETURN.
We get a few more messages.
Now I can run virsh console and then the name of the domain or guest, kvmguest01.
And initially you’ll see that the domain is not running.
If I run the command virsh –c qemu:///system list --all.
You can see that the state is shut off.
So we’ll start this up by using virsh start kvmguest01.
If I run that command again, you can see that it’s running.
I can run my console command again.
You get a few more messages.
Now I get a login prompt.
So I can login as root, give it the password that I provided and now I’m in to the KVM
guest.
I can run df –h.
You see this is the block volume that was provided for storage.
I can run ip addr and you can see the network interface that was a secondary vnic on the
KVM host.
Note the MAC address there, 94:3f.
I’ll type exit to logoff the host and then control right square bracket to close that.
Just want to run a few more commands here.
If I run virsh domblklist kvmguest01.
You can see there’s the device that was allocated for the KVM guest.
If I run virsh iface-list, you can see that this is the MAC address that we saw up here,
94:3f.
I will finish this demonstration by destroying the domain.
First we use virsh to destroy the KVM guest.
I’ll type the command virsh destroy kvmguest01.
And then we use the oci-kvm utility with the destroy command –D and then the name of
the domain or the guest.
And now the block volume that was attached to the KVM host has been released and is freed
up to be used by other KVM guests.
The secondary vnic that was attached to KVM host has been released as well and now is
available for a new KVM guest.
Oracle provides an extensive number of resources which you can use to learn more about this
subject and others.
Look for additional videos on the Oracle Linux KVM image on the Oracle Linux Learning Library.
And see the education.oracle.com links for comprehensive Oracle Linux curriculum available
to support a full range of Linux administration skills for cloud, on-premise and hybrid users.
This concludes this presentation.
Thank you for watching.