Changes

Jump to: navigation, search

OPS235 Lab 2 - CentOS7 - VMware

4,632 bytes removed, 18:18, 22 May 2016
no edit summary
== Purpose / Objectives of Lab2==
[[Image:hostmachinevmware-1.png|thumb|right|300px550px|The c7host centos1 Linux server will run virtualization software to install and run 3 virtual machines (installed in lab2). ]]
'''In this lab, you will create three additional virtual machines'''. This also gives you an opportunity to experiment with different ways of installing CentOSLinux virtual machines.
<br><br>
<u>Main Objectives</u>
* '''Installing Virtualization Software''' on your '''c7host''' machine
* '''Create 3 separate VMs (virtual machines) using different installation methods:'''
:* Centos Live DVDInstallation
:* Network Centos Installation without configuration file:* Network Centos Installation with configuration file (Kickstart)
* Understand the '''advantages and disadvantages of each type of installation''', and be able to '''select the best installation method''' for a particular situation.
* '''Manipulate virtual machines by CLI''' (virsh)
* '''Properly backup VMs and VM configuration''' in virtual manager application onto home directory and to external source (USB Key)
* Observe how '''Bash Shell Scripting''' can be used to automate routine tasks involving VM management
 
 
== What is a Virtual Machine?==
 
A '''virtual machine''' is a software simulation of a computer which can be used as though it were actual hardware. It's possible to run multiple virtual machines on one computer, reducing hardware requirements and promoting flexibility when working with multiple operating systems. Some common uses of virtualization include:
 
:* '''Software testing''' -- Using multiple operating systems simultaneously on a single computer for testing and experimentation.
:* '''Network simulation''' -- Testing network services, protocols, and security scenarios with a small number of computers.
:* '''Isolation''' -- Protecting multiple sets of data by storing them on multiple virtual machines. If one of the virtual machines is compromised, the data on other virtual machines is still protected.
:* '''Server consolidation''' -- Reducing the number of physical servers in a network by moving physical machines to virtual machines. This saves hardware, administration, cooling, and electricity costs, and it can increase the utilization of hardware (by ensuring that the hardware is not under-loaded).
:* '''Load-balancing and disaster recovery''' -- It is possible to migrate virtual machines between different physical machines, to ensure that a workload is balanced across multiple computers, to allow routine hardware maintenance and upgrading, and to compensate for hardware failure or other disasters.
|- valign="top"
|width="10%" | [[Image:harddrive.png|thumb|left|85px|<b>Removable Hard Disk Pack</b> (SATA)]]
|width="10%" |[[Image:ubs-key.png|thumb|left|85px|<b>USB key</b><br>(for backups)]]
|- valign="top"
|width="20%" |<u>Virtualization:</u>
[http://linux.die.net/man/1/virt-manager virt-manager]x<br>[http://linux.die.net/man/1/virsh virsh]x
|width="20%" |<u>Commands</u>
[http://unixhelp.ed.ac.uk/CGI/man-cgi?gzip gzip, gunzip]<br>
'''Record VM Installation in Lab2 (Installation Comparison Chart):'''
You will be learning to perform several different type of CENTOS Linux installs. Lab2 already has an empty table for comparing various Linux installs. You were required in lab1 to record your observation for your '''c7hostcentos1''' installation.
As you proceed throughout this lab, you will be required to fill in the comparison chart for three of the VMs (virtual machines) that you will be installing.
 
 
'''Complete the following steps to install and run the virtual manager application:'''
 
 
# Open a web-browser, and open the OPS235 Lab #2 WIKI.
# Open a shell terminal.<br><br>'''WARNING:''' You must perform a '''yum update''' on your '''c7host''' machine before proceeding with the next steps.<br><br>
# You will need to download an image file for the Centos7 LIVE DVD by issuing the following command (best works while at Seneca):<br><b><code><span style="color:#3366CC;font-size:1.2em;">wget http://belmont.senecac.on.ca/centos/7/isos/x86_64/CentOS-7-x86_64-LiveGNOME-1511.iso</span></code></b><br><br>
# Install the virtualization software by issuing the command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python \<br>python-virtinst libvirt-client virt-install virt-viewer bridge-utils</span></code></b> <br><br>
 
{{Admon/important|Restart your Host Machine|You must restart your '''c7host''' machine after installing the virtualization program above. If you fail to do this, you may experience virtualization network problems!}}
 
 
::This will install many applications (including):
:::* '''kvm/qemu''' - the hypervisor and other hardware emulation systems.
:::* A system service named '''libvirtd''' that manages the VMs.
:::* A graphical tool for managing virtual machines ('''virt-manager''') and the '''virsh''' command-line tool.<br><br>
<ol>
<li value="5">Start the virtualization service: <b><code><span style="color:#3366CC;font-size:1.2em;">service libvirtd start</span></code></b></li>
<li>The firewall configuration is altered by the addition of the virtualization software. Centos7 uses firewalld for firewall, but we will be switching back to using iptables. Issue the following series of command to install iptables and restart the firewall:<br><br> <b><code><span style="color:#3366CC;font-size:1.2em;">systemctl stop firewalld</span></code></b><br><b><code><span style="color:#3366CC;font-size:1.2em;">systemctl mask firewalld</span></code></b><br><b><code><span style="color:#3366CC;font-size:1.2em;">yum install iptables-services</span></code></b><br><b><code><span style="color:#3366CC;font-size:1.2em;">systemctl enable iptables</span></code></b><br><b><code><span style="color:#3366CC;font-size:1.2em;">systemctl start iptables</span></code></b><br><b><code><span style="color:#3366CC;font-size:1.2em;">service iptables save</span></code></b><br><br></li>
</ol>
{| width="40%" align="right" cellpadding="10"
|- valign="top"
|colspan="2"|{{Admon/important|Run virt-manager as a regular user, not as root|Otherwise all your virtual machines will be owned by root and you won't be able to use them as a regular user.}}
 
|}
<ol>
<li value="7">Start the graphical tool by selecting the menu options '''Applications'''>'''System Tools'''>'''Virtual Machine Manager''' or by typing the command<b><code><span style="color:#3366CC;font-size:1.2em;"> virt-manager</span></code></b></li>
</ol>
 
 
 
{{Admon/important|Restart your Host Machine Again|You must restart your '''c7hostcentos1''' machine again, prior to creating your virtual machines. If you fail to do this, you may experience virtualization network problems!}}
:'''VM Details:'''
# '''Step 3 of 5:''' Set the memory to '''2048 MB''' and the number of CPUs to '''1'''
[[Image:vm-path.png|thumb|right|300px|It is extremely important to '''correctly specify the VM image file path-name'''. Double-check the spelling of the path-name before proceeding!]]
<ol><li value="7">'''Step 4 of 5:''' This next step creates a disk file that will be used to simulate the virtual machine's disk drive. Select a size of '''10 GB'''. Click on<br> '''Select managed or other existing storage''' and type the VM image file pathame:<br> '''/var/lib/libvirt/images/centos1.img''' (make certain that the pathname is correct) and then click '''Forward''' to proceed.</li><li>'''Step 5 of 5:''' Enter the virtual machine name: '''centos1'''. Review the VM information, and click '''Finish'''.<br><br></li><li>'''The virtual machine will now start''' - start timing your installation and making notes for '''centos1''' virtual machine in the installation comparison chart in lab2 logbook. The virtual machine is running from the live disc at this point, and no software has been installed on the ''hard drive'' of the virtual machine. The point of a live disk is to allow you to test the distribution to see whether you like it without installing to the hard-drive first.</li><li>Double-click '''Install to Hard Drive'''. The installation program, similar to the one used when installing CentOS in Lab 1, will appear. You basically perform the same installation operations for this VM including for '''Date & Time''', '''Network & Hostname''', and '''Installation Destination'''. Make certain to use the '''hostname''': '''<u>centos1</u>''' as opposed to ''c7hostcentos1'') for this installation. (with a few slight differences).</li><li>For '''Installation Destination''', select the destination option: '''I will configure partitioning''' and then click '''Done'''. Make certain that the '''Partition Scheme''' is set to '''LVM''' and then click on the link: '''Click to Create Automatically'''. '''Done'''. Check to make certain that the root partition has file system type: '''ext4'''.</li><li>Accept the changes and then click '''Begin Installation'''.<ol type="a"><li>You will be required to make selections very similar to what you did in lab1.</li><li>While the system is installing, take a few minutes to record your observations (including slight differences with centos1 install as opposed to c7host centos1 install).</li><li>When the installation process is complete, note the time required to install this system and record in the installation comparison chart of your lab2 logbook.<br><br></li></ol></li><li>Power-off your Centos7 LIVE system.</li><li>You should notice that the Centos7 boot menu appears. Either press '''ENTER''' to start or wait for it to start automatically.</li><li>Finish the final steps in the setup process (like you did in lab1).</li><li>#You may want to turn off the screen-saver (like you did in Lab1): [http://zenit.senecac.on.ca/wiki/index.php/OPS235_Lab_1_-_CentOS7#Customizing_Your_Account How to Turn-off Screen Saver (lab1)]</li></ol>
{| width="40%" align="right" cellpadding="10"
|- valign="top"
# Create the VM (called '''centos2''') as you did with the ''c7hostcentos1'' machine, except for the following differences:<br><br><ol type="a"><li>Select '''Network Installation''' using the installation source URL displayed above.</li><li>When customizing your partitions, do the same operation that you did in centos1, but after automatically creating the partitions, reduce the size of the root LVM partition to '''8000 MB''' and add an LVM partition with a size of '''2000 MB''' (mount point: '''/home''', name: '''home''', and make certain root and /home partitions have '''ext4''' file system).</li><li>Don't forget to install the GNOME desktop here as you will need a GUI for Centos2<br><br></li></ol>
# Complete the installation. Login to your regular user account, and perform a yum update for the centos2 VM (reboot if required). Make certain to adjust your screen-saver settings if desired.
# Repeat the steps as you did to '''start the SSH service''', '''set iptables to accept connections via ssh''', '''test connections between centos2 and c7hostcentos1''', and '''disable SELinux''' (refer to lab1).
# Record the time taken to install, and compare this to the time taken by the previous installations. Record your findings in the Installation Comparison chart in lab2 logbook.
# Take a look at the kickstart file (eg. view url in a webj-browser) to determine the root password as well as the name and password for the first user account!
# Boot the virtual machine and log in (use the user ID and password information from the previous step). Compare the experience to the first time you booted the other virtual machines. Record this information in the '''table contained in Investigation 4'''.
# Repeat the steps as you did to '''start the SSH service''', '''set iptables to accept connections via ssh''', '''test connections between centos3 and c7hostcentos1''', and '''disable SELinux''' (refer to lab1).
# Remember that centos3 is text-based interface only (no graphics). To recover from a blank screen, press a key (like the SPACE key) to return to the screen display.
# Record the time taken to install, and compare this to the time taken by the previous installations. Record your findings in the Installation Comparison chart in lab2 logbook.
|}
# Start the '''centos1''' virtual machine, and stop the '''centos2''' and '''centos3''' virtual machines.
# Switch to the '''c7hostcentos1''' machine, and open a shell terminal.# Enter these admin commands into your '''c7hostcentos1''' machine and note the result:
:: <b><code><span style="color:#3366CC;font-size:1.2em;">virsh list</span></code></b>
:: <b><code><span style="color:#3366CC;font-size:1.2em;">virsh list --all</span></code></b>
</ol>
::* In order to fully back up a virtual machine, what information should be saved in addition to the virtual machine image?
<ol><li value="24">A previous OPS235 student graciously created a shell script that you can download and run to check to see how you performed this lab (to see if you are on the right track).<br>Simply issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">wget http://matrix.senecac.on.ca/~murray.saul/ops235/lab2check2.bash</span></code></b> and run on your '''c7host centos1 machine'''.<br><br>'''If the shell script indicates any major errors, please inform your OPS235 instructor or lab assistant to advise what to do'''.<br><br></li></ol>
'''Answer the Investigation observations / questions in your lab log book.'''
If you require <u>'''additional practice'''</u> in creating shell scripts using logic, loops and mathematical operations, run the commands in your '''Matrix''' account: <ul><li>'''/home/murray.saul/scripting-2'''</li><li>'''/home/murray.saul/scripting-3'''</li></ul>
Perform the following steps in your c7host centos1 machine:
# Open a Bash shell terminal and login as root.
'''Arrange proof of the following on the screen:'''
<ol><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''<u>All</u> VMs''':<blockquote><ul><li>Working virtual machines '''created''' and '''running'''</li><li>'''Disk layout''' and '''size''' correct on all virtual machines</li><li> Proof of '''yum updates'''</li><li>'''All virtual machines backed-up''' (eg. usb stick and/or home directory)</li></ul></blockquote></li><li><span style="color:green;font-size:1.5em;">&#x2713;</span>'''c7hostcentos1''' machine:<blockquote><ul><li>'''Correct VM image filenames''' contained in '''/var/lib/libvirt/images directory'''</li><li>Creation of your bash shell script called '''backupVM.bash'''</li><li>A list of your '''iptables''' rules (command: '''iptables -L''')</li></ul></blockquote></li><li><span style="color:green;font-size:1.5em;">&#x2713;</span> Lab2 logbook notes and '''Installation Comparison chart''' completed</li></ol>
== Practice For Quizzes, Tests, Midterm &amp; Final Exam ==
13,420
edits

Navigation menu