How To Create a Container/VPS Machine With OpenVZ Server

After We have installed a OpenVZ VPS Master Server, We can create a container or VPS Machine on it.
Please see this URL if you still don’t have OpenVZ VPS Master Server running/installed on your server.
http://wowtutorial.org/en/tutorial/97.html

Create a VPS Machine in OpenVZ VPS Master Server

First we need to make sure we have a vps config in /etc/vz/conf
All vps config that we have created will store in this directory
VPS config is use to define a harddrive space, memory, and other config stuff

Example there are 3 config file there

$ls -al /etc/vz/conf
ve-light.conf-sample
ve-vps.basic.conf-sample
ve-vps.heavy.conf-sample

Next, We will need to make sure we have precreated template in /vz/template/cache directory

$ls -al /vz/template/cache

centos-4-i386-default.tar.gz fedora-core-5-i386-minimal.tar.gz-old
centos-4-i386-default.tar.gz-old fedora-core-6-i686-default.tar.gz
centos-4-i386-minimal.tar.gz fedora-core-7-i386-default.tar.gz
centos-4-i386-minimal.tar.gz-old fedora-core-7-i386-minimal.tar.gz
centos-5-i386-minimal.tar.gz mandriva-2006-i386-minimal.tar.gz
debian-3.1-i386-minimal.tar.gz opensuse-10-i386-default.tar.gz
fedora-8-i386-minimal.tar.gz slackware-12.0-i386-minimal.tar.gz
fedora-8-i386-minimal.tar.gz.1 ubuntu-6.06-i386-minimal.tar.gz
fedora-core-5-i386-default.tar.gz ubuntu-7.10-i386-minimal.tar.gz
fedora-core-5-i386-minimal.tar.gz

If we have a config and precreated template we can start create a VPS Machine on OpenVZ VPS Master Server
We will use vzctl command to create,start,stop,destroy,etc.. the VPS Machine

Example command to create a VPS Machine:

$vzctl create NODE --config yourconfigfile --ostemplate yourostemplate --ipadd yourvpsipadd

Here is the real examples command

$vzctl create 1 --config vps.basic --ostemplate centos-4-i386-default --ipadd 10.10.1.2

Example config is : ve-vps.basic.conf-sample we can just use vps.basic in –config line command
NODE here is just numbering your VPS. we can name it 1, 100, 1000 ,etc

Next, We need to set a nameserver & Hostname for brandnew VPS Machine

$vzctl set 1 --nameserver 10.10.1.50 --hostname server.testing.com --save

Note: Example Nameserver ip address is 10.10.1.50

After that, we can start the VPS Machine with this command

$vzctl start 1

We also can directly enter into VPS Machine from VPS Master Server

$vzctl enter 1

This command will automatically let us enter NODE 1 which is our brandnew vps
Then we can just use passwd to change the root password

If we want to exit from container/vps machine 1, it’s simple type exit

$exit

it will automatically logout and stay in OpenVZ Master VPS Machine again

To take a look a running VPS Machine type

$vzlist

VEID NPROC STATUS IP_ADDR HOSTNAME
1 46 running 10.10.1.2 server.testing.com

Next Step is trying to connect the ip from outside network using putty.
If you are able to connect into 10.10.1.2 port 22 it’s mean you are successfully configure a container/VPS Machine

If you want to stop the VPS Machine type

$vzctl stop 1

It will automatically stop container/vps machine 1 (server.testing.com)

If you want to delete/destroy your VPS Machine, type

$vzctl destroy 1

Note : you need to stop vps machine 1 first, before destroy the vps machine

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: