カスタム検索
このエントリーをはてなブックマークに追加
tomo.gif (1144 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)line.gif (927 ツバツイツト)To previous pageTo home pageMailing to me

OpenVZの話題と実験

Modified: 2 August 2009, 16 January 2009, 10 January 2009, 13 April 2008, 19 August 2007, 19 April 2007, 28 October 2006
Created: 27 October 2006

"VPS" という言葉を聞き、怪しげなサービスを感じていましたが、特定目的ながらすごいシステムということがわかってきたので実験してみました。

OpenVZのコミュニティページ
http://openvz.org/

以下が製品版のサイトです。
http://www.swsoft.com/jp/

OpenVZの技術情報
http://opentechpress.jp/developer/article.pl?sid=07/01/17/0129254&pagenum=1

http://kano.feena.jp/?Debian%2FOpenVZ#oce96a15
http://swdn.swsoft.com/en/library/virtuozzo/


OpenVZの小技16 January 2009

VTONFの話題と実験 − GUIでメンテナンスできるツール  (12 January 2009)
VPSのバックアップ
2 August 2009
VPSのマイグレーション (10 January 2009)

OpenVZのインストール - CentOS4 (10 January 2009
VPSを作成する (
27 October 2006
コンフィグファイルの意味 (19 August 2007)


 OpenVZのインストール

yumの設定

# cd /etc/yum.repos.d/
# wget http://download.openvz.org/openvz.repo
--00:45:41--  http://download.openvz.org/openvz.repo
           => `openvz.repo'
download.openvz.org をDNSに問いあわせています... 69.64.46.11
download.openvz.org|69.64.46.11|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 952 [text/plain]

100%[===========================================================>] 952           --.--K/s             

00:45:42 (43.23 MB/s) - `openvz.repo' を保存しました [952/952]

#


OpenVZ用カーネルのインストール

# yum install ovzkernel
Setting up Install Process
Setting up repositories
openvz                    100% |=========================|  951 B    00:00     
update                    100% |=========================|  951 B    00:00     
base                      100% |=========================| 1.1 kB    00:00     
addons                    100% |=========================|  951 B    00:00     
extras                    100% |=========================| 1.1 kB    00:00     
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 6.4 kB    00:00     
openvz    : ################################################## 26/26
Added 26 new packages, deleted 0 old in 0.37 seconds
primary.xml.gz            100% |=========================|  39 kB    00:00     
update    : ################################################## 116/116
Added 116 new packages, deleted 200 old in 2.52 seconds
primary.xml.gz            100% |=========================| 569 kB    00:01     
base      : ################################################## 1500/1500
Added 471 new packages, deleted 420 old in 12.46 seconds
primary.xml.gz            100% |=========================|  28 kB    00:14     
extras    : ################################################## 114/114
Added 34 new packages, deleted 127 old in 0.60 seconds
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packagesy. Please wait.
---> Downloading header for ovzkernel to pack into transaction set.
ovzkernel-2.6.9-023stab03 100% |=========================| 519 kB    00:03     
---> Package ovzkernel.i686 0:2.6.9-023stab032.1 set to be installed
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size 
=============================================================================
Installing:
 ovzkernel               i686       2.6.9-023stab032.1  openvz             13 M

Transaction Summary
=============================================================================
Install      1 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         
Total download size: 13 M
Is this ok [y/N]: y
Downloading Packages:
(1/1): ovzkernel-2.6.9-02 100% |=========================|  13 MB    01:04     
warning: rpmts_HdrFromFdno: V3 DSA signature: NOKEY, key ID a7a1d4b6
Public key for ovzkernel-2.6.9-023stab032.1.i686.rpm is not installed
Retrieving GPG key from http://download.openvz.org/RPM-GPG-Key-OpenVZ
Importing GPG key 0xA7A1D4B6 "OpenVZ Project <security@openvz.org>"
Is this ok [y/N]: y
Key imported successfully
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: ovzkernel                    ######################### [1/1] 

Installed: ovzkernel.i686 0:2.6.9-023stab032.1
Complete!
#

 4GB以上のサーバーにインストールする場合、以下でインストールします。

# yum install ovzkernel-PAE
#


sysctlの設定

以下を追加変更します。

# On Hardware Node we generally need
# packet forwarding enabled and proxy arp disabled
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.default.proxy_arp = 0

# Enables source route verification
net.ipv4.conf.all.rp_filter = 1

# Enables the magic-sysrq key
kernel.sysrq = 1

# We do not want all our interfaces to send redirects
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0

OpenVZ用カーネルで起動

以下のように、OpenVZ用カーネル(2.6.9-023stab032.1)を指定して起動します。


OpenVZの管理ソフトのインストール

再起動後、以下のパッケージをインストールします。

# yum install vzctrl vzquota vzpkg
Setting up Install Process
Setting up repositories
openvz                    100% |=========================|  951 B    00:00     
update                    100% |=========================|  951 B    00:00     
base                      100% |=========================| 1.1 kB    00:00     
addons                    100% |=========================|  951 B    00:00     
extras                    100% |=========================| 1.1 kB    00:00     
Reading repository metadata in from local files
Parsing package install arguments
No Match for argument: vzctrl
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vzpkg to pack into transaction set.
vzpkg-2.7.0-18.noarch.rpm 100% |=========================| 4.2 kB    00:00     
---> Package vzpkg.noarch 0:2.7.0-18 set to be updated
---> Downloading header for vzquota to pack into transaction set.
vzquota-3.0.9-1.i386.rpm  100% |=========================| 3.5 kB    00:00     
---> Package vzquota.i386 0:3.0.9-1 set to be updated
--> Running transaction check
--> Processing Dependency: vzctl >= 2.7.0-23 for package: vzpkg
--> Processing Dependency: vzyum >= 2.4.0-5 for package: vzpkg
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vzyum to pack into transaction set.
vzyum-2.4.0-11.noarch.rpm 100% |=========================|  18 kB    00:00     
---> Package vzyum.noarch 0:2.4.0-11 set to be updated
---> Downloading header for vzctl to pack into transaction set.
vzctl-3.0.12-1.i386.rpm   100% |=========================|  16 kB    00:00     
---> Package vzctl.i386 0:3.0.12-1 set to be updated
--> Running transaction check
--> Processing Dependency: libvzctl.so.0.0.2 for package: vzctl
--> Processing Dependency: vzctl-lib = 3.0.12-1 for package: vzctl
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vzctl-lib to pack into transaction set.
vzctl-lib-3.0.12-1.i386.r 100% |=========================| 2.4 kB    00:00     
---> Package vzctl-lib.i386 0:3.0.12-1 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size 
=============================================================================
Installing:
 vzpkg                   noarch     2.7.0-18         openvz             39 k
 vzquota                 i386       3.0.9-1          openvz             47 k
Installing for dependencies:
 vzctl                   i386       3.0.12-1         openvz            114 k
 vzctl-lib               i386       3.0.12-1         openvz             61 k
 vzyum                   noarch     2.4.0-11         openvz            361 k

Transaction Summary
=============================================================================
Install      5 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         
Total download size: 621 k
Is this ok [y/N]: y
Downloading Packages:
(1/5): vzctl-lib-3.0.12-1 100% |=========================|  61 kB    00:03     
(2/5): vzyum-2.4.0-11.noa 100% |=========================| 361 kB    00:12     
(3/5): vzpkg-2.7.0-18.noa 100% |=========================|  39 kB    00:00     
(4/5): vzquota-3.0.9-1.i3 100% |=========================|  47 kB    00:02     
(5/5): vzctl-3.0.12-1.i38 100% |=========================| 114 kB    00:03     
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: vzquota                      ######################### [1/5] 
  Installing: vzyum                        ######################### [2/5] 
  Installing: vzctl-lib                    ######################### [3/5] 
  Installing: vzctl                        ######################### [4/5] 
  Installing: vzpkg                        ######################### [5/5] 

Installed: vzpkg.noarch 0:2.7.0-18 vzquota.i386 0:3.0.9-1
Dependency Installed: vzctl.i386 0:3.0.12-1 vzctl-lib.i386 0:3.0.12-1 vzyum.noarch 0:2.4.0-11
Complete!
# 

さらに以下もインストールしましょう。

# yum install vzyum 'vzrpm*'


OpenVZの起動

以下のコマンドで、OpenVZを起動します。

# service vz start
Starting OpenVZ:                                           [  OK  ]
Bringing up interface venet0:                              [  OK  ]
Configuring interface venet0: net.ipv4.conf.venet0.send_redirects = 0
                                                           [  OK  ]
# 


OSテンプレートのインストール

インストール可能なOSテンプレートを確認します。

# yum list vz*
Setting up repositories
openvz                    100% |=========================|  951 B    00:00     
update                    100% |=========================|  951 B    00:00     
base                      100% |=========================| 1.1 kB    00:00     
addons                    100% |=========================|  951 B    00:00     
extras                    100% |=========================| 1.1 kB    00:00     
Reading repository metadata in from local files
Installed Packages
vzctl.i386                               3.0.12-1               installed       
vzctl-lib.i386                           3.0.12-1               installed       
vzpkg.noarch                             2.7.0-18               installed       
vzquota.i386                             3.0.9-1                installed       
vzyum.noarch                             2.4.0-11               installed       
Available Packages
vzrpm43.i386                             4.3.3-7_nonptl.6       openvz          
vzrpm43-python.i386                      4.3.3-7_nonptl.6       openvz          
vzrpm44.i386                             4.4.1-22.5             openvz          
vzrpm44-python.i386                      4.4.1-22.5             openvz          
vztmpl-centos-4.i386                     2.0-2                  openvz          
vztmpl-fedora-core-3.i386                2.0-2                  openvz          
vztmpl-fedora-core-4.i386                2.0-2                  openvz          
vztmpl-fedora-core-5.i386                2.0-2                  openvz          
# 


CentOS4のテンプレートのインストール

以下のコマンドで、CentOS4のテンプレートをインストールします。

# yum install vztmpl-centos-4.i386
Setting up Install Process
Setting up repositories
openvz                    100% |=========================|  951 B    00:00     
update                    100% |=========================|  951 B    00:00     
base                      100% |=========================| 1.1 kB    00:00     
addons                    100% |=========================|  951 B    00:00     
extras                    100% |=========================| 1.1 kB    00:00     
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vztmpl-centos-4 to pack into transaction set.
vztmpl-centos-4-2.0-2.i38 100% |=========================| 5.4 kB    00:00     
---> Package vztmpl-centos-4.i386 0:2.0-2 set to be updated
--> Running transaction check
--> Processing Dependency: vzrpm43 for package: vztmpl-centos-4
--> Processing Dependency: vzrpm43-python for package: vztmpl-centos-4
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for vzrpm43-python to pack into transaction set.
vzrpm43-python-4.3.3-7_no 100% |=========================| 4.4 kB    00:00     
---> Package vzrpm43-python.i386 0:4.3.3-7_nonptl.6 set to be updated
---> Downloading header for vzrpm43 to pack into transaction set.
vzrpm43-4.3.3-7_nonptl.6. 100% |=========================|  13 kB    00:00     
---> Package vzrpm43.i386 0:4.3.3-7_nonptl.6 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
 Package                 Arch       Version          Repository        Size 
=============================================================================
Installing:
 vztmpl-centos-4         i386       2.0-2            openvz            127 k
Installing for dependencies:
 vzrpm43                 i386       4.3.3-7_nonptl.6  openvz            7.0 M
 vzrpm43-python          i386       4.3.3-7_nonptl.6  openvz             15 M

Transaction Summary
=============================================================================
Install      3 Package(s)         
Update       0 Package(s)         
Remove       0 Package(s)         
Total download size: 22 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): vztmpl-centos-4-2. 100% |=========================| 127 kB    00:02     
(2/3): vzrpm43-python-4.3 100% |=========================|  15 MB    08:41     
(3/3): vzrpm43-4.3.3-7_no 100% |=========================| 7.0 MB    04:00     
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing: vzrpm43                      ######################### [1/3] 
  Installing: vzrpm43-python               ######################### [2/3] 
  Installing: vztmpl-centos-4              ######################### [3/3] 

Installed: vztmpl-centos-4.i386 0:2.0-2
Dependency Installed: vzrpm43.i386 0:4.3.3-7_nonptl.6 vzrpm43-python.i386 0:4.3.3-7_nonptl.6
Complete!
# 


CentOS4のテンプレートのキャッシュの作成

以下のコマンドで、CentOS4のテンプレートのキャッシュを作成します。

# vzpkgcache


 VPSを作成する 

VPSを作成する

以下のコマンドで、VPSを作成します。

# vzctl create 1001 --ostemplate centos-4-i386-default --config vps.basic
Creating VE private area: /vz/private/1001
Performing postcreate actions
VE private area was created
#

以下のコマンドで、VPSを設定します。

# vzctl set 1001 --onboot yes --save
Saved parameters for VE 1001
# vzctl set 1001 --hostname openvz.tomo.ac --save
Saved parameters for VE 1001
# vzctl set 1001 --ipadd 192.168.0.22 --save
Saved parameters for VE 1001
# vzctl set 1001 --nameserver 192.168.0.11 --save
Saved parameters for VE 1001
# vzctl set 1001 --vmguarpages 256M --save
Saved parameters for VE 1001
# vzctl set 1001 --privvmpages 1G --save
Saved parameters for VE 1001
# vzctl set 1001 --userpasswd root:jhgyggjkk
Starting VE ...
VE is mounted
VE start in progress...
Changing password for user root.
passwd: all authentication tokens updated successfully.
Stopping VE ...
VE was stopped
VE is unmounted
# 

以下のコマンドで、VPSを起動します。

# vzctl start 1001
Starting VE ...
VE is mounted
Adding IP address(es): 192.168.0.22
Setting CPU units: 1000
Set hostname: openvz.tomo.ac
File resolv.conf was modified
VE start in progress...
#

以下のコマンドで、VPSの状態を確認します。

# vzlist -a
      VEID      NPROC STATUS  IP_ADDR         HOSTNAME                        
      1001         16 running 192.168.0.22   openvz.tomo.ac                  
# 

To previous pageTo home pageMailing to meJump to Top of pageline.gif (927 ツバツイツト)line.gif (927 ツバツイツト)tomo.gif (1144 ツバツイツト)
カスタム検索



このエントリーをはてなブックマークに追加