推薦宿主系統:Fedora Core 3/4/5 或 RHEL/CentOS 4。
依核心版本至 官網下載頁 取得對應套件:
rpm -ihv vzkernel-name*.rpm
編輯 grub.conf 新增 OpenVZ 核心啟動項:
title OpenVZ (2.6.8-022stab029.1)
root (hd0,0)
kernel /vmlinuz-2.6.8-022stab029.1 ro root=/dev/sda5
initrd /initrd-2.6.8-022stab029.1.img
# 封包轉發與代理 ARP
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
# 來源路由驗證
net.ipv4.conf.all.rp_filter = 1
# 啟用 Magic SysRq
kernel.sysrq = 1
# 介面重導向控制
net.ipv4.conf.default.send_redirects = 1
# SELinux
vi /etc/sysconfig/selinux
SELINUX=disabled
# 關閉 iptables 服務
service iptables stop
chkconfig iptables off
至 工具下載頁 取得套件:
rpm -Uhv vzctl*.rpm vzquota*.rpm vzpkg*.rpm
/etc/init.d/vz start
rpm -ihv vztmpl-fedora-core-3-1.0-2.noarch.rpm
vzpkgcache
# 輸出:Cache file fedora-core-3.tar.gz [130M] created.
vzctl create 101
# Creating VPS private area: /vz/private/101
# VPS is mounted → Postcreate action done → VPS is unmounted
# VPS private area was created
vzctl set 101 --hostname test101.my.org --save
vzctl set 101 --ipadd 10.0.186.1 --save
vzctl set 101 --nameserver 192.168.1.165 --save
vzctl set 101 --userpasswd root:test
vzctl exec 101 service sshd start
vzctl start 101
# Starting VPS ... VPS is mounted
# Adding IP address(es): 10.0.186.101
# Hostname for VPS 101 set: test.my.org
# VPS start in progress...
vzctl set 101 --iptables iptable_filter \
--iptables ipt_length --iptables ipt_limit \
--iptables iptable_mangle --iptables ipt_REJECT --save
OpenVZ 採容器級虛擬化,單核心共享,效能損耗極低,適合高密度 VPS 部署。模板快取機制使建立新容器極快(秒級)。