Difference between revisions of "Physical to container"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(rsync/scp as a copy method)
Line 10: Line 10:
 
* Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh).
 
* Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh).
  
* Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to <code>/vz/private/123/</code> directory (so there will be directories such as <code>/vz/private/123/bin</code>, <code>etc</code>, <code>var</code> and so on).
+
* Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to <code>/vz/private/123/</code> directory (so there will be directories such as <code>/vz/private/123/bin</code>, <code>etc</code>, <code>var</code> and so on). This could be done by scp or rsync.
  
 
* Set some VE parameters. You have to add <code>OSTEMPLATE=xxx</code> line to <code>/etc/vz/conf/123.conf</code> file, where <code>xxx</code> would be distribution name (like <code>debian-3.0</code>) for vzctl to be able to make changes specific for this distribution.
 
* Set some VE parameters. You have to add <code>OSTEMPLATE=xxx</code> line to <code>/etc/vz/conf/123.conf</code> file, where <code>xxx</code> would be distribution name (like <code>debian-3.0</code>) for vzctl to be able to make changes specific for this distribution.

Revision as of 00:40, 26 October 2006

A rough description of how to migrate existing physical server into a VE.

What you need to do in order to migrate is:

  • Prepare an “empty” VE. For OpenVZ this would mean the following (assume you choose VE ID of 123):
mkdir /vz/root/123 /vz/private/123
cat /etc/vz/conf/ve-vps.basic.conf-sample > /etc/vz/conf/123.conf
  • Stop most services on a machine to be migrated. “Most” means services such as web server, databases and the like — so you will not loose your data. Just leave the bare minimum (including ssh).
  • Copy all your data from the machine to an OpenVZ box. Say you'll be using VE with ID of 123, then all the data should be placed to /vz/private/123/ directory (so there will be directories such as /vz/private/123/bin, etc, var and so on). This could be done by scp or rsync.
  • Set some VE parameters. You have to add OSTEMPLATE=xxx line to /etc/vz/conf/123.conf file, where xxx would be distribution name (like debian-3.0) for vzctl to be able to make changes specific for this distribution.
Also, you have to supply an IP for a new VE:
vzctl set 123 --ipadd x.x.x.x --save
  • You have to edit some files inside a VE. For example, virtual server does not have real ttys, so you have to disable getty in /etc/inittab (i. e. /vz/private/123/etc/inittab). Also, link /etc/mtab to /proc/mounts.
sed -i -e '/getty/d' /vz/private/123/etc/inittab
rm -f /vz/private/123/etc/mtab
ln -s /proc/mounts /vz/private/123/etc/mtab 
There might be other adjustments needed.
  • Try to start your new VE:
vzctl start 123
If anything goes wrong, try to find out why and fix. If you have enough Linux experience, it can be handled.