Tampilkan postingan dengan label Virtualization. Tampilkan semua postingan
Tampilkan postingan dengan label Virtualization. Tampilkan semua postingan

Rabu, 28 Januari 2015

How to Install Openvz on CentOs


CentOS is one of the most popular free and open source server operating systems. OpenVZ is a popular open source system for creating virtual private servers. Combine the two together, and you have a low-cost yet powerful VPS system. The following is a brief installation guide to get OpenVZ running on CentOS.

Add the OpenVZ repository to Yum:

#cd /etc/yum.repos.d
#wget http://download.openvz.org/openvz.repo
#rpm –import http://download.openvz.org/RPM-GPG-Key-OpenVZ

Edit openvz.repo and disable the [openvz-kernel-rhel5] repository (enabled=0) and enable the [openvz-kernel-rhel6] repository.

Install the OpenVZ kernel:

Search using:
#yum search vzkernel

Choose the kernel you want and install:
yum install vzkernel

(This should automatically update Grub to your new kernel. If not, you may need to manually edit your grub configuration).

Install OpenVZ user tools:

#yum install vzctl vzquota

Edit /etc/sysctl.conf and ensure you have these settings:
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
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1

If your IP addresses for your virtual machines will be on a different subnet than your host machine, you need to make sure you have this in /etc/vz/vz.conf:

NEIGHBOUR_DEVS=all

Disable SELinux bye editing /etc/sysconfig/selinux:

# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled

Reboot

You should now have a working OpenVZ installation. You should then test it to verify that the kernel is running and that you are able to create containers.

Selasa, 27 Januari 2015

How to migrate OpenVZ to KVM/VMWare

To migrate your OpenVZ virtual server to a KVM/VMWARE just follow these steps:

  • First thing you do is to install a KVM machine with the same operating system.  Preferably  the same point revision too!
  • Now logon to your OpenVZ box and run

# yum install mingetty

  • This will install a load of dependencies –  they are all required and provide the core functions to enable your machine to boot successfully!
  • Edit the file /etc/inittab and add in the following:
# Run gettys in standard runlevels

1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

This will enable the machine to actually get a logon prompt!

  • Now.. sync the OpenVZ box to the new box

rsync –exclude=/etc/fstab –exclude=/boot –exclude=/proc –exclude=/lib/modules/ –exclude=/etc/udev –exclude=/lib/udev –exclude=/sys -e ssh –delete –numeric-ids -avpogtStlHz / root@IPTOKVM:/

This will copy every thing from the old box to the new box, but will exclude the kernel files that you will need to boot the machine!  Trust me.. it works!
  •     Power down your OpenVZ Box
  •     Reboot and start your KVM box.

This process has worked for me pretty much every time when migrating Centos 5 and Centos 6.  I am pretty certain that the same basic idea will work with other distros.