Archive for the OpenVZ Category

OpenVZ ubuntu guest have not networking

Posted on April 14, 2010 with 1 Comment

I created an OpenVZ vps with ubuntu template ubuntu-9.10-x86.tar.gz

After login to VPS, there was no networking enabled in the VPS

root@server70 [/vz/template/cache]# vzctl enter 102
entered into CT 102
root@hosthat:/# ifconfig
root@hosthat:/# ping yahoo.com
ping: unknown host yahoo.com
root@hosthat:/#

Whrn i restarted networking, i got error

root@hosthat:/# /etc/init.d/networking restart
 * Reconfiguring network interfaces...                                                                                        /etc/network/interfaces:15: interface lo declared allow-auto twice
ifdown: couldn't read interfaces file "/etc/network/interfaces"
/etc/network/interfaces:15: interface lo declared allow-auto twice
ifup: couldn't read interfaces file "/etc/network/interfaces"
                                                                                                                       [fail]
root@hosthat:/#

It says

/etc/network/interfaces:15: interface lo declared allow-auto twice

I checked file /etc/network/interfaces and found two entry for lo

root@hosthat:/dev# cat /etc/network/interfaces
# This configuration file is auto-generated.
# WARNING: Do not edit this file, otherwise your changes will be lost.
# Please edit template /etc/network/interfaces.template instead.
 
 
auto lo
iface lo inet loopback
        address 127.0.0.1
        netmask 255.0.0.0
        broadcast 127.255.255.255
        up ip route replace 127.0.0.0/8 dev lo
 
 
# Auto generated interfaces
auto lo
iface lo inet loopback
 
auto venet0
iface venet0 inet static
        address 127.0.0.1
        netmask 255.255.255.255
        broadcast 0.0.0.0
        up route add -net 192.0.2.1 netmask 255.255.255.255 dev venet0
        up route add default gw 192.0.2.1
auto venet0:0
iface venet0:0 inet static
        address 67.228.104.123
        netmask 255.255.255.255
        broadcast 0.0.0.0
 
root@hosthat:/dev#

This is fixed by commenting lo entry in file /etc/network/interfaces.template

root@hosthat:/dev# cat /etc/network/interfaces.template
 
auto lo
iface lo inet loopback
        address 127.0.0.1
        netmask 255.0.0.0
        broadcast 127.255.255.255
        up ip route replace 127.0.0.0/8 dev lo
 
root@hosthat:/dev# vi /etc/network/interfaces

After commenting, the file content look like

#auto lo
#iface lo inet loopback
#        address 127.0.0.1
#        netmask 255.0.0.0
#        broadcast 127.255.255.255
#        up ip route replace 127.0.0.0/8 dev lo

After rebooting, network interfaces started working properly.

root@hosthat:/# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2550 (2.5 KB)  TX bytes:2550 (2.5 KB)
 
venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:127.0.0.1  P-t-P:127.0.0.1  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:316733 errors:0 dropped:0 overruns:0 frame:0
          TX packets:168152 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:473833406 (473.8 MB)  TX bytes:9101935 (9.1 MB)
 
venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:67.228.104.123  P-t-P:67.228.104.123  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
 
root@hosthat:/#

Installing OpenVZ

Posted on June 17, 2009 with 4 Comments

Install instructions for OpenVZ available at

http://wiki.openvz.org/Quick_installation

Here is what i done to install OpenVZ on CentOS 5 32 bit OS/

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

Find if OS is 32 or 64 bit using uname -a

# uname -a
Linux server84.hosthat.com 2.6.18-92.1.18.el5 #1 SMP Wed Nov 12 09:30:27 EST 2008 i686 i686 i386 GNU/Linux
#

In this case, i686 in uname -a result means the OS is 32 bit.

Now we will find list of openvz kernal available

# yum list|grep ovzkernel
ovzkernel.i686                          2.6.18-128.1.1.el5.028stab062.3
ovzkernel-PAE.i686                      2.6.18-128.1.1.el5.028stab062.3
ovzkernel-PAE-devel.i686                2.6.18-128.1.1.el5.028stab062.3
ovzkernel-devel.i686                    2.6.18-128.1.1.el5.028stab062.3
ovzkernel-ent.i686                      2.6.18-128.1.1.el5.028stab062.3
ovzkernel-ent-devel.i686                2.6.18-128.1.1.el5.028stab062.3
ovzkernel-xen.i686                      2.6.18-128.1.1.el5.028stab062.3
ovzkernel-xen-devel.i686                2.6.18-128.1.1.el5.028stab062.3
#

We need to install .686 version of the kernel. Kernel with PAE is for servers with more than 4 GB of RAM.

We check memory available in the server with free -m

# free -m
             total       used       free     shared    buffers     cached
Mem:          2017       1662        355          0        175       1319
-/+ buffers/cache:        167       1850
Swap:         4071          0       4071
#

Its only 2 GB, so we can install non PAE kernel. For severs with more than 4 GB of RAM, always better to get 64 bit OS.

So we install

yum install ovzkernel.i686 ovzkernel-devel.i686

After install finished, we get

Installed: ovzkernel.i686 0:2.6.18-128.1.1.el5.028stab062.3 ovzkernel-devel.i686 0:2.6.18-128.1.1.el5.028stab062.3

To boot from this kernel, we need o configure boot loader, grub.

vi /boot/grub/grub.conf

The file contains

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/hde3
#          initrd /initrd-version.img
#boot=/dev/hde
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-128.1.1.el5.028stab062.3)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-128.1.1.el5.028stab062.3 ro root=LABEL=/1
        initrd /initrd-2.6.18-128.1.1.el5.028stab062.3.img
title CentOS (2.6.18-92.1.18.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-92.1.18.el5 ro root=LABEL=/1
        initrd /initrd-2.6.18-92.1.18.el5.img
title CentOS (2.6.18-92.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-92.el5 ro root=LABEL=/1
        initrd /initrd-2.6.18-92.el5.img

Here default=0 means first entry in the file get booted, that is

title CentOS (2.6.18-128.1.1.el5.028stab062.3)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-128.1.1.el5.028stab062.3 ro root=LABEL=/1
        initrd /initrd-2.6.18-128.1.1.el5.028stab062.3.img

This is our new openvz kernel, so nothing to change in boot loader.

Now need to make some changes in

vi /etc/sysctl.conf

At the end of the file add

# 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

Disable SELinux if you have not already done.

vi /etc/sysconfig/selinux

In the file change value of SELINUX to disabled.

SELINUX=disabled

Now reboot the server, so server will boot with new openvz kernel

reboot

After reboot, we have the new kernal shown in uname -a

root@server84 [~]# uname -a
Linux server84.hosthat.com 2.6.18-128.1.1.el5.028stab062.3 #1 SMP Tue May 5 17:31:34 MSD 2009 i686 i686 i386 GNU/Linux
root@server84 [~]#

Now install

yum install vzctl vzquota

You need to do a reboot now

reboot

To create a VPS, download an OS Template from

http://download.openvz.org/template/precreated/

To create an VPS with ubuntu OS

cd /vz/template/cache
wget http://download.openvz.org/template/precreated/ubuntu-9.04-x86.tar.gz

Now you have the OS template cache, before creating VPS, i need a FREE IP

In cpanel servers, go to

Main >> IP Functions >> Show or Delete Current IP Addresses

Delete a IP that is not used.

On non Cpanel servers you need to edit the file

vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0

OR

vi /etc/sysconfig/network-scripts/ifcfg-eth0:X

Here is the syntax to create a new VPS

vzctl create CTID --ostemplate osname
vzctl set CTID --ipadd a.b.c.d --save
vzctl set CTID --nameserver a.b.c.d --save
vzctl start CTID

To create VSP i run following commands

vzctl create 101 --ostemplate ubuntu-9.04-x86
vzctl set 101 --ipadd 67.159.32.134 --save
vzctl set 101 --nameserver vps2.hosthat.com --save
vzctl set 101 --nameserver 208.67.222.222 --save
vzctl set 101 --onboot yes --save
vzctl set 101 --kmemsize 60000000 --save
vzctl set 101 --privvmpages 900000 --save
vzctl set 101 --numproc 1000 --save
vzctl set 101 --numtcpsock 500 --save
vzctl set 101 --tcpsndbuf 20000000:35000000 --save
vzctl set 101 --tcprcvbuf 20000000:35000000 --save
vzctl set 101 --diskspace 10048576:10153434 --save
vzctl set 101 --cpuunits 1000 --save
vzctl start 101

Here are the results

root@server84 [~]# vzctl create 101 --ostemplate ubuntu-9.04-x86
Unable to get full ostemplate name for ubuntu-9.04-x86
Creating container private area (ubuntu-9.04-x86)
vzquota : (error) Quota on syscall for id 101: File exists
vzquota on failed [3]
vzquota : (error) Quota is not running for id 101
Performing postcreate actions
Container private area was created
root@server84 [~]# vzctl set 101 --ipadd 67.159.32.134 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --nameserver vps2.hosthat.com --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --nameserver 208.67.222.222 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --onboot yes --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --kmemsize 60000000 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --privvmpages 900000 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --numproc 1000 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --numtcpsock 500 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --tcpsndbuf 20000000:35000000 --save
Saved parameters for CT 101
vzctl set 101 --tcprcvbuf 20000000:35000000 --save
root@server84 [~]# vzctl set 101 --tcprcvbuf 20000000:35000000 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --diskspace 10048576:10153434 --save
Saved parameters for CT 101
root@server84 [~]# vzctl set 101 --cpuunits 1000 --save
Saved parameters for CT 101
root@server84 [~]#

Now lets start VSP

root@server84 [~]# vzctl start 101
Starting container ...
vzquota : (error) Quota on syscall for id 101: File exists
vzquota on failed [3]
root@server84 [~]#

The error was due to quota was not enabled in the hard disk.

This error was fixed by adding usrquota in /etc/fstab for / partition

root@server84 [/]# cat /etc/fstab
LABEL=/1                /                       ext3    defaults,usrquota        1 1
LABEL=/boot1            /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-hde2         swap                    swap    defaults        0 0
/usr/tmpDSK             /tmp                    ext3    defaults,noauto        0 0
/tmp             /var/tmp                    ext3    defaults,bind,noauto        0 0
root@server84 [/]#

To start VSP

root@server84 [/]# vzctl start 101
Starting container ...
Container is mounted
Adding IP address(es): 67.159.32.134
Setting CPU units: 1000
Configure meminfo: 900000
File resolv.conf was modified
Container start in progress...
root@server84 [/]#

To set root password

vzctl enter 101
passwd
root@server84 [/]# vzctl enter 101
entered into CT 101
root@server84:/# cat /etc/*issue
Ubuntu 9.04 \n \l
 
root@server84:/# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@server84:/#

Now VPS is ready, i am able to connect to VPS from my computer with SSH.

Tags: , , ,

Category: OpenVZ