Changes

Jump to: navigation, search

OPS235 Lab 2 - CentOS7 - VMware

No change in size, 17:50, 22 May 2016
no edit summary
== Purpose / Objectives of Lab2==
[[Image:vmware-1.png|thumb|right|400px|The centos1 centos2 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 Linux.
:'''VM Details:'''
:: '''VM Name (and hostname):''' centos1centos2
:: '''Boot media:''' LIVE CD Image
:: '''Installation source:''' Downloaded Centos7 LIVE CD image (http://belmont.senecac.on.ca/centos/7/isos/x86_64/CentOS-7-x86_64-LiveGNOME-1511.iso)
:: '''VM Image Pathname:''' /var/lib/libvirt/images/centos1centos2.img
:: '''Memory:''' 2GB
:: '''Disk space:''' 10GB
# '''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/centos1centos2.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: '''centos1centos2'''. 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 '''centos1centos2''' 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>centos1centos2</u>''' as opposed to ''c7host'') 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 centos2 install as opposed to c7host 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"
<li value="13">Enable SSH access to your virtual machine with these commands (semi-colon allows commands to be run in sequence):<br /> <b><code><span style="color:#3366CC;font-size:1.2em;">service sshd start; chkconfig sshd on</span></code></b></li>
<li>Find out the IP address of your virtual machine and the name of your Ethernet network adaptor: <b><code><span style="color:#3366CC;font-size:1.2em;">ifconfig</span></code></b> </li>
<li>Enter the following command on your virtual machine to create a firewall exception to allow ssh traffic into the machine:<br /> <b><code><span style="color:#3366CC;font-size:1.2em;">iptables -I INPUT -p tcp -s0/0 -d0/0 --dport 22 -j ACCEPT</span></code></b></li><li>If you are logged in as root, logout to your regular user account.</li><li>Confirm that you can ssh to your virtual machine from the host (your main CentOS installation): <b><code><span style="color:#3366CC;font-size:1.2em;">ssh regularuserid@IPaddress</span></code></b> (where '''regularuserid''' is your regular user login id, and '''IPaddress''' is the '''IP_ADDRESS''' of your '''centos1centos2''' VM!).</li><li>Make certain to '''disable SELinux for centos1centos2''' (refer to lab1)</li><li>Adjust your screen-saver settings and run a '''yum update''' on your centos1 centos2 VM before proceeding to ''Part 2''</li></ol>
:'''VM Details:'''
:: '''VM Name (and hostname):''' centos2centos3
:: '''Boot media:''' Network installation
:: '''Installation source URL:''' http://belmont.senecac.on.ca/centos/7/os/x86_64/
:: '''VM Image Pathname:''' /var/lib/libvirt/images/centos2centos3.img
:: '''Memory:''' 2048MB
:: '''Disk space:''' 20GB
# Create the VM (called '''centos2centos3''') as you did with the ''c7host'' 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 centos1centos2, 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 Centos2Centos3<br><br></li></ol># Complete the installation. Login to your regular user account, and perform a yum update for the centos2 centos3 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 centos3 and c7host''', 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.
# Create the VM as you did with the ''centos2centos3'' virtual machine, specifying a network install as before, but specify the kickstart location under the "options section" for network install. What do you think is the purpose of this kickstart file?
# Observe the installation. How is it different from booting from a downloaded image?
# Complete the installation. Record the time taken to install, and compare this to the time taken by the previous installations.<br><br>If the during the installation, you see the message at the bottom '''Pane is Dead''', click the '''Virtual Machine''' menu at the top, select '''Shut Down''' -> '''Force Off''', '''right-click''' on '''centos4''' in the ''virtual manager'' window and select '''Delete'''. Redo the VM setup for a new instance of the ''centos4'' VM.
|colspan="2"|{{Admon/note|Manage virtual machines from the host|The commands used to manage virtual machines must be executed on the host (your disk pack) and not inside a virtual machine.}}
|}
# Start the '''centos1centos2''' virtual machine, and stop the '''centos2centos3''' and '''centos4''' virtual machines.
# Switch to the '''c7host''' machine, and open a shell terminal.
# Enter these admin commands into your '''c7host''' machine and note the result:
|colspan="2"|{{Admon/note|Virtual Machine Does not Shutdown from Command|If the Virtual machine fails to shutdown from the <code>virsh shutdown</code> command, then you can go to the '''Virtual Machine manager''' and '''halt''' or '''shutdown''' within the VM itself, then you can click the '''PowerOff''' button in the VM window. You'll want to avoid a forced shutdown since those are equivalent to yanking the power cord out of the wall on a physical machine!|}}
|}
<ol><li value="4">Now, shut-down your centos1 centos2 VM normally, and close the centos1 centos2 VM window.</li><li>Switch to your terminal and issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">virsh start centos1centos2</span></code></b></li><li>Using the appropriate command check to see if your centos1 centos2 VM is now running.</li><li>There are other commands that can be used (such as '''suspend''', or '''shutdown'''). The "shutdown" command may not always work since it relies on the guest handling a particular ACPI event. Why do you think it is useful to have commands to manipulate VMs?</li><li>Since this is a text-based version of Linux, you do not need to turn off the screen-saver.</li></ol>
# Restore the original image from the backup in your home directory by typing this command: <b><code><span style="color:#3366CC;font-size:1.2em;">gunzip < ~YourUserId/centos4.img.backup.gz > centos4.img'''</span></code></b>
# Restart the VM. Is it working normally?
# Create compressed backups of your other virtual machines (ie. '''centos1centos2''' and '''centos2centos3''').
# You should make a copy of the xml configuration file in case you "wipe" and re-install the host machine, and want to add a restored VM backups to the virtual machine manager list. We will demonstrate using the centos4 xml configuration file, and prove that a "clone" can be added to your list.Please perform the following step:
# Execute the following command: <b><code><span style="color:#3366CC;font-size:1.2em;">virsh dumpxml centos4 > centos4.xml</span></code></b>
</code>
<br>
<ol><li value="4">Save your editing session, but remain in the text editor.</li><li>This shell script is designed particularly for your centos1centos2, centos2centos3, and centos4 VMS.</li><li>The code displayed below will prompt the user if they wish for all VMs to be backed-up; otherwise, allow the user the option of specifying which VMs to be backed-up. Add the following code</li></ol>
<br>
<code style="color:#3366CC;font-family:courier;font-size:.9em;">
<ol>
<li value="7">Save, set permissions, and then run that shell script to backup centos1centos2. Confirm that this script did backup this image to root's home directory</li><li>Use the <b><code>wget</code></b> command to download, study, and run the following shell scripts on-line:<blockquote><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">https://scs.senecac.on.ca/~murray.saul/vm-start-text.bash<br>https://scs.senecac.on.ca/~murray.saul/vm-stop-text.bash</span></code></b><br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">https://scs.senecac.on.ca/~murray.saul/vm-start.bash<br>https://scs.senecac.on.ca/~murray.saul/vm-stop.bash</span></code></b></blockquote></li><li>Try to understand what these Bash Shell scripts do.</li><li>You have completed lab2. Proceed to Completing The Lab, and follow the instructions for "lab sign-off".</li></ol>
'''Answer all observations / questions in your lab log book.'''
13,420
edits

Navigation menu