Blog

VPS creation Steps

Tags: node managementvirtuozzoVPS

Published on: October 22, 2014 by Vipin R.N

VPS creation Steps

Scenario:

Scenario
Our requirement is to create VPS from a Node (or Physical server). The Virtualization technology adopted in the Node is OpenVZ (Open Virtuozzo).

OpenVZ
OpenVZ is an Operating System level, container-based Virtualization for Linux. OpenVZ creates multiple secure, isolated Linux containers (otherwise known as VEs or VPSs) on a single physical server enabling better server utilization and ensuring that applications do not conflict. Each container performs and executes exactly like a stand-alone server; a container can be rebooted independently and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files.

Creating a Container
Before we start creating a Container or create VPS, the following prerequisites are to be met :

  • Check that the Hardware Node is visible on your network. You should be able to connect to/from other hosts. Otherwise, your Containers will not be accessible from other servers.
  • Check that you have at least one IP address per Container and the addresses belong to the same network as the Hardware Node or routing to the Containers has been set up via the Hardware Node.

To create a new Container, we have to:

  • Choose the new Container ID where it has to be ensured that no containers already exists by that CTID (Container ID). More detailed Guidelines are available at https://openvz.org/User_Guide/Operations_on_Containers#Choosing_Container_ID
  • Choose the OS template to use for the Container. Various OS templates are available to download here. The OS templates would be in tar.gz format and it should not be unpacked. The location where the OS templates reside is /vz/template/cache.

 

[root@node /vz/template/cache/]# ls
centos-5.0-x86.tar.gz centos-6-x86_64.tar.gz centos-6-x86.tar.gz debian-6.0-x86_64.tar.gz

Now, let’s create the container. The command used to create a container is :-


# vzctl create CTID --ostemplate --config basic 

Example :

vzctl create 100 –ostemplate centos-6-x86 –config basic

OR

vzctl create 262 –ostemplate debian-6.0-x86_64 –config basic

Note : When specifying the OS template, make sure to remove the file extension (tar.gz). If you don’t specify the OS Template name, it will try to fetch the parameter in /etc/vz/vz.conf. See the section ## Defaults for containers in that file for more information. It would look like :

## Defaults for containers
VE_ROOT=/vz/root/$VEID
VE_PRIVATE=/vz/private/$VEID
CONFIGFILE=”basic”
DEF_OSTEMPLATE=”centos-5″

With vzctl create command, the container private area is being created. The private area is the directory containing the actual files of the given Container; it is usually residing in /vz/private/CTID/. The private area is mounted to the /vz/root/CTID directory on the Hardware Node and provides Container users with a complete Linux file system tree.

[root@node ~]# ls /vz/root/100/
.autofsck boot/ etc/ lib/ mnt/ proc/ sbin/ srv/ tmp/ var/ bin/ dev/ home/ media/ opt/ root/ selinux/ sys/ usr/

[root@node conf]# ls /vz/private/100
bin boot dev etc home lib media mnt opt proc root sbin selinux srv sys tmp usr var

The switch –config basic is specified to choose the basic template configuration which would be usually located at /etc/vz/conf/ve-basic.conf-sample. This file has resource control parameters suitable for most Containers. Obviously these parameters can be changed later.

Essential Configuration

Creating just the container will not help it function properly. Some inevitable configuration has to be made before we start the container. The Configuration file of a container is located at /etc/vz/conf/CTID.conf where CTID is the container ID. You can either edit the configuration file directly or use vzctl commands to adjust the parameters in any container’s configuration file. Using vzctl commands is more safe because you cannot make any incorrect or invalid parameter in the configuration file. Few essential parameters for a Container are given below.

Add IP Address

Adding an IP address is very much essential. To add an IP address to the Container, use the command


# vzctl set CTID --ipadd <IP Address> --save

Example :

vzctl set 100 –ipadd 8.18.17.48 –save

Note : It is possible to add multiple IP addresses at once or add an entire IP range by using CIDR notation. Make sure that the IP address is free or not used elsewhere.

Assign DNS Server

To set a DNS server to a Container, use the command


# vzctl set CTID --nameserver <NS ADDRESS> --save

Example :

vzctl set 100 –nameserver 8.8.8.8 –save

Disk Space

To set certain amount of Disk space to a Container, use the command


# vzctl set CTID --diskspace <SOFTLIMIT:HARDLIMIT> --save

Example :

vzctl set 100 –diskspace 100G:110G –save

Note : Sufficient Disk space would be allotted to the container by the Basic configuration file. If it is not enough, you can override it.

Hostname

To set the Hostname to a Container, use the command


# vzctl set CTID --hostname <HOSTNAME> --save

Example :

vzctl set 100 –hostname training.supportsages.com –save

Change System Time

Sometimes it may be essential to enable the capability of a container to change its System time. For that use the command


# vzctl set CTID --capability sys_time:on --save

Example :

vzctl set 100 –capability sys_time:on –save

Startup Parameters

It is possible to define the onboot Container startup parameter. Setting this parameter to yes makes the Container automatically boot at the Hardware Node startup.


# vzctl set CTID --onboot yes --save

Example :

vzctl set 100 –onboot yes –save

Starting the Container

Once all the essential parameters are defined, the container can be started. Many options can be set while the container is running. Then it may be necessary to restart the container for the changes to be in effect.


# vzctl start CTID

Example :

vzctl start 100

Checking the Container Status

To see whether our configuration has succeeded, hit vzlist -a. It will display all containers in a node irrespective of the status (Running | Stopped etc)

[root@node ~]# vzlist -a
CTID NPROC STATUS IP_ADDR HOSTNAME
100 26 running 8.18.17.48 training.supportsages.com
101 70 running 8.18.17.1 server.supportsages.com

Stopping the Container

To stop the container, execute


# vzctl stop CTID

Example :

vzctl stop 100

Removing the Container

To remove the container, execute


# vzctl destroy CTID

Example :

vzctl destroy 100

Note : Removing a container will cause complete data loss in it. Ensure that the data is backed up or no longer required. Before removing a container, it has to be stopped as well.

Other Parameters

Various other parameters determining the resource usage can be set in the Container configuration. See this link for complete details.

References / Further Reading

 

  1. User Guide/Operations on Containers – https://openvz.org/Basic_operations_in_OpenVZ_environment
  2. UBC primary parameters – https://wiki.openvz.org/UBC_primary_parameters
 Get 24/7 expert server management

 

Category : Howtos, Linux, Troubleshooting, VPS

Vipin R.N

Vipin R.N

Vipin is a no-nonsense, disciplined guy who ensures that everything is carried out with the highest level of perfection. Apart from his great coding skills, he is quite interested in advanced server administration, issue analysis, documentation and training. In-depth knowledge in international politics, ammunition and automobiles makes this hard core Manchester United fan, one of the most referenced personalities in the entire team.

You may also read:

Comments

Add new commentSIGN IN

Let's Connect

Categories

Your Cart

Cart is empty.

Subtotal
₹0.00
APPLY
0
Send this to a friend