Difference between revisions of "Lab 2 Warnings / Debrief"

From CDOT Wiki
Jump to: navigation, search
(Created page with '= Preparing for Lab 1= == Purpose of Lab1 == [[Image:hostmachine.png|thumb|right|300px|The c7host Linux server will run virtualization software to install and run 3 virtual mac…')
 
 
(30 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Preparing for Lab 1=
+
= Preparing for Lab 2=
  
== Purpose of Lab1 ==
+
== Purpose / Objectives of Lab2==
 +
[[Image:hostmachine.png|thumb|right|250px|The c7host Linux server will run virtualization software to install and run 3 virtual machines (installed in lab2). ]]
  
[[Image:hostmachine.png|thumb|right|300px|The c7host Linux server will run virtualization software to install and run 3 virtual machines (installed in lab2). ]]
+
'''In this lab, you will create three virtual machines'''. This also gives you an opportunity to experiment with different ways of installing CentOS.
You need to install a Linux OS to be a host or "platform" to install and use other Linux VMs (Virtual Machines) during this course.
+
<br><br>
 +
* '''Installing Virtualization Software''' on your '''c7host''' machine
 +
* '''Create 3 separate VMs (virtual machines) using different installation methods:'''
 +
:* Centos Live DVDInstallation (Hostname: '''centos1''')
 +
:* Network Installation without configuration file (Hostname: '''centos2''')
 +
:* Network Installation with Kickstart file (Hostname: '''centos3''')
 +
* 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
  
The Linux OS you will be installing in this lab will be a Host Machine (''hostname'': '''c7host''') that will allow you to run '''Virtualization Software''' to create 3 separate virtual machines (to be performed in lab2). It is important to install this host machine correctly since other labs will depend on the stability of this host machine.
 
  
 +
== Installing Virtual Machines ==
  
<u>Main objectives</u>:
+
Prior to installing virtual machines, you need to issue a command to download and install virtualization software. There are many brands of this software (eg. VMWare, VirtualBox, etc), but will be using KVM.
  
* '''Correctly install the CentOS 7 FULL INSTALL DVD''' (not LIVE DVD) on your removable hard disk.
+
The command to install KVM is:
  
* '''Record installation characteristics of CentOS 7 FULL INSTALL''' in a chart (contained in lab2 logbook chart) to compare with other installation methods performed in lab2.
+
'''yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python \
 +
python-virtinst libvirt-client virt-install virt-viewer bridge-utils'''  
  
* '''Verify correct settings''' prior to proceeding with host installation stages.
 
  
* '''Obtain Linux server information after installation''' to create a software asset report for later access.
+
When creating a virtual machine, two separate operations must be performed:
  
* '''Disable Linux Kernel security enhancements''' to allow easier internal networking connections (to be reactivated in a later lab).
+
:# '''Create "storage space" for VM''' (complete details such as name, hard drive size, RAM, etc)
 +
:# '''Install OS''' (eg. DVD, ISO image, Network, Network with kickstart file)
  
* Observe that '''Bash Shell Scripts can automate routine tasks'''.
+
After using the yum install command to install the virtualization software, you MUST issue commands to '''start the virtulatization service''' and '''restart the firewall'''!. If you do <u>'''not'''</u> issue these commands, the virtual machine manager application will not work, and you may '''experience problems in future labs with ssh connections'''!
  
  
<u>Hard Disk Partitioning</u>
+
== Managing Virtual Machines ==
  
* '''Hard Disk partitions are simply smaller logical storage units''' (containers) within a hard disk
+
Can manipulate the Virtual Machines via command line (i.e. instead of Virtual Machine Manager, although that program must be running).
 +
Useful when utilized within shell scripts (demonstrated at the end of lab2).<br>
 +
A command called virsh (Virtual Shell allows administrator to issue commands in this special shell)
  
* <u>'''Advantages of Hard Disk Partitions'''</u>
+
<u>Common virsh examples</u>
:* Separation of operating system files from data (easier recovery)
+
*'''virsh list''' (only lists only running VMs)
:* Allows for booting multiple operating systems
+
*'''virsh list --all''' (lists running and non-running VMs)
:* Separation of Data for efficient access and sharing
+
*'''virsh list --inactive''' (lists only non-running VMs)
 +
*'''virsh start centos1''' (starts VM named "centos1")
 +
*'''virsh stop centos3'''  (stops VM named "centos3" , although best to shut-down under normal methods)
  
* In Lab 1, we will be creating customized partitions (as opposed to suggested partitioning default from install program)
 
  
 +
== Backing Up Virtual Machine Images ==
  
<u>Accessing the Administrative Account (root)</u>
+
Backing up your virtual machine images and xml virtual machine menu configurations is extremely important and MUST be performed at the end of each lab onto you USB key.
 +
If something bad occurs (even removable hard disk failure). Student simply has to perform lab1 and first part of lab2 (install virtualization program), and then restore the VMs.
 +
Failure to follow instructions can lead to loss of backups!
  
Many administrative tasks require the root administrative account. There are many ways to access this administration account:<ul><li>Login: '''root'''  (enter root password)</li><li>Switch User to root (without login):<ul><li>'''su''': Remains in regular user's directory, does not run root's startup script(s).</li><li>'''su -''' : Changes to root's home directory (/root) and runs root's start script(s).</li></ul></li></ul>
+
There are two general processes in order to back up your images:<ol><li>'''Compressing your images''' (also recommended to backup up to external storage USB Key) using the '''gzip''' command.<br>eg. '''gzip < centos3.img > ~YourUserId/centos3.img.backup.gz'''  (Use the redirect symbols!!!!)</li><li>'''Backup the VM xml configuration file''' (preferably to USB key) using '''virsh''' shell command to add VM to virtual machine manager list (in the event that the HOST machine is "wiped" and re-installed, but VM images and xml configuration files have been backed up external storage).<br>eg. '''virsh dumpxml centos3 > centos3.xml'''<br><br></li></ol><br />Taking the time to backup the image of the Operating System's file system allows the user to return to a '''"restoration point"''' using the '''gunzip''' command in case something bad occurs to the OS during a lab.<br>There are four general processes to restore your backed-up VMs:<ol><li>eg. Copy '''centos3.img.backup.gz''' from your USB to your <u>images</u> diretory</li><li>Issue command in <u>images</u> directory: '''gunzip < ~YourUserId/centos3.img.backup.gz > centos3.img'''</li><li>Copy '''centos3.xml''' from your USB to your <u>images</u> directory</li><li>In the <u>images</u> directory issue the command: '''virsh define centos3.xml'''</li></ol><br>Failure to take the time to make and confirm backups can result in loss of lab work for the student!
  
  
<u>Pathname for USB Stick</u>
+
== Managing VMs with Shell Scripts ==
  
The default mount location has been changed in linux distributions newer than CentOS. So while we will get '''/media/usb-device-name''',<br> in newer distributions you'll see '''/run/media/userloginid/usb-device-name'''
+
Refer to the shell scripting section in lab 2 to see how shell scripts can use the virsh command to start and stop VMs automatically.
 
 
 
 
<u>Disabling SELinux</u>
 
 
 
SELinux stands for '''Security-Enhanced Linux'''. It is a component that helps to better secure the system to protect against intrusion (hackers). SELinux is enabled upon the default install of CentOS. SELinux can be a good thing, if you take care of it and know how it works. For this course it is strongly recommended that you '''disable SELinux by default''' because we won't have the time to reconfigure it every time the labs make it necessary
 
  
  
Line 55: Line 67:
 
{{Admon/important |Be Aware of the Following Issues| Be aware of these common mistakes that students make that can cause problems for their future labs.}}
 
{{Admon/important |Be Aware of the Following Issues| Be aware of these common mistakes that students make that can cause problems for their future labs.}}
  
 
+
* Use '''comparison chart on lab2 logbook''' to record your findings as you install <u>each</u> VM.
<u>Bring Required Materials to Class</u>
+
* After using the yum install command to install the virtualization software, you MUST issue commands to '''start the virtulatization service''' and '''restart the firewall'''!
 
+
* Best to start the virtual Manager by menu instead of command line (i.e. '''Applications''' > '''System Tools''' > '''Virtual Machine Manager''')<br><br>
: '''Come prepared for labs:'''
+
* '''FOLLOW THE INSTRUCTIONS CAREFULLY''' in terms of hard disk sizes, image pathnames, RAM size, etc! Not following instructions can lead to removing VM and starting again.<br><br>
:* '''Removable SATA Drive''' ( min 250 GB )
+
* If need to start-over, you can right-click on VM in Virtual Machine Manager, and remove (Make certain "delete files" is also selected, so you can re-use VM name).
:* '''USB Stick''' ( min 8 GB )
+
* Installation of centos2 and centos3 can only be performed at college since it uses internal Belmont network!
:* '''CENTOS 7 Full INSTALL DVD'''
+
* Make certain to do following for EACH Virtual Machine:<ul><li>Start ssh service</li><li>Create firewall exception to allow ssh traffic for ssh (iptables)</li><li>Disable SElinux</li></ul>
:* '''Lab 1 Logbook''' (Instructor can't sign-off lab without seeing lab-book notes)
 
:* '''Access to Lab Instructions''': printout, notebook, netbook, smartphone
 
 
 
 
 
<u>Paritioning</u>
 
 
 
* '''Failure to properly following lab instructions may result in re-doing lab again!'''
 
 
 
* '''Make certain to create the correct partitions''' (Have instructor or lab monitor confirm before proceeding with install):
 
:'''Primary Partitions (ext4):
 
:*'''30GB''' for '''/'''  (i.e. "root")
 
:*'''40GB''' for /home
 
:*'''100GB''' for '''/var/lib/libvirt/images''' (need to manually enter this "mount-point")
 
:'''Swap Partition:'''
 
:*'''16GB''' (Note: "swap" must be selected from the drop down menu)
 
 
 
* '''NOTE:''' Remember that the sizes are recorded in MB (eg. 30 GB = 30000 MB) and you should multiply GB by a factor of 1024 to get the correct size.<br> (eg. '''30 GB x 1024 = 30720 MB''')<br><br>
 
 
 
<u>Common Types of File Systems for Linux</u>
 
 
 
Similar to other Operating Systems like windows '''fat''' / '''vfat''' / '''ntfs''' file system types, it is good to know a few common file system types in Linux for comparison:<br><ul><li><b>xfs:</b> &nbsp; Newer filesystem (fast transfer rates for large files, Journaling)</li><li><b>ext4:</b> &nbsp; Newer filesystem supporting large files and Journaling (used in for this lab)</li><li><b>ext2:</b> &nbsp; Stable filesystem popular for databases (no journaling)</li></ul>
 
 
 
  
  
Line 99: Line 89:
  
  
== Lab 1 Debrief ==
+
== Lab 2 Debrief ==
 +
 
  
* How many packages were installed?
 
* How many files (correct to the nearest hundred) were installed?
 
* How many users were created automatically on your system (regular, admin)?
 
* List 2 ways that you can access your root account
 
* What is the difference between the commands '''su''' and '''su -'''  ?
 
* What is the home directory for the user "root"?
 
* How do you determine the host name of your GNU/Linux workstation?
 
* What command can display the NIC's MAC address?
 
* What command is used to get a list of running processes on your newly-installed system?
 
* What is the command to copy files to your USB key?
 
* How can Shell Scripts be used to help automate a task performed in lab1?
 
  
 
[[Category:OPS235]]
 
[[Category:OPS235]]
 
[[Category:OPS235 Labs]]
 
[[Category:OPS235 Labs]]

Latest revision as of 09:17, 22 September 2015

Preparing for Lab 2

Purpose / Objectives of Lab2

The c7host Linux server will run virtualization software to install and run 3 virtual machines (installed in lab2).

In this lab, you will create three virtual machines. This also gives you an opportunity to experiment with different ways of installing CentOS.

  • Installing Virtualization Software on your c7host machine
  • Create 3 separate VMs (virtual machines) using different installation methods:
  • Centos Live DVDInstallation (Hostname: centos1)
  • Network Installation without configuration file (Hostname: centos2)
  • Network Installation with Kickstart file (Hostname: centos3)
  • 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


Installing Virtual Machines

Prior to installing virtual machines, you need to issue a command to download and install virtualization software. There are many brands of this software (eg. VMWare, VirtualBox, etc), but will be using KVM.

The command to install KVM is:

yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python \ python-virtinst libvirt-client virt-install virt-viewer bridge-utils


When creating a virtual machine, two separate operations must be performed:

  1. Create "storage space" for VM (complete details such as name, hard drive size, RAM, etc)
  2. Install OS (eg. DVD, ISO image, Network, Network with kickstart file)

After using the yum install command to install the virtualization software, you MUST issue commands to start the virtulatization service and restart the firewall!. If you do not issue these commands, the virtual machine manager application will not work, and you may experience problems in future labs with ssh connections!


Managing Virtual Machines

Can manipulate the Virtual Machines via command line (i.e. instead of Virtual Machine Manager, although that program must be running). Useful when utilized within shell scripts (demonstrated at the end of lab2).
A command called virsh (Virtual Shell allows administrator to issue commands in this special shell)

Common virsh examples

  • virsh list (only lists only running VMs)
  • virsh list --all (lists running and non-running VMs)
  • virsh list --inactive (lists only non-running VMs)
  • virsh start centos1 (starts VM named "centos1")
  • virsh stop centos3 (stops VM named "centos3" , although best to shut-down under normal methods)


Backing Up Virtual Machine Images

Backing up your virtual machine images and xml virtual machine menu configurations is extremely important and MUST be performed at the end of each lab onto you USB key. If something bad occurs (even removable hard disk failure). Student simply has to perform lab1 and first part of lab2 (install virtualization program), and then restore the VMs. Failure to follow instructions can lead to loss of backups!

There are two general processes in order to back up your images:
  1. Compressing your images (also recommended to backup up to external storage USB Key) using the gzip command.
    eg. gzip < centos3.img > ~YourUserId/centos3.img.backup.gz (Use the redirect symbols!!!!)
  2. Backup the VM xml configuration file (preferably to USB key) using virsh shell command to add VM to virtual machine manager list (in the event that the HOST machine is "wiped" and re-installed, but VM images and xml configuration files have been backed up external storage).
    eg. virsh dumpxml centos3 > centos3.xml


Taking the time to backup the image of the Operating System's file system allows the user to return to a "restoration point" using the gunzip command in case something bad occurs to the OS during a lab.
There are four general processes to restore your backed-up VMs:
  1. eg. Copy centos3.img.backup.gz from your USB to your images diretory
  2. Issue command in images directory: gunzip < ~YourUserId/centos3.img.backup.gz > centos3.img
  3. Copy centos3.xml from your USB to your images directory
  4. In the images directory issue the command: virsh define centos3.xml

Failure to take the time to make and confirm backups can result in loss of lab work for the student!


Managing VMs with Shell Scripts

Refer to the shell scripting section in lab 2 to see how shell scripts can use the virsh command to start and stop VMs automatically.


Common Mistakes / Warnings

Important.png
Be Aware of the Following Issues
Be aware of these common mistakes that students make that can cause problems for their future labs.
  • Use comparison chart on lab2 logbook to record your findings as you install each VM.
  • After using the yum install command to install the virtualization software, you MUST issue commands to start the virtulatization service and restart the firewall!
  • Best to start the virtual Manager by menu instead of command line (i.e. Applications > System Tools > Virtual Machine Manager)

  • FOLLOW THE INSTRUCTIONS CAREFULLY in terms of hard disk sizes, image pathnames, RAM size, etc! Not following instructions can lead to removing VM and starting again.

  • If need to start-over, you can right-click on VM in Virtual Machine Manager, and remove (Make certain "delete files" is also selected, so you can re-use VM name).
  • Installation of centos2 and centos3 can only be performed at college since it uses internal Belmont network!
  • Make certain to do following for EACH Virtual Machine:
    • Start ssh service
    • Create firewall exception to allow ssh traffic for ssh (iptables)
    • Disable SElinux


Preparing for Lab Sign-Off

Students should be prepared with all required commands (system information) displayed in a terminal (or multiple terminals) prior to calling the instructor for signoff.


In order to properly complete your lab and move to the next lab, you must have your instructor "sign-off" on your lab

  • Each "signed-off" lab (before due date) is worth 1% of your final grade.
  • Signing-off on labs help to spot errors that can cause problems with future labs.
  • Do you ask the instructor what to check for! Read at the bottom of the lab the requirements, and have all proof available for instructor to view at same time.
  • Failing to be prepared and asking instructor what to check when assignment is mark will result in deduct of marks!
  • For example, open multiple terminals with command results. If properly set-up ahead of sign-off, the process should only take instructor approx 20 seconds to sign-off your lab.
  • If you do not have your lab-logbook, you MUST show your work and your lab log-book to your instructor for sign-off in the next class. This may cause a late penalty if past the required due date.


Lab 2 Debrief