openvz Server refused to allocate pty solution

SSH returns: "Server refused to allocate pty" upon login.
OR:
"enter into VE 101 failed
Unable to open pty: No such file or directory"


This solution is for CentOS VE's.

Solution #1
At the HN (hardware node) enter (replace 101 with your VE-id / CT-id):

$ vzctl exec 101 /sbin/MAKEDEV tty
$ vzctl exec 101 /sbin/MAKEDEV pty

Then enter the VE/CT:

$ vzctl enter 101

And make sure the udev rpm is gone:
$ rpm -e --nodeps udev
...else the problem comes back after a VE reboot.

 

Solution #2

If the problem persists try this:

$ vzctl exec 101 rpm -e --nodeps udev
$ nano -w /var/lib/vz/root/101/etc/rc.sysinit

or...
$ nano -w /vz/root/101/etc/rc.sysinit

Find:
/sbin/start_udev
Replace by:
#/sbin/start_udev
/sbin/MAKEDEV tty
/sbin/MAKEDEV pty
$ vzctl restart 101

 

Solution #3

If the problem persists after reboot, repeat the steps above and create the following file within the VE/CT:

/etc/udev/makedev.d/51-udev.nodes

...with these contents:

# These device have to be created manually
tty0
tty1
tty2
tty3
ttyp0
ttyp1
ttyp2
ttyp3
ptyp0
ptyp1
ptyp2
ptyp3

Solution #4

Sometimes the problem can be very persistent. If none helps, the following solution might help. It copies devices from the hostnode to the container.

Create and edit /etc/vz/conf/101.mount likewise:

#!/bin/bash
VEID=`basename $0 | sed -e 's/\(.*\)\..*/\1/g'`
rm -f /var/lib/vz/private/${VEID}/dev/*
rsync -a /dev/* /var/lib/vz/private/${VEID}/dev

$ chmod 700 /etc/vz/conf/101.mount
$ vzctl restart 101

References:
http://forum.openvz.org/index.php?t=msg&goto=14953
http://wiki.openvz.org/Container_enter_failed
http://linuxhostingsupport.net/blog/tag/sbinmakedev-pty

 

bash_history not working in VE (virtual environment) of openvz

Add the following line to file /root/.bashrc

HISTFILE=/root/.bash_history

Now, .bash_history will be created and filled!

Using vzdump snapshot to backup without downtime

It's a while ago since I've written my last serious article but this one is really worth reading. The last few months I'm testing the possibilities to make Linux hosting more flexible and less independent on hardware. As an "Open source CentOS Linux enthusiast" I found OpenVZ. I cite: "OpenVZ is an Operating System-level server virtualization solution, built on Linux. OpenVZ creates isolated, secure virtual environments — VEs (otherwise known as virtual private servers, or VPSs) on a single physical server enabling better server utilization and ensuring that applications do not conflict."
After some tests I managed to get it running properly. Some VE configuration changes are necessary to let a virtual server work with Java JRE in a good manner.

Anyway, there's a tool called "vzdump" (http://wiki.openvz.org/Backup_of_a_running_VE_with_vzdump) to make backups of VEs.

There are 3 backup modes availabe:
1) bad (e.g. vzctl stop 101; vzdump 101; vzctl start 101)
2) better (e.g. vzdump --suspend 101)
3) best (e.g. vzdump --dumpdir /home --snapshot 101)

1 - bad:
==========
Only useful if you first STOP your VE in order to make a backup. Making an online backup without suspending the VE may lead to inconsistent data)

2- better:
==========
Sufficient in most cases. Makes an online backup with only a few seconds downtime of the VE. The vzdump tool takes care of stopping and resuming the VE. All services (e.g. Apache) are restored automatically.

3- best:
==========
Makes an backup without any downtime of the VE.


After pulling my hairs out, reading forums and trying all kinds of possibilities I've finally found the solution. In fact, it's quite easy but the lack of documentation makes it hard.

All you need to do is setup a Linux box like this:

Use LVM2 'volume group' (called 'sysvg') with these 'logical volumes':

  • "/", type ext3, size 8 GB for example;
  • "/vz", type ext3, size 8 GB for example;
  • "/var/freespace", no filesystem required, size at least 512MB;
  • "swap", type swap, size 2 times internal memory;

 

After the Linux installation has finished remove the logical volume freespace by entering the commands:
# umount /var/freespace
# lvremove /dev/sysvg/freespace
Now the the command vzdump --dumpdir /home --snapshot 101 (or likewise) should work!
Restoring a container can be done like this: vzdump --restore /home/vzdump-101.tgz 101
(or vzrestore
/home/vzdump-101.tgz 101)

Also checkout the command vzmigrate for moving VEs to a new host node (physical server).


Let me explain what happens. Vzdump makes a temporarily logical volume with type "snapshot" of 512MB and mounts it on "/vzsnap". (That's why you need at least 512MB free space in the volume group.)
This snapshot is taken from the logical volume mounted on '/vz'. And that's why all OpenVZ stuff (e.g. /vz and subdirs) needs to be in that '/vz'-logical-volume.
Okay, after vzdump has taken the snapshot of '/vz' all it has to do is travel down to the data of the selected VE and put in a "tar"-file. After this is done, the file will be moved to its final destination (dumpdir) and the temporarily "/vzsnap" will be deleted.

Good luck and let me know if this article is useful for you!

Tip: You should have at least 512MB free space available in the volume group. To check this, use vgdisplay and look for "Free PE / Size".

Speciale Joomla! hostingdienst gestart

Link: http://www.joomlajoomla.nl

Amtex heeft deze week een speciale hostingdienst gestart gericht op Joomla!. Joomla! is een vrij web content management systeem dat in Nederland steeds meer aan populariteit wint.

Voorheen was het voor ontwikkelaars nog een hele klus om Joomla! te installeren. Meer dan 1700 bestanden moesten naar een webruimte worden geupload. En daarna het instellen van directory-permissies, PHP instellingen en database connecties.

Met Joomla! Hosting Pro wordt Joomla! in een paar klikken automatisch geinstalleerd en geconfigureerd. Webdevelopers en vormgevers kunnen zich nu direct richten op de realisatie van Joomla! websites i.p.v. het tijdrovende upload/installatie proces.

In de nabije toekomst wil Amtex het installatieproces nog verder vereenvoudigen door vrije topextensies erbij te leveren. Op die manier kunnen webdevelopers zelf aanvinken of ze een webshopextensie zoals `virtuemart` of een nieuwsbriefpakket zoals `letterman` automatisch wensen mee te installeren.

Joomla! Hosting Pro is voor 7,95 p/m (excl. BTW) via http://www.joomlajoomla.nl te verkrijgen.

CFM codesnippet: navigation through large datasets with mySQL (SQL_CALC_FOUND_ROWS)

Codesnippet:
Following code uses CFM + MySQL to select a part of all available records from a table. But also use 'SQL_CALC_FOUND_ROWS' to obtain the total amount of records in the table.
This way you can make page navigation through large datasets.

Requires:
An installed mysql-connector-java-3.x (jar)

Following codesnippet is provided by BehindThe.net. Thanks Ernst!


<!--- use transaction for isolating foundRows --->
<cftransaction isolation="read_uncommitted">
<!--- get records from Database --->
<cfquery name="getMany" datasource="#application.datasources[1].name#">
SELECT SQL_CALC_FOUND_ROWS
job_id
,job_code
FROM jobs
ORDER BY #orderBy#
<cfif isNumeric(arguments.maxRows)>
LIMIT #firstRowLimit#,#arguments.maxRows#
</cfif>
</cfquery>

<cfquery name="getFoundRows" datasource="#application.datasources[1].name#">
SELECT found_rows() AS foundRows
</cfquery>
</cftransaction>

<!--- add a column to getMany query and set first row with value of foundRows --->
<cfset newColumnValues[1] = getFoundRows.foundRows>
<cfset newColumn = QueryAddColumn(getMany, "foundRows", newColumnValues)>