ADMIN
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
OpenVZ<br />
Virtualization<br />
a number of community templates<br />
(Figure 4).<br />
Configuring the Host<br />
Environment<br />
The /etc/vz/vz.conf file lets you<br />
configure the host environment. This<br />
is where you specify the path to the<br />
container and template data on the<br />
host filesystem. If you prefer not to<br />
use the defaults of<br />
subnet and tell them the DNS server<br />
address, which lets OpenVZ create<br />
venet devices. All of the following<br />
commands must be given in the host<br />
context. To do this, you first need to<br />
stop the VE and then set all the basic<br />
parameters. For example, you can set<br />
the hostname for the VE as follows:<br />
sudo vzctl set VEID U<br />
‐‐hostname Hostname ‐‐save<br />
The ‐‐ipadd option lets you assign a<br />
local IP address. If you need to install<br />
a large number of VEs, use VEID as<br />
the host part of the numeric address.<br />
sudo vzctl set VEID ‐‐ipadd U<br />
IP-Address ‐‐save<br />
The DNS server can be configured using<br />
the ‐‐nameserver option:<br />
sudo vzctl set VEID U<br />
‐‐nameserver Nameserver-address ‐‐save E<br />
TEMPLATE=/var/lib/vz/template<br />
VE_ROOT=/var/lib/vz/root/$VEID<br />
VE_PRIVATE=/var/lib/vz/private/$VEID<br />
you can set your own paths. VE_ROOT<br />
is the mountpoint for the root directory<br />
of the container. The private<br />
data for the container are mounted in<br />
VE_PRIVATE. VEID is a unique ID that<br />
identifies an instance of the virtual<br />
environment. All OpenVZ tools use<br />
this container ID to address the required<br />
container.<br />
Figure 6: The virtual environment uses venet devices to communicate with the outside world.<br />
Creating Containers<br />
The vzctl, which is only available<br />
in the host context, creates containers<br />
and handles most management<br />
tasks, too. In the following example,<br />
I used it to create a new VE based on<br />
a template for openSUSE 11.1 that I<br />
downloaded:<br />
Figure 7: The vzlist command outputs a list of active VEs.<br />
sudo vzctl create VEID U<br />
‐‐ostemplate suse‐11.1‐x86_64<br />
The template name is specified without<br />
the path and file extension. The<br />
sudo vzctl start VEID starts the<br />
VE, and sudo vzctl stop VEID stops<br />
it again (Figure 5). The commands<br />
sudo vzctl enter VEID and exit let<br />
you enter and exit the VE.<br />
Entering the VE gives you a working<br />
root shell without prompting you for<br />
a password. Unfortunately, you can’t<br />
deny root access in the host context.<br />
Network Configuration<br />
The next step is to configure network<br />
access for the container. OpenVZ<br />
supports various network modes for<br />
this. The easiest option is to assign<br />
the VEs an IP on the local network/<br />
Figure 8: User Bean Counters, a set of configuration parameters, allow the administrator to limit resources<br />
for each virtual environment.<br />
www.admin-magazine.com<br />
Admin 01<br />
55