vzmigrate fails with error 80

Problem:
When doing a migration with Virtuozzo Software at the end it wants to start the container on the destination node but might fail with errorcode=80.



[root@vz098 ]# vzmigrate --keep-dst -r no --ssh="-p 2233" vz099.server.invalid 132132
root@vz099.server.invalid's password:
Connection to destination HN (vz099.server.invalid) is successfully established
Moving/copying VE#132132 -> VE#132132, [], [] ...
Start of CT 132132 migration (private /vz/private/132132, root /vz/root/132132)
tracker pid 12801
Syncing private area '/vz/private/132132'
- 100% |*******************************************************************************************|
done
Stopping VE#132132 ...
done
Fast syncing private area '/vz/private/132132'
\ 100% |********************************************************************************************|
done
OfflineManagement CT#132132 ...
done
Starting CT#132132 ...
vzctl : Container start failed
vzctl failed, exitcode=80
Can't move/copy VE#132132 -> VE#132132, [], [] : vzctl failed, exitcode=80
Starting VE#132132 ...
done

The manual page only says:

error code 80:
Can not set up traffic shaping


Solution:

In the config file (/etc/vz/conf/132132.conf) there is traffic shapping configured for a different amiount of available interfaces. E.g. vz098 has eth0 and eth1 whereas vz099 only has eth0.
So you might want to change

RATE="eth0:1:10240 eth1:1:102400"

to

RATE="eth0:1:10240"

Broadcast into Virtuozzo Container

Problem:
Broadcasting into a Virtuozzo container is not possible with the standard (host-routed) IP setup. So you cannot run e.g. a samba or dhcp server there.


Solution:

You have to set up IP in bridged networking mode:
If your container (here VEID 1006) already has some IP through your standard setup, remove it:

vzctl set 1006 --ipdel 192.168.1.6 --save

Now setting up bridged networking mode:
Container has IP 192.168.1.6, NS and gateway is 192.168.1.1, interface within the container will be eth0

vzctl set 1006 --netif_add eth0 --save
vzctl set 1006 --ifname eth0 --ipadd 192.168.1.6 --save
vzctl set 1006 --ifname eth0 --nameserver 192.168.1.1 --save
vzctl set 1006 --ifname eth0 --gateway 192.168.1.1 --save
vznetcfg net new vznetwork1
vzctl set 1006 --ifname eth0 --network vznetwork1 --save
vznetcfg net addif vznetwork1 eth0

Set up of an OpenSuse 11.1 container on Virtuozzo 4.6

Problem:
Set up of an OpenSuse container on Virtuozzo 4.6 is broken…


Solution:

When trying to install the container the usual way, you get these error messages:
mkdir suse
cd suse
wget http://downloads.swsoft.com/cgi-bin/getfile.pl/suse/11.1/x86_64/suse-11.1-x86_64-ez-4.0.0-6.swsoft.noarch.rpm
rpm -ihv *
vzpkg create cache suse-11.1-x86_64
Creation OS template cache for suse-11.1-x86_64 template
Error: URL $SUSE_SERVER/download/suse-11.1 contents undefined variable
You can define this variable in /etc/vztt/url.map.
See Virtuozzo Installation Guide for more details.

So we set in /etc/vztt/url.map the variable
$SUSE_SERVER http://download.opensuse.org

But we still get an error:
Creation OS template cache for suse-11.1-x86_64 template
Loading "rpm2vzrpm" plugin
Cleaning up xml metadata
0 metadata files removed
Loading "rpm2vzrpm" plugin
Making cache files for all metadata files.
This may take a while depending on the speed of this computer
Setting up repositories
http://download.opensuse.org/distribution/11.1/repo/oss/suse/repodata/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Cannot open/read repomd.xml file for repository: base0
failure: repodata/repomd.xml from base0: [Errno 256] No more mirrors to try.
Error: failure: repodata/repomd.xml from base0: [Errno 256] No more mirrors to try.
Error: /usr/share/vzyum/bin/yum failed, exitcode=1

We go to
cd /vz/template/suse/11.1/x86_64/config/os/default/

and edit the repositories file:
$SUSE_SERVER/distribution/11.1/repo/oss/suse/

and try another vzpkg create cache suse-11.1-x86_64:
yes, better luck this time:
...
Finished.
OS template suse-11.1-x86_64 cache was created

Virtuozzo 4.6 does not create VE 1 at installation time

Problem:
After installing the latest Virtuozzo Software (V 4.6) there is no VE 1 and the hardware node cannot be accessed by PMC or similiar tools.


Solution:

From V4.6 on you need to install PVA (Parallels Virtual Automation) additonally for having a VE1.
So you first install Virtuozzo:

./vzinstall-linux-i386.bin install

Then you need to supply a valid license:

echo "BLABLA-YOUR-LICENSE" | vzlicload -i

Finally you can try to install PVA:

./pva-setup-deploy.x86_64

which gave following error:

Dependency check failed:
libapr-1.so.0()(64bit) is needed by httpd-2.2.3-6.el5.centos.1.x86_64
libaprutil-1.so.0()(64bit) is needed by httpd-2.2.3-6.el5.centos.1.x86_64

(I am running OS Centos 5.6)
Tried my luck with

yum install httpd

and again with

./pva-setup-deploy.x86_64 install

and this time everything went smoothly.

Find spamming website on shared server

Problem:
Your shared server is misused for spamming using some php script. Since there are hundreds of websites or domains on your server it is not easy to find out which domain or which script the culprit is.


Solution:
Write a wrapper script:

Find the active sendmail “path” in php.ini:

grep sendmail_path /etc/php.ini

This is usually something like:

sendmail_path = /usr/sbin/sendmail -t -i

Write a new shell script /usr/local/sbin/sendmail_php.sh:

#!/bin/bash
logger php_mail: dir=${PWD}
/usr/sbin/sendmail -t -i $*

Change /etc/php.ini accordingly:

sendmail_path = /usr/local/sbin/sendmail_php.sh

Restart your webserver.

Now when some php form is using mail() you will see following entry in your server logs:

May 3 11:29:58 www42 logger: php_mail: dir=/var/www/vhosts/example.com/httpdocs/guestbook

Copy column in sql

Problem:
Copy the content of one column of a sql table into another column.


Solution:

both columns in same table:

update table1 set column2 = column1

both columns in different tables:

update table2 set column2 = (select column1 from table1)

How to test if mod_rewrite is enabled and working

Problem:
Many CMS and Blogs need mod_rewrite. However the usual user is not able to debug the problem if the pre-configured .htaccess is not working as expected.


Solution:
Write a simple .htaccess to find out if mod_rewrite is even working for your root webdirectory: Create a file .htaccess with followig content:

RewriteEngine On
RewriteRule ^i1.html$ /i2.html

Create two more testfiles:
echo "1" >i1.html
echo "2" >i2.html

If you fire up your browser with
http://yourdomain/i1.html
and you see “1” mod_rewrite is not working. If you see “2” then mod_rewrite is working fine and you do not have to bugger your hoster to check if mod_rewrite ist doing its job 😉