Changes

Jump to: navigation, search

OPS335 Installation Lab

3,644 bytes added, 12:50, 11 August 2022
no edit summary
[[Category:OPS335]][[Category:OPS335 Labs]] = = OBJECTIVE &amp; PREPARATION == This lab is a repeat of a portion of lab1 (and some of lab2) that you already performed in OPS235 plus some newer content that relates to this week's notes. You are expected to be able to complete all this using your existing skills and knowledge or refer back to your OPS235 lab-book or OPS235 WIKI notes. In this is lab, you will install your '''host machine''' (Centos7), '''install virtualization software''', and '''create and install 3 nested virtual machines'''. === Required materials ===*Centos 7 Full Installation DVD.*One Solid State Drive (SSD), mininmum capacity: 240 GB (USB 3.0). It is strongly advised you dedicate a drive for this course only. === Online Resources=== *[https://wiki.centos.org/TipsAndTricks#head-4c9ee55a5c9dc051bd32e795b46a3856e41a0335 Centos7 Install Tips]<br> ==INVESTIGATION 1: HOST INSTALLATION== === Installation instructions for CentOS 7 ===# It may be advisable to obtain the <u>latest version</u> of the CentOS 7 Full Installation DVD since there may be improvements since the last version from when you took OPS235.<br><br># Download and burn on a DVD a copy of the CentOS 7 installation DVD (64 bit edition) from the CentOS web site or the Belmont server.<br>'''Note:''' we'll be using the 64 bit version of CentOS because all of our lab computers are equipped with Intel 64 bit mainboards and CPUs, and any computer you bought in the last few years for yourself will be 64bit as well.<br><br>#* '''Seneca's mirror of CentOS:''' https://mirror.senecacollege.ca/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso <br>This is very fast, but is only accessible from within Seneca's network - you can't access this from home. You can burn this disc on the machines in the Open Lab.)<br><br>#* '''Outside Seneca College link (available from any Internet connection):<br>''' https://mirror.netflash.net/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso<br /><br># You need to refer to your OPS235 notes in order to install your host machine.<br>Here is a direct link:<br> [https://wiki.cdot.senecacollege.ca/wiki/OPS245_Lab_1 OPS245 - Lab1] <ol><li value=4>Customize your installation following these guidelines:<ul><li>'''Turn on networking''' and use '''host''' as the '''hostname'''.<li>Under software selection, choose '''Gnome desktop'''.<li>The partition setup is similar to what you had in OPS235:<ul><li>Delete any old partitions.<li>Select the hard disk and indicate "I will configure partitions" and click done.<li>Click the link to '''create them (partitions) automatically''' (this will give a typical layout with /, /boot, /boot/efi, /home, etc).<li>Free up at least '''100GB''' of disk space by shrinking the '''/home''' partition (At least '''40 GB''' for root (/) and '''40GB''' for /home). Since your machine will have far fewer users and more virtual machines than a typical installation, we will need that space elsewhere.<li>Create a new logical volume for '''/var/lib/libvirt/images''' and give it the space made available by shrinking /home (You will need enough space for up to 10 virtual machines at 8GB each plus room to compress/extract images).<li>Make certain that the existing partitions '''except swap, /boot and /boot/efi''' have the file system type '''ext4''' (not xfs).</ul></ul><li>After the installation starts you will also have the opportunity to create users.<ul><li>Set the root password<li>Create a '''user account''' named with '''your MySeneca ID'''</ul></ol><br> === First boot === # In the current version of CentOS the first time you boot your system a graphical licence prompt comes up.<br><br><ol><li value="2">Log in and check that you have access to the internet. If you don't - you need to get the network interface to come up on boot. Edit the appropriate config file and configure your main network interface to come up at boot.<ul><li>You can then use the '''ifup'''/'''ifdown''' commands to reset your network configuration or you can just reboot.</li></ul></li><li>Make certain that '''SELinux''' is '''enforcing''' for security reasons (this should be the default). To make it ''enforcing'', simply edit the '''/etc/selinux/config''' file and follow the instructions inside. {{Admon/important |SELinux in Andrew's sections|If you're in one of Andrew's sections - please disable SELinux (i.e. do the opposite of the bullet above). This will give you some extra freedom in the rest of the course to learn and experiment without being bogged down by inexplicable permission denied errors.}}</li><li>Install all updates using the '''yum update''' command.</li></ol><br> ===Using iptables===The most recent variants of Centos 6and Fedora are using a service called '''firewalld''' that is intended to replace '''iptables''', however the ''iptables'' service is still in relatively common usage.5 In this course we will concentrate on ''iptables''.<ol><li>Disable firewalld:<source>systemctl disable firewalldsystemctl stop firewalld</source></ol><ol><li value="2">Install and enable the IPTables services:<source>yum install iptables-servicessystemctl enable iptablessystemctl start iptables</source></ol>At this point you have a basic Centos system installed and updated. This will serve as a host for the virtual machines where you will do the majority of the work in this course. All the rest of our labs will assume you have this basic system running. If, for any reason, your system becomes corrupted during the semester, you'll have to redo this lab to be able to continue with the remaining uncompleted labs. You are responsible for YOUR system. If you do not perform back-ups you have taken this risk on yourself. Poor planning on your part does not constitute an emergency for anyone else. '''Record steps, commands, and your observations in INVESTIGATION 1 in your OPS235 lab log-book''' ==INVESTIGATION 2: VIRTUAL MACHINE INSTALLATION== ===Configuring a VM host=== # You will need to install some software to allow your machine to act as a host for virtual machines. We'll be using the same '''libvirt''' and '''virt-manager''' you used in [https://wiki.cdot.senecacollege.ca/wiki/OPS235_Lab_2 OPS235 - Lab2].<br>You may find it helpful to refer back to the '''OPS235 notes''' to perform the following operations:#* Install the required virtualization software#* Start and enable the virtualization service#* Reboot your host machine<br><br># Start the graphical virtual machine manager (''virt-manager''). Do this as you regular user, and don't run virt-manager from a terminal where you're logged in as root.# We will be creating our own virtual network. A default virtual network has been created for you, but you will be using a <u>custom</u> one in this course.#* 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 '''ops235'''#:* Use the '''last two digits of your student number for the third octet of network IP address''' (for example, if your student number is 000-000-0<b>90</b>, the network address would be 192.168.<b>90</b>.0/24.#:* Ensure the DHCP range will allow you to assign '''at least 10 static IP addresses outside it''' (note: leave the low numbers available for static addresses).#:* Choose '''Forwarding to physical network''' radio button, '''Destination: Any physical device''' and '''Mode: NAT'''#:* Ensure the network is '''started at boot'''. <br> === VM Installation===
[[CategoryWith the virtualization software installed and your personal network created, you are now ready to create your first virtual machine.First, It is a good idea to make certain that your host machine has been set up correctly prior to creating your first virtual machine:OPS335]][[Category #Open a separate terminal and issue the '''ip address show''' command on your host machine to know your physical network and your virtual network. Note this information for the next few steps.#Issue the following command to download Bash shell script to check your host machine's set-up prior to proceeding with this lab:<br>'''wget http://ict.senecacollege.ca/~andrew.smith/ops335/labcheck_install.sh'''<br>#Assign execute permissions, and run the script to check your work:<br> '''labcheck_install.sh'''<ol><li value="4">Use the information from the '''ip address show''' command to correctly specify the '''physical network interface''' and the '''virtual network interface'''.</li></ol> '''NOTE:''' You will need an ISO file for CentOS 7 (the same one you burned your DVD from). It is recommended to use the command to download this image onto your host machine. In this way, you can keep it on your host machine for the remainder of this course in case you need it: '''wget http://mirror.csclub.uwaterloo.ca/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso''' Perform the following steps to create your first VM on your Virtual Machine Manager application:OPS335 Labs]]
== Objectives ==Install Host Machine (Centos 6# Create a new virtual machine named '''vm1'''.5)Install 3 Virtual Machines # Accept the default file type (Fedora 20which is '''qcow2''')Prepare for lab exercises. You are <u>NOT</u> required to specify the VM file pathname as you did in OPS235.
== Required materials ==
Centos 6.5 Installation DVD
One SATA hard disk in a removable drive tray (minimum 160GB) - It is strongly advised you dedicate a drive for this course only.
Recommended - USB drive (8 GB+) for creating and storing backups (Virtual Machines, configuration files)
==Part A: Host Installation =={{Admon/tip|VM File Types ( '''.qcow2''' vs '''.img''' )|In OPS235, you selected the VM images as a '''"raw"''' image. In OPS335, you will be accepting the default image file '''".qcow2"''' (which stands for "QMENU Copy on Write version 2" ) that provides more features when manipulating stored VM images.}}
=== Installation instructions ===
#Download a copy of the Centos 6.5 installation DVD (64 bit edition) from the Centos web site or burn the DVD using Seneca's Freedom Toaster which is located in the Open Lab on the 2nd floor of the TEL building. Note: we'll be using the 64 bit version of Centos because all of our lab computers are equiped with Intel 64 bit mainboards and CPUs. We'll also be using a Fedora iso for installing the virtual machines, but you will not need to burn that to a disc. It is faster to download the ISO and install directly from it. Finally, if you're going to burn your DVD using the Freedom Toaster then be sure to use a blank DVD-R disc. DVD+R discs sometimes fail to burn successfully.
#* '''Seneca's mirror of Centos:''' http://belmont.senecac.on.ca/centos <br />(This is very fast, but is only accessible from within Seneca's network - you can't access this from home. You can burn this disc on the machines in the Open Lab.)<br />
#* '''Centos mirror list:''' http://isoredirect.centos.org/centos/6/isos/x86_64/<br />(Accessible from any Internet connection.)<br />
#Insert your HDD into the docking bay of a PC in the lab and boot the computer using your installation DVD. If possible try to use the same PC for this course for the rest of the semester. Some PCs may be configured with slight hardware variations from others which may cause problems when moving your HDD from one system to another.
#Perform your installation following these guidelines:
#*wherever possible select the default options
#*set your hostname to your learn ID.
#*set Toronto as your time zone
#*When given the option, click 'review and modify partition layout'. A typical installation devotes most of the available space to a logical volume for /home. You will have very fewer users and more virtual machines than a typical installation. Reduce the size of lv_home (minimum 10GB), and create a new logical volume for /var (called lv_var) and give it the space made available by shrinking lv_home (You will need enough space for 6 virtual machines at 8GB each).
#*set the root password
#After completing the installation, remove the DVD and reboot from your HDD.
{{Admon<ol><li value="3">Since you will be installing a Linux <u>server</tip|Tip: Boot Menu|If u> (as opposed to a Gnome Desktop workstation), you got can '''use the boot failure message, restart <u>default</u> memory and CPU options for use with lab computers'''.</li><li>Set the computer and press [F10] disk image size set to get '''8GB'''<br><br>Note: Since you already setup your virtual network to the boot menuOPS335, select your VM will be automatically connected to your new ops335 virtual network.<br><br></li><li>Note the Hard Disk as boot device and continue. }}following installation steps when you install your created VM:</li></ol>
=== Booting your system ===::* Select the correct ''location / Time Zone''.#create a user named with your learn ID#Login as ::* For Software Selection: Accept the user you created and open a terminal window. Then use default '''suminimum install' to become root and run the 'yum update' command. Logout when done. Note, you may None of your VMs in this course will have to reboot after all updates have completeda GUI since GUIs needlessly consume resources and image space. Now that your system is up to date<ol><li>Click '''Installation Destination''', again login using your learnid and do the following:#*Verify then click '''Done''' to confirm that your system date an '''automatic install''' will be performed.</li><li>Click Network & Hostname and time are correct. If not then set the correct system date and timehostname to: '''vm1.#*Verify that your network is functioning.#*Run localdomain''' and record the output of make certain the 'df -hT' commandEthernet connection'' is set to '''ON'''.#*Run and record the output of </li><li>During installation you will be prompted to set the 'cat /etc/fstab' command.#*Run root password'' and record the output of the an '''initial user account''cat /etc/issue' command.#*Run and record the output of For the 'uname -a' commandinitial user'', enter the same information you entered on your host machine.</li></ol>
===Configuring a Linux Gateway===At this point you have a basic Centos 6.5 installed and updated. This will serve as a host for the virtual machines where you will do the majority {{Admon/tip|First user created|For successful completion of the work in this course. All the rest of our labs will assume you have this basic system running. If, for any reason, your system becomes corrupted during the semester, you'll have to redo this lab to be able to continue with please ensure the remaining uncompleted labs. You are responsible for YOUR system. If you do not perform back-ups you have taken this risk on yourself. Poor planning on first user created is named using your part does not constitute an emergency for anyone elseSeneca username.}}
*You will need to install some software to allow your machine to act as a host for virtual machines yum groupinstall virtualization yum install virt-manager libvirt*Start and enable the virtualization service service libvirtd start chkconfig libvirtd on*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 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.**A default one has been created for you, but you will be using a custom one in this course.#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 'ops335'#*Use the last two digits of your student number for the third octet of network IP address. Example, if your student number is 000-000-0<bbr>90</b>, the network address would be 192.168.<b>90</b>.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
==Part B: Virtual Machine Installation ==
With the virtualization software installed and your personal network created, you are now ready to create your first virtual machine. If you have an installation DVD for Fedora you can use that, but it will be much faster to download the iso from belmont (If it has been made available yet) and install directly from it.
wget http://belmont.senecac.on.ca/fedora/releases/20/Fedora/x86_64/iso/Fedora-20-x86_64-DVD.iso
If it has not been made available use the publicly available mirrors
http://mirrors.fedoraproject.org/publiclist/Fedora/20/#CA
===Installation===
*Click on the icon "Create a new virtual machine" to begin.
*Name your machine "f20-vm01" 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 "Fedora 18" (if there is no option for Fedora 20) 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 'ops335'. Make note of any other available options (you will need them again in the assignments).
*Select 'Install to Hard Drive' to begin your Fedora installation. Select the appropriate default options (You may wish to review your OPS235 notes to remind yourself what these are).
*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 "vm01.localdomain".
{{Admon/important|Firstboot - First user created|For successful completion of the labs, please ensure the first user created is named using your Learn ID.}}
===First Boot===
*#You will notice that the server installation defaults to a command-line interface. This is normal, and we will only be using this interface during this course.#Ensure your machine has a network connection by running the command host cbc'''ssh your_seneca_id@matrix.senecacollege.ca'''<ol><li value="3">If that did not work- make sure GlobalProtect VPN is installed on your Windows/Mac and connected. If it is, edit the line in ensure your CentOS network interface is started automatically on boot.</etcli></sysconfigol>{{Admon/tip|Default for networkconfig for onboot|If you've turned on your networking interface during installation -scripts/ifcfgit will be turned on by default. If you've left the network interface off during the installation -eth0 onboot=noshould it will beoff by default.}} onboot<ol><li value=yes*Update "4">Once you have a working connection - update your machine (this may take a while).</li></ol> '''yum update'''*Reboot <ol><li value="5">Install the virtual machine once '''bind-utils''' package. The commands it is updatedprovides (e.g. nslookup) will be useful in troubleshooting your network connection.</li>*Now run <li>You may also want to install the following commands '''nmap''', '''telnet''' and '''net-tools''' packages to help you troubleshoot connectivity issues.</li><li>Configure '''firewalld, iptables''' and note (if required) '''SELinux''' the output. Note how they differ from same way you did for the Centos installation on your host.</li> df -hT cat <li>Reboot the virtual machine once it is updated.</etc/fstabli> cat </etc/issueol> uname -a===Minimizing your VM's footprintCloning a Virtual Machine===*Since all VMs used in this course are intended to be servers<ol><li> Now that you have one virtual machine working, you will create two more. If you struggled with the presence of a GUI in not recommended - servers previous steps, repeat them to create two more virtual machines.</li><li>'''If you are typically managed from confident with what you have done so far, you may clone your existing machine to create the command line.* Make it boot others by default to performing the command line onlyfollowing steps:'''</li><li><ol type="a">**Fedora 17 and onward do not use <li>Make certain that your '''vm1''' virtual machine is shutdown.</etc/inittabli> <li>For your '''vm1''' machine, go to set the default run level but rather use targets as a more flexible replacement. Note details section and remove the output of the following command: ll <u>device</etcu> '''Channel qemu-ga'''.</systemd/system/*.targetli> lrwxrwxrwx<li>In the virtual machine manager, '''right click''' on ''vm1'' and select '''Clone. 1 root root 36 Dec ..'''.</li> 3 09<li>Set the Name to be:35 '''vm2'''</etcli></systemdol></system/defaultli><li>Once successfully created, boot the new VM and correct the host name.target This can be done using the '''hostnamectl''' command-line tool.</li> <li>Record in your notes the steps for cloning a vm.</libli><li>Use the host command to check for connectivity</systemdli><li>After creating '''vm2''' repeat the above steps to create '''vm3''' and correct the hostname ('''vm2.localdomain''' and '''vm3.localdomain''' respectively).</systemli></runlevel5.targetol>and ll {{Admon/libimportant |Backup your VMs!|You MUST backup ALL of your VMs whenever you complete your '''OPS335 labs''' or when working on your '''OPS335 assignments''':<br>[ [https:/systemd/system/*wiki.targetSystemd uses symbolic links to point to the default runlevel in usecdot. To change the default runlevel you must first remove the existing symlinksenecacollege. rm ca/etcwiki/systemd/system/defaultOPS235_Lab_2_-_CentOS7_-_HD2#Part_1:_Backing_Up_Virtual_Machines Backing up Your Virtual Machines] ]. Refer to OPS235 lab2 notes on how to backup your VMs.targetTo change You should backup your system VMs to boot a USB key in multi-user mode by defaultcase something happens to your host machine. Note: ln -s VM files contained in the '''/var/lib/systemdlibvirt/system/multi-userimages''' directory have the extension in '''.target /etc/systemd/system/default.targetMake note qcow2''' and instead of the command that would be needed to change the default 'runlevel' (or 'target.img''' as it is now referred to when using systemd) (eg. for OPS235 courses prior to graphical or runlevel 5Fall 2016.}}Test your VM to make sure that it boots correctly before moving on to the next step.
===Managing a Service===*Before you start'''Record steps, if you are more familiar with the chkconfig or service commands, you may wish to review the [http://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet SysVinit to Systemd Cheatsheet].*You will want to be able to communicate with and your machines using ssh.**Check the ip address of the virtual machine ip address show**Start the ssh service on the virtual machine. Also set the service to start automatically when the machine boots.**Use ssh to connect from observations in INVESTIGATION 2 in your host to the virtual machine.***You will be prompted to store the virtual machineOPS335 lab log-book'''s identification. Choose yes (we will cover this in more detail later).**Reboot the virtual machine and check the status of your ssh service.
===Cloning a Virtual Machine=COMPLETING THE LAB ==*Now that Upon completion of this lab you should have one 4 installed machines. One machine running Centos 7 and acting as a host and gateway for three virtual machines running minimal installations of Centos 7. Each machine working, you will create two more. If you struggled with must be fully updated and have access to the previous stepsnetwork (for example, repeat them to create to more virtual machines (naming them f20-vm02 get further updates) and f20-vm03, with hostnames vm02be able ping the others.localdomain and vm03 Each machine must be using iptables for the firewall.localdomain respectively) ===Online Submission=== Follow the instructions for lab 0 on blackboard<!--===Andrew's sections=== You may choose to:*If you are confident with what you have done so farSubmit screenshots of your work on Blackboard, in which case you may clone your existing machine don't need to come to create the otherslab.**To quickly create additional VM's shutdown 'f20-vm01'Or come to the lab, show me your work, right click and select talk to me about it. I want to hear what you'Clone..ve learned and answer any questions you haveYou'll get the same grade regardless of how you choose to submit your work. Use the following options Expected results of this lab are:*Name::<span style="color: f20green;font-vm02size:1.5em;">&#x2713;</span> Host Machine installed*Storage::<span style="color:green;font-size:1.5em;">&#x2713;</span> 3 virtual machines installed**Click the drop down menu below 'f20::<span style="color:green;font-vm01size:1.img', choose details 5em;">&#x2713;</span> Each machine (host and rename the image VM) has access to the f20network::<span style="color:green;font-vm02size:1.img5em;">&#x2713;</span> Lab logbook completed**Once successfully created boot the new VM and correct the host name::<span style="color:green;font-size:1. This can be done using 5em;">&#x2713;</span> Run the GUI or command line'''labcheck_install. **Record in sh''' shell script on your notes how each is done.**Check for connectivity. host cbc.camachine**After creating f20-vm02 repeat the above steps to create f20-vm03 and correct the host name.>
== Completing the Lab EXPLORATION QUESTIONS==Upon completion of this lab you should have 4 installed machines. One machine running Centos 6.5 and acting as a host and gateway for three virtual machines running Fedora 20. Make sure that each machine can access the network (for example, to get updates) and that you can ssh from your host to your VMs, and between your VMs.
Record the following answers in your logbook.
#What is the code name of your installed Fedora Linux system? How did you determine this?
#What kernel release is your host system running?
#What kernel release are your virtual machines running?
#What is the UUID (Universally Unique Identifier) of your root file system? What command was used to obtain this information?
#What is the size and type of the /boot file system on your host?
#What file was edited to change the host name on your VM's?#How are ping and ssh affected (on both machines) when you run the following command on the host machine?#*echo 0 > /proc/sys/net/ipv4/ip_forward#When changing the default target on your VMs to multiuser, you used two commands. What option can be added Are there other ways to reduce this to a single commandchange the hostname?
163
edits

Navigation menu