Virtualization

  • Uploaded by: Shuaib Zahda
  • 0
  • 0
  • August 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Virtualization as PDF for free.

More details

  • Words: 1,689
  • Pages: 8
Virtualization using openVZ and easyVZ By: Showayb A A Zahda 

It is one of the most interesting and exciting things to run many operating systems at the  same   time   on   a   single   computer.   You   can   probably   test  some   software   on   different  environments without the need to buy several computers. Or you can have several servers  at the same machine running different services in which you distribute the job of the  services into different operating systems. And having a stronger security. Of  course that  is possible  and doable using virtualization. Virtualization is basically  running several operating systems at the same time on top of one operating system. They  all share the resources of the machine like CPU, RAM, Hard disk, etc. Each system will  run in its environment and will not affect other systems. Moreover, we can connect all of  them using the virtual network.  In this humble tutorial I will explain for you how to use virtualization to run several  operating systems on Linux box. I will use openVZ and on top of it I will use the GUI  easyVZ to make the virtualization look prettier and nicer. To start, you need to have your kernel compiled with openVZ. Check that using #uname -a The output should look something like Linux ... 2.6.18­8.1.8.el5.028stab038.1 .. The most important part is 028stab038, if you do not have this (the numbers might be  different on your machine) you need to update your kernel using yum. So, make sure you  are connected to the Internet. To update the kernel you need first to update your yum  repository.  #cd /etc/yum.repos.d #wget http://download.openvz.org/openvz.repo #cd Till now you have just updated your repository so as to use it for yum. #yum -y install ovzkernel

After this step is done, you several things will change beside the kernel update. One of  them is the boot loader. I am using Centos 5, so my boot loader is GRUB. What happens  is that the yum installer will add extra entry to /boot/grub/grub.con looks like  title Cenros (2.6.8-022stab029.1) root (hd0,0) kernel /vmlinuz-2.6.8-022stab029.1 root=/dev/sda5 initrd /initrd-2.6.8-022stab029.1.img

ro

Note the “stab” in the entry I believe you know how to edit GRUB configuration file to make this entry the default  boot option. After this step we have to make some changes on some configuration files to make our  virtualization runs with no problem.  First file to be edited is the system control file. /etc/sysctl.conf // change these entries # On Hardware Node we generally need # packet forwarding enabled and proxy arp disabled net.ipv4.ip_forward = 1 # Enables the magic-sysrq key kernel.sysrq = 1 # Enables source route verification net.ipv4.conf.all.rp_filter = 1 net.ipv4.conf.default.proxy_arp = 0 // add these entries at the bottom net.ipv4.conf.default.proxy_arp = 0 net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0 Do not forget to save the file. Now the next file to be changed is /etc/sysconfig/selinux SELINUX=disabled Make sure that selinux is disabled. Ok by now your virtualization is half way, you need to reboot your machine.

#reboot After your reboot is completed. you need to ensure that you have booted to the correct  kernel #uname -a The output should look something like Linux ... 2.6.18­8.1.8.el5.028stab038.1 .. Now is the time to install the tools of openVZ. #yum -y install vzctl vzquota vzpkg After the installation is completed we can start our service of virtualization. #/etc/init.d/vz start or #service vz start Until here we have our virtualization program setup and running. Let's see how this thing  work. In openVZ as other virtualization tools, you must have images of your operating systems  that you want to run on the host machine. The host machine is the machine that you are  running every thing on.  So, in openVZ the operating system is called template. What is  inside a template? You can have the whole operating system and tools in the template  and   you  can  have  the  minimum   number  of tools as well. It is customizable. In this  tutorial we will use one template that has been done by the openVZ people and do our  experiments on it. In order to get ready made templates you can search them using yum #yum search vztmpl This will give you some output like this  vztmpl-centos-4.i386 2.0-2 openvz-utils Matched from: vztmpl-centos-4 vztmpl-fedora-7.i386 openvz-utils Matched from:

1.1-1

vztmpl-fedora-7 vztmpl-fedora-core-6.i386 openvz-utils Matched from: vztmpl-fedora-core-6

1.2-1

vztmpl-fedora-core-3.i386 openvz-utils Matched from: vztmpl-fedora-core-3

2.0-2

vztmpl-fedora-core-4.i386 openvz-utils Matched from: vztmpl-fedora-core-4

2.0-2

vztmpl-fedora-core-5.i386 openvz-utils Matched from: vztmpl-fedora-core-5

2.0-2

vztmpl-centos-4.i386 installed Matched from: vztmpl-centos-4

2.0-2

now you pick the operating system of your interest and download it using yum. In my  case I prefer to use centos 4.5. The name of the tempalte usually looks like vztmpl­ nameOfDistro­version.machine #yum -y vztmpl-centos-4.i386 if you want to download another one you just need to change the name of the operating  system after vztmpl like  #yum -y vztmpl-fedora-7.i386 From here we need to have some understanding of the files of openVZ. Once you have  your template downloaded and installed. It will basically be extracted in the directory  /vz/template/centos/4/i388 . This is basically a mapping of the name to be extracted in  directories. So, /vz/emplate/nameOfDistro/version/machine/

and inside are the files of the system. Now what you did is that just you have installed a small file which creates for you the  beginning of the job. In order to be able to run the system you have to have a file that  ends with .tar.gz. something like centos-4-i386-default.tar.gz saved in /vz/template/cache/ To have this file you can use yum or download it manually. To have things done easier I will use yum but this time it will be used via another  command called #vzpkgcache this   command   will   read   what   are   the   directories   inside   /vz/template/   and   start  downloading   the   files   of   the   system   and   store   them   in   one   file   (tarball   file)   in  /vz/template/cache each operating system respectively. In my case I will only use one so  at the end I will have one tar file stored in  /vz/template/cache/centos-4i386-default.ta.gz Once you have this file or others, you can start the virtualization. Before that, let's list  what openVZ templates we have. use #vzpkgls the output would look like  centos-4-i386-default You would have more names listed basically that is based on how many templates you  started. At this stage we can start the virtualization. To start the virtualization we need to create virtual private server VPS (if you do not  know this google it). then we can start the virtualization.  to create VPS  # vzctl create 101 --ostemplate centos-4-i386-default what does this mean? vzctl means virtualization control create : self explanatory 101: the VPS id which should be always any integer number above 100. ­­ostemplate: is an argument that takes the name of the template after it

centos­4­i386­default: is the name of the template. The output of this command looks like this Creating VE private area (centos-4-i386-default) Performing postcreate actions VE private area was created this will create a folder inside /vz/private/101 this folder has the root file system of Linux (/). Notice that we did not configure anything yet. you can configure the network manully  from within the system or you can use vzctl again, let's use it #vzctl set 101 --ipadd 192.168.0.18 –save you can use any IP address you like output: Saved parameters for VE 101 #vzctl set 101 --nameserver 192.168.0.17 --save you can use your own DNS server output: Saved parameters for VE 101 now we can start our our template #vzctl start 101 Starting VE ... VE is mounted Adding IP address(es): 192.168.0.18 Setting CPU units: 1000 File resolv.conf was modified VE start in progress... now we have created our Virtual Environment (VE) and we can use it. the next step is to try out some commands  you can execute Linux commands without the need to access the VPS. you need to do  this #vzctl exec 101 service sshd start exec means execute. 101 is the VPS id of the you VE. service sshd start is a Linux command to start the ssh server.

the other way is that you access the VE and run the commands there to access the VE #vzctl enter 101 now you are in the VE. Enjoy Linuxing there. Well,   I   did   not   finish   yet.   I   said   at   the  beginning  that   you can   run  many  operating  systems at the same time. so how? just download another template, let's say fedora and follow the same steps to cache the template then create it with different VPS id let's  say 102. okay since you would have several operating systems running at the same time. How can  you know how many? what are they? etc. #vzlist : means list the running virtual environments Form the output you can know basic information of the VE that are running at your host  machines. Now let's have a look at some command #vzctl restart 101 this just stops and starts the VE again #vzctl stop 101 this stops the VE so it cannot be used but the VPS id is still reserved for this template. if  you do not want this template anymore you can destroy it. Note: stop the VE then destroy #vzctl destroy 101 Destroying VE private area: /vz/private/101 VE private area was destroyed Since the aim of virtualization is to make several servers available and running always  we need to ensure that if the host is rebooted the virtual server is running too. This can  be achieved by  #vzctl set 101 --onboot yes --save

You can do some yumimg for the VE, so if you want to install screen program for the  VE 101 #vzyum 101 install screen The vzyum is a program that installs the package for  the VPS specified by the id. You  can do all the functions that are available by yum, so  #vzyum 101 update #vzyum 101 upgrade packeage-name You can have rpm packages as well #vzrpm 101 -ivh rpm-package.rpm To check how much space, cpu, and what not resources have been used by specific VPS. #vzcalc ­v 101 ­v: virtual id I wish this much of information have helped you to run openVZ To run easyVZ which is the GUI of openVZ  download the package form here http://binarykarma.com/?q=node/1 References: http://www.server­world.info/en/note?os=ce5&p=vz&f=1 http://wiki.openvz.org/Main_Page http://binarykarma.com/?q=node/1

Related Documents

Virtualization
November 2019 13
Virtualization
November 2019 16
Virtualization
August 2019 50
Virtualization Guide
April 2020 4
Open Virtualization:
June 2020 5

More Documents from ""

Menu
December 2019 42
Open Office Class6
December 2019 43
Pictures
December 2019 56
Drrajabi
November 2019 54
Ubuntu Installation Class2
December 2019 45
Virtualization
August 2019 50