OpenVZ インストール · 2 min read · Jan 17, 2026

CentOS 5.2にOpenVZをインストールして使用する

CentOS 5.2にOpenVZをインストールして使用する

バージョン 1.0
著者: Falko Timme

このHowToでは、CentOS 5.2サーバーをOpenVZ用に準備する方法を説明します。OpenVZを使用すると、同じハードウェア上に複数の仮想プライベートサーバー(VPS)を作成できます。これはXenやLinux Vserverプロジェクトに似ています。OpenVZは、仮想サーバーを提供する多くのプロバイダーによって使用される商用仮想化ソリューションであるVirtuozzoのオープンソース版です。OpenVZカーネルパッチはGPLライセンスの下でライセンスされており、ユーザーレベルのツールはQPLライセンスの下にあります。

このhowtoは実用的なガイドとして意図されています。理論的な背景については、他の多くの文書で扱われています。

この文書は、いかなる種類の保証もなく提供されます!これは、このようなシステムを設定する唯一の方法ではないことを言いたいです。この目標を達成する方法はたくさんありますが、これは私が取る方法です。これがあなたにとって機能するという保証はありません!

1 OpenVZのインストール

OpenVZをインストールするには、yumにOpenVZリポジトリを追加する必要があります:

cd /etc/yum.repos.d  
wget http://download.openvz.org/openvz.repo  
rpm --import http://download.openvz.org/RPM-GPG-Key-OpenVZ

リポジトリには、いくつかの異なるOpenVZカーネルが含まれています(詳細については、こちらを参照してください: http://wiki.openvz.org/Kernel_flavors)。コマンド

yum search ovzkernel

は、利用可能なカーネルを表示します:

[root@server1 yum.repos.d]# yum search ovzkernel  
Loading "fastestmirror" plugin  
Loading mirror speeds from cached hostfile  
 * base: ftp.halifax.rwth-aachen.de  
 * openvz-kernel-rhel5: openvz.proserve.nl  
 * updates: ftp.halifax.rwth-aachen.de  
 * addons: ftp.halifax.rwth-aachen.de  
 * openvz-utils: openvz.proserve.nl  
 * extras: ftp.halifax.rwth-aachen.de  
openvz-kernel-rhel5       100% |=========================|  951 B    00:00  
primary.xml.gz            100% |=========================|  22 kB    00:00  
openvz-ker: ################################################## 14/14  
openvz-utils              100% |=========================|  951 B    00:00  
primary.xml.gz            100% |=========================| 6.7 kB    00:00  
openvz-uti: ################################################## 26/26  
ovzkernel-ent.i686 : The Linux kernel compiled for huge mem capable machines.  
ovzkernel-PAE.i686 : The Linux kernel compiled for PAE capable machines.  
ovzkernel-ent-devel.i686 : Development package for building kernel modules to match the ent kernel.  
ovzkernel-PAE-devel.i686 : Development package for building kernel modules to match the PAE kernel.  
ovzkernel.i686 : Virtuozzo Linux kernel (the core of the Linux operating system)  
ovzkernel-xen.i686 : The Linux kernel compiled for Xen VM operations  
ovzkernel-xen-devel.i686 : Development package for building kernel modules to match the kernel.  
ovzkernel-devel.i686 : Development package for building kernel modules to match the kernel.  
[root@server1 yum.repos.d]#

その中から1つを選択し、次のようにインストールします:

yum install ovzkernel

これにより、GRUBブートローダーも自動的に更新されるはずです。とにかく、/boot/grub/menu.lstを開きます。最初のカーネルスタンザには新しいOpenVZカーネルが含まれているはずです。そのカーネルのタイトルは「CentOS」とだけ表示されます。それを変更し、「OpenVZ」を追加するのは良いアイデアだと思います。そうすれば、それがOpenVZカーネルであることがわかります。また、defaultの値が0になっていることを確認してください。これにより、最初のカーネル(OpenVZカーネル)がデフォルトのCentOSカーネルの代わりに自動的にブートされます。

vi /boot/grub/menu.lst

| # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00 # initrd /initrd-version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,0)/grub/splash.xpm.gz hiddenmenu title CentOS OpenVZ (2.6.18-53.1.19.el5.028stab053.14) root (hd0,0) kernel /vmlinuz-2.6.18-53.1.19.el5.028stab053.14 ro root=/dev/VolGroup00/LogVol00 initrd /initrd-2.6.18-53.1.19.el5.028stab053.14.img title CentOS (2.6.18-92.1.1.el5) root (hd0,0) kernel /vmlinuz-2.6.18-92.1.1.el5 ro root=/dev/VolGroup00/LogVol00 initrd /initrd-2.6.18-92.1.1.el5.img title CentOS (2.6.18-92.el5) root (hd0,0) kernel /vmlinuz-2.6.18-92.el5 ro root=/dev/VolGroup00/LogVol00 initrd /initrd-2.6.18-92.el5.img |

次に、いくつかのOpenVZユーザーツールをインストールします:

yum install vzctl vzquota

/etc/sysctl.confを開き、次の設定が含まれていることを確認します:

vi /etc/sysctl.conf

| [...] net.ipv4.ip_forward = 1 net.ipv4.conf.default.proxy_arp = 0 net.ipv4.conf.all.rp_filter = 1 kernel.sysrq = 1 net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0 net.ipv4.icmp_echo_ignore_broadcasts=1 net.ipv4.conf.default.forwarding=1 [...] |

/etc/sysctl.confを変更する必要がある場合は、次のように実行します。

sysctl -p

次のステップは、仮想マシンのIPアドレスがホストシステムのIPアドレスとは異なるサブネットにある場合に重要です。これを行わないと、仮想マシン内でネットワークが機能しません!

/etc/vz/vz.confを開き、NEIGHBOUR_DEVSをallに設定します:

vi /etc/vz/vz.conf

| [...] NEIGHBOUR_DEVS=all [...] |

OpenVZを使用する場合、SELinuxは無効にする必要があります。/etc/sysconfig/selinuxを開き、SELINUXの値をdisabledに設定します:

vi /etc/sysconfig/selinux

| # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted |

最後に、システムを再起動します:

reboot

システムが問題なく再起動すれば、すべてが正常です!

次のコマンドを実行します:

uname -r

新しいOpenVZカーネルが表示されるはずです:

[root@server1 ~]# uname -r  
2.6.18-53.1.19.el5.028stab053.14  
[root@server1 ~]#
Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。