个人工具

UbuntuHelp:OpenVZ

来自Ubuntu中文

Oneleaf讨论 | 贡献2007年11月21日 (三) 18:25的版本 (新页面: {{From|https://help.ubuntu.com/community/OpenVZ}} {{Languages|UbuntuHelp:OpenVZ}} == Introduction == This page describes the installation of OpenVZ on "Ubuntu Server" as a host. To pr...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索


Introduction

This page describes the installation of OpenVZ on "Ubuntu Server" as a host. To properly implement the practical steps found in this guide, the reader should be a user of Ubuntu who is comfortable with the use of command-line applications, using the Bourne Again SHell (bash) environment, and editing system configuration files with their preferred text editor application.

About OpenVZ

OpenVZ is a server virtualization solution for Linux. It enables one to create multiple virtual Linux servers which are isolated from the host and from each other, based on a technique called "Operating System Virtualization". Similar techniques are used in Solaris Zones, Linux-VServer and FreeBSD jails. This technique does not use hardware virtualization like KVM, XEN or VMware. The so called "Virtual Servers" or VPSs behave like stand alone servers. They consume less resources than their hardware virtualized counterparts, but must use the same kernel as the host. Therefor you can only have Linux VPSs on a Linux host.

The original documentation can be found here: [1]

Installing OpenVZ

This installation was tested on Ubuntu Server 7.04 (Feisty)

  • Because OpenVZ is not part of the standard repositories of Ubuntu, we first have to add the Debian repository for OpenVZ. Therefore add the following line to your "/etc/apt/sources.list"

"deb http://debian.systs.org/ stable openvz" (without quotes)

  • Now we have to get the correct signing key for this repository added to our system:
sudo wget http://debian.systs.org/dso_archiv_signing_key.asc
sudo apt-key add dso_archiv_signing_key.asc
sudo rm dso_archiv_signing_key.asc
  • When this is done we can update APT and install the ovz kernel.
sudo apt-get update
sudo apt-get install ovzkernel-2.6.18

When the new kernel is installed, change the /boot/grub/menu.lst file so that it boots the ovz kernel automatically

  • Now reboot the system in the new ovz-kernel
  • We still have to install the OpenVZ control utilities: vzctl and vzquota
sudo apt-get install vzctl vzquota

Networking

  • For the networking to work properly, ipv4 forwarding has to be turned on.

This enables your VPSs to communicate with the outside world. You can check this with the following command: cat /proc/sys/net/ipv4/ip_forward it should read "1".

If it reads "0", it can be turned on by editing the "/etc/sysctl.conf" file. The malfunctioning network-settings are probably because of this bug, see [2]

  • To edit this file type:

"sudo nano -w /etc/sysctl.conf" and add the following line: "net.ipv4.conf.all.forwarding=1" and save the document. We can reload this config file to the system with: "sudo sysctl -p"

Download Template(s)

Before we can create a new Virtual Private Server, we first have to download a template of the distro we want to use. OpenVZ uses "templates" or "cached templates". The difference is that "templates" are a sort of cookbook for "cached templates" A package manager is then used to download and create the cached template of the chosen distribution. Because most cached versions of popular distro's are already created and not that big, it is easiest to download the cached version and place it in the "/var/lib/vz/template/cache" directory (or the path you have chosen in the "/etc/vz/vz.conf" file).

The cached templates can be found here [3]

Create a new VPS

When we create a VPS, we must give it a number. This number must be unique and it is used to control the VPS during it's existence. A good guideline is to use the last three digits of the ip address you are going to use for this VPS. i.e.: 10.0.0.101 would be VPS 101!

To create a VPS use this command:

sudo vzctl create 101 --ostemplate <the name of your template>

more to come...