Installing the virtualization software
You
can now execute any command that requires elevated privileges without
switching to root, as long as you type sudo before it and supply your
user password (not your root password). You will need to install some
software to allow your machine to act as a host for virtual machines
Start and enable the virtualization service
sudo yum -y install @virtualization
virt-manager libvirt
Start and enable the virtualization service
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
Note that when starting libvirtd you may receive a warning
'virGetHostname: getaddrinfo failed for "Machine Name": Name or service
not known. This will not interfere with your machines.
Reboot your machine (if you have not already as part of the installation process). If you do not, you will not be able to install any virtual machines. Start the graphical virtual machine manager. You will need to enter your root password.
Create your own virtual network
Reboot your machine (if you have not already as part of the installation process). If you do not, you will not be able to install any virtual machines. Start the graphical virtual machine manager. You will need to enter your root password.
Create your own virtual network
- Right click 'localhost (QEMU)' and select 'Details'. Click on the 'Virtual Networks' tab.
- Stop and delete the 'default' network.
- Use the plus sign to add a new virtual network using the following options.
- Name your virtual network 'centos7'
- Use the network address space as you want . Example, if you were want 11, the network address would be 192.168.11.0/24.
- Ensure the DHCP range will allow you to assign at least 3 static IP addresses outside it.
- Choose 'Forwarding to physical network' radio button, 'Destination: Any physical device' and 'Mode: NAT'
- Ensure the network is started at boot.
- Once completed open a terminal and observe and record the output of the following command:
iptables -t nat -L
Installing a Virtual Machine
With the virtualization software installed and your personal network
created, you are now ready to create your first virtual machine. Use
your Centos 7 installation dvd (or alternately you can copy the ISO
image to your hard drive and install from that). The later option will
result in a slightly faster install.
Installation
- Click on the icon "Create a new virtual machine" to begin.
- Name your machine "centos1" and choose your installation method - "Local install media". Choose the desired option to install from either the CD or iso. For "OS type" select "Linux" and for Version select "Red Hat Enterprise 6" then click on the "Forward" button.
- Use the default memory and CPU options for use with lab computers (Depending on available hardware these settings can be adjusted). Then click on the "Forward" button to proceed.
- Leave the disk image size set at 8GB, ensure "Allocate entire disk now" is checked, then click on the "Forward" button.
- At the "Ready to begin installation" window click on 'Advanced options' arrow to review available options.
- Select the Virtual Network named 'centos7'. Make note of any other available options .
- Select 'Install to Hard Drive' to begin your Centos installation. Select the appropriate default options ). The installation process should be identical to what you chose on the host, with the exception of the hostname.
- During installation you will be prompted to set the root password and an initial user account. For the initial user, enter the same information you entered on your host machine.
- Set your hostname to "centos1".
First Boot
- You may notice that graphical windows are not being displayed properly. The following steps will resolve this.
- At the first opportunity, shut the VM down. If you perform these steps while the machine is running it will claim they will be applied the next time the machine boots, but that does not work.
- While the VM is off, click on 'View' (from the menu at the top of the VM window), and select 'Details'.
- From the menu on the left side, select 'Video'.
- Change the drop-down list for Model from 'Cirrus' to 'vga', and click apply.
- Switch the view back to 'Console' and start the machine again.
- Ensure your machine has a network connection by running the command
host cbc.ca
If that did not work, edit the line in /etc/sysconfig/network-scripts/ifcfg-eth0
onboot=no
should be
onboot=yes
- If you had to change that, bring the interface down and back up again
sudo ifdown eth0; sudo ifup eth0
- Once you have a working connection update your machine (this may take a while -- while you are waiting it is probably a good idea to update your host as well).
sudo yum -y update
- Reboot the virtual machine once it is updated.
- If your virtual machine hangs on boot, you will need to change a graphics option:
- While the VM is off, click on 'View' (from the menu at the top of the VM window), and select 'Details'.
- From the menu on the left side, select 'Display'.
- Change the drop-down list for Type from 'VNC' to 'Spice', and click apply.
- Switch the view back to 'Console' and start the machine again.
- Now run the following commands and note the output. Note how they differ from the Centos installation on your host.
df -hT
cat /etc/fstab
cat /etc/issue
uname -a
Cloning a Virtual Machine
- Now that you have one virtual machine working, you will create two more. If you struggled with the previous steps, repeat them to create two more virtual machines (naming them centos2 and centos3, with hostnames centos2 and centos3 respectively).
- If you are confident with what you have done so far, you may clone your existing machine to create the others.
- To quickly create additional VM's shutdown 'centos1', right click and select 'Clone...'. Use the following options:
- Name: centos2
- Storage:
- Click the drop down menu below 'centos1.img', choose details and rename the image to the centos2.img
- Once successfully created boot the new VM and correct the host name. This can be done using the GUI or command line.
- Record in your notes how each is done.
- Check for connectivity.
host cbc.ca
- After creating centos2 repeat the above steps to create centos3 and correct the host name.
Backing up your Virtual Machines
You are responsible for backing up your virtual machines on a regular basis. It is good practice to copy your back ups to a separate location (like a USB Flash Drive) once completed, so in the event your drive becomes damaged to the point that you can't access them all you need do is reinstall the host and restore your back ups. i will upload info how to back up VMs in my next blogthank you
No comments:
Post a Comment