Linux Security Forum
 
 

Go Back   Linux Security Forum > Linux Security > Articles

Notices

Articles Linux Security Articles

Reply
 
Thread Tools
  #1  
Old 08-21-2008
drendeah drendeah is offline
Super Moderator
 
Join Date: Jul 2008
Posts: 294
Blog Entries: 1
Rep Power: 101
drendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond reputedrendeah has a reputation beyond repute
Default Taking it further: XEN and OpenVZ on CentOS 5.2 x86_64

Taking it further: XEN and OpenVZ on CentOS 5.2 x86_64
By drendeah

In a prior tutorial I showed you how to install XEN on CentOS 5.2 to isolate services. This is a good aproach when you have a dedicated server and you want to isolate your services. However, what will you do if you have a dedicated server and you rent Virtual Machines (VMs)?

Your customers will face the same problem that you faced initially. They will end up
running their services unseparated on the same VM. Not anymore, today I will explain a technique to overcome this limitation. We will further divide the VM into multiple Virtual Environments (VEs) using OpenVZ.

OpenVZ is a virtualization technology / software that, unlike XEN, allows for resource sharing. You have the ability to allocate the same amount of cpu/memory to several VEs and they will use it as needed. This kind of virtualization is perfect for isolating services inside of a XEN VM. This way your customers can benefit from service isolation too.

I will assume that you have properly installed CentOS with XEN and have successfully created a CentOS 5.2 x86_64 Xen VM. We will be doing the install from the console.

Installing OpenVZ

To install OpenVZ on a XEN VM you will need to log into the VM.

Code:
wget http://download.openvz.org/kernel/branches/rhel5-2.6.18/028stab053.14/ovzkernel-xen-2.6.18-53.1.19.el5.028stab053.14.x86_64.rpm
The above command will download the latest release of OpenVZ kernel-xen at the time this article was written.

Now that we've downloaded the RPM, let's install it.

Code:
rpm -ivh ovzkernel-xen-2.6.18-53.1.19.el5.028stab053.14.x86_64.rpm
The above command installs the OpenVZ kernel.

However, we will need some more supporting RPMs to install before we can actually use OpenVZ.

Issue the following commands:
Code:
wget http://download.openvz.org/utils/vzctl/current/vzctl-3.0.22-1.x86_64.rpm
wget http://download.openvz.org/utils/vzctl/current/vzctl-lib-3.0.22-1.x86_64.rpm
wget http://download.openvz.org/utils/vzquota/current/vzquota-3.0.11-1.x86_64.rpm
Wait for the packages to download and then install them:
Code:
rpm -ivh vzquota-3.0.11-1.x86_64.rpm vzctl-*
Now we will need a template for our VEs. We will use a precreated template. (You are free to create your own templates or use template metadata to generate the templates locally, but for tutorial purposes i will show how to use a precreated template).

We will download a CentOS 4 x86_64 minimal precreated template.

Code:
wget http://download.openvz.org/template/precreated/centos-4-x86_64-minimal.tar.gz
Now we must move the template to the correct directory so it can be used by OpenVZ.

Code:
mv centos-4-x86_64-minimal.tar.gz  /vz/template/cache/
Now we will need to make some changes to /etc/sysctl.conf. Open it with your favourite editor and make sure you change the following settings to look like this:

Code:
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
Another thing, we must disable SELinux for OpenVZ to operate. Open /etc/sysconfig/selinux and modify it like this:

Code:
SELINUX=disabled
Having done all of this, it's time to reboot the VM and see our new OpenVZ setup running.

Code:
reboot
Login to your VM again and issue the command:

Code:
uname -r
It should reveal the following information:

Code:
2.6.18-53.1.19.el5.028stab053.14xen
Congrats! You have a working setup of XEN+OpenVZ.

Creating a OpenVZ Virtual Environment

Now let's create our first OpenVZ VE inside the XEN VM.

Code:
vzctl create 200 --ostemplate centos-4-x86_64-minimal --ipadd 10.10.10.1 --hostname testve1
After the creation process is complete issue the following command.

Code:
vzlist -a
You should see your newly created VE in the list.

To start the VE issue the following command.

Code:
vzctl start 200
And, to enter into the VE issue the following command.

Code:
vzctl enter 200
Now you are inside the VE. Your shell prompt will look this way:
Code:
entered into VE 200
[root@testve1 /]#
Now it is up to you to configure the VE properly, configure more VEs, and whatever may cross your mind. Have fun in the wonderful world of virtualization!

This article was brought to you by LinuxSecurityForum.org, become a member by clicking here: Register
Reply With Quote
Sponsored Links
Reply

Bookmarks

Tags
centos, further:, openvz, taking, x86_64

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:15 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Advertisement System V2.3 By   Branden