PDA

View Full Version : Installing OpenVZ on CentOS 6.4



Fli
04-03-2013, 03:08 PM
This guide worked for me on CentOS 6.4 64bit OS. I dont guarantee this will work for you and you are using this guide on Your own risk. This guide/tutorial is made according to source OpenVZ installation guide: http://openvz.org/Quick_installation

PS: If you plan to use CentOS, you may want to save time and install HyperVM control panel including OpenVZ (Hyper VM is much more advanced than OpenVZ Web Panel and still free). The tutorial on this page is rather manual process on command line. If you want quicker way including HyperVM, go there: http://internetlifeforum.com/linux-server-management/170-installing-hypervm-hypervisor-openvz-x-xen/

1.
Ensure there is yum on server and directory with files exist:
cd /etc/yum.repos.d/

Download open vz repository + import
wget -P /etc/yum.repos.d/ http://download.openvz.org/openvz.repo;
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

Install OpenVZ kernel:
yum install vzkernel

You can use kernel "flawors" too.. (but not required, i did not used)
yum install vzkernel-smp

-smp:
This is optional part of the command. Instead of "smp" you can use other kernel flavor (http://openvz.org/Kernel_flavors)
smp: multiprocessor, up to 4GB ram, 10-20 containers (virt. machines)
entnosplit: multiprocessor, up to 64GB ram, 10-30 containers
enterprise multiprocessor, up to 64GB ram, 20+ containers

2.
Then configure kernel parameters using vim editor:
vim /etc/sysctl.conf

TIP: in VIM editor, to start writing numbers, hit key "a" to stop writing hit Ctrl+C
To write changes in VIM: :w
To discard changes in VIM: :q!
To quit in VIM: q

change values (1, 0) so they are like this:



# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0


# Enables source route verification
net.ipv4.conf.all.rp_filter = 1


# Enables the magic-sysrq key
kernel.sysrq = 1


# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0




3.
Then edit selinux config file:
vim /etc/sysconfig/selinux

Set "SELINUX" from "enforcing" to "disabled"

4.
then reboot server:
reboot

THIS IS ONLY WHEN YOU USE OVH.COM SERVERS: after reboot then if using stock OVH.com kernel and doing command uname -r , i can see:
3.2.13-grsec-xxxx-grs-ipv6-64 #1 SMP
Thats bad, i dont know how to fix this (maybe look on the post under this one, i written some links there), i did it another way: from OVHmanager i reinstalled server and selected Linux, CentOS 6.4 and NATIVE. After this, i got this result when entered uname -r
2.6.32-042stab076.5
this is how it should be

And this is how boot loader (vim /boot/grub/grub.conf) should look like after OpenVZ install:


default=0
timeout=5


title OpenVZ (2.6.32-042stab076.5)
kernel /boot/vmlinuz-2.6.32-042stab076.5 root=/dev/sda1 ro crashkernel=auto SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us
root (hd0,0)
initrd /boot/initramfs-2.6.32-042stab076.5.img
title linux centos6_64
kernel /boot/vmlinuz-2.6.32-358.2.1.el6.x86_64 root=/dev/sda1 ro
root (hd0,0)
initrd /boot/initrd-2.6.32-358.2.1.el6.x86_64.img


6.
If you need to manage OpenVZ from command line and you are on 64bit system, install these tools:
yum install vzctl.x86_64 vzquota.x86_64
(or else yum install vzctl vzquota under 32bit)

7.
Install visual web control panel (OpenVZ Web panel) for managing Virtual machines:
wget -O - http://ovz-web-panel.googlecode.com/svn/installer/ai.sh | sh

After installation, control panel should be available at http://serverip:3000

Fli
04-03-2013, 03:36 PM
OpenVZ CentOS 64bit installation Troubleshooting

According to OpenVZ instalaltion manual, i need to then start OpenVZ by:

"/sbin/service vz start"

But this says "vz: unrecognized service"

Tried to do this:
updatedb
locate vz
which vz

not found..

yum update initscripts
rpm -q initscripts

service vz start dont works

============

Moreover, after reboot, kernel after uname -r is:
3.2.13-grsec-xxxx-grs-ipv6-64

cat /boot/grub/grub.conf shows:
default=0
timeout=5


title linux centos6_64
kernel /boot/bzImage-3.2.13-xxxx-grs-ipv6-64 root=/dev/sda1 ro
root (hd0,0)



I see in /boot/ directory, there is also green color: vmlinuz-2.6.32-042stab076.5

Please what to do to boot it correctly into openVZ kernel?

Ways to go around OVH non-native kernel:

1.

i get it working by reinstalling using Centos 6 + SolusVM template.
followed by installing OpenVZ Web Panel
followed by uninstalling SolusVM.


2.
Guide how to change to stocl centos kernel:
http://change_ovh_kernel.onlinephpfunctions.com/

Another handy guide on OpenVZ install:
http://www.nixgurus.com/virtual-private-server/installing-openvz/