Create a Virtual Server with OpenVZ

by Mike on May 16, 2009

in Virtualization

Create a Virtual Server
Once you have OpenVZ installed you will be able to begin the process of installing individual containers.

Using the vzctl command you will be able to create a virtual server in less than 5 minutes.  One of the steps that must be completed before you begin is to move the template you will use into the /vz/template/cache.

The first command uses a template and sets the configuration as a vps.basic.  The 26 is a identifier for the vps.  It makes sense to use the last octet of the IP Address for this identifier.  Thus this is used for  In the example the centos template is used.

# vzctl create 26 – -ostemplate centos-5 –config vps.basic
Creating VE private area (centos-5-i386-default)
Performing postcreate actions
VE private area was created

This setting provides for the VE to start on boot.  This is probably what you want.  However, the default is not to start a VE on boot so if you do not use this setting it will remain off.

# vzctl set 26 – -onboot yes –save
# vzctl set 26 – -hostname admin26–save

# vzctl set 26 – -ipadd –save

# vzctl set 26 – -nameserver –save

# vzctl start 26
Starting VE …
VE is mounted
Adding IP address(es):
Setting CPU units: 1000
Set hostname: admin26
File resolv.conf was modified
VE start in progress…

# vzctl set 26 – -userpasswd root:bcrY67LD3 –save
Changing password for user root.
passwd: all authentication tokens updated successfully.
Saved parameters for VE 26

Now use vzlist to show which virtual servers are running.

# vzlist -a
26         16 running    admin26

Previous post:

Next post: