CentOS 5
Sponsored Link

VPSの作成2010/04/24

[1] VPS を作成します。VPS とは Virtual Private Server の略で一般的に言うゲストOSのことです。 OpenVZ では VPS と呼びます。ここでは VPS に CentOS 4 をインストールしてみます。
[root@ns ~]#
yum -y vztmpl-centos-4-2.0-2
 
# CentOS 4 用テンプレート

Loading "installonlyn" plugin
Loading "fastestmirror" plugin
Setting up Install Process
Setting up repositories
Loading mirror speeds from cached hostfile
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 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
---> 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
--> Running transaction check

Dependencies Resolved
====================================
Package ArchVersionRepositorySize
====================================
Installing:
vztmpl-centos-4 i3862.0-2openvz-utils127 k
Installing for dependencies:
vzrpm43 i3864.3.3-7_nonptl.6openvz-utils7.0 M
vzrpm43-python i3864.3.3-7_nonptl.6openvz-utils15 M
Transaction Summary
=================================
Install 3 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 22 M
Downloading Packages:
(1/3): vzrpm43-4.3.3-7_no 100% |========|
7.0 MB 00:00

(2/3): vztmpl-centos-4-2. 100% |========|   127 kB 00:00
(3/3): vzrpm43-python-4.3 100% |========|
15 MB 00:00

Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing:   vzrpm43-python ############### [1/3]
  Installing:   vzrpm43 ############### [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!
[root@ns ~]#
[root@ns ~]#
vzpkgcache
# キャッシュ生成


##### ベースシステム用の大量のパッケージがインストールされる #####


[root@ns ~]#
vzpkgls
# インストール済みテンプレート確認

centos-4-i386-default
centos-4-i386-minimal

# 以下のコマンドでIDが101のVPSを作成 ( 0 - 100 は予約済みで使えない )

[root@ns ~]#
vzctl create 101 --ostemplate centos-4-i386-default --config vps.basic

Creating VE private area (centos-4-i386-default)
Performing postcreate actions
VE private area was created
[root@ns ~]#
# VPS自動起動設定

[root@ns ~]#
vzctl set 101 --onboot yes --save

Saved parameters for VE 101
# VPSのIPアドレス設定

[root@ns ~]#
vzctl set 101 --ipadd 192.168.0.18 --save

Saved parameters for VE 101
# VPSのホストネーム設定

[root@ns ~]#
vzctl set 101 --hostname www.server-linux.info --save

Saved parameters for VE 101
# VPSが参照するDNSサーバ設定

[root@ns ~]#
vzctl set 101 --nameserver 192.168.0.17 --save

Saved parameters for VE 101
# VPSのrootパスワード設定

[root@ns ~]#
vzctl set 101 --userpasswd root:password

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
[root@ns ~]#
vzctl start 101
# IDが101のVPS起動

Starting VE ...
VE is mounted
Adding IP address(es): 192.168.0.18
Setting CPU units: 1000
Set hostname: www.server-linux.info
File resolv.conf was modified
VE start in progress...
[root@ns ~]#
vzctl exec 101 service sshd start
 
# VPSの sshd 起動

Starting sshd: [  OK  ]
[root@ns ~]#
vzlist
# VPSの状態表示

  VEID NPROC STATUS IP_ADDR HOSTNAME
  101 16 running 192.168.0.18 www.server-linux.info
  以上で、VPS の作成と起動が終了し、SSHも立ち上げたので Tera Term や Putty 等でフツーに接続して操作できます。 VPSの追加もとても簡単に行うことができます。
[2] ホストOSは CentOS なので当然 yum コマンドが使用できるわけですが、 この OpenVZ は ホストOS側から VPS 内へ yum でアプリケーションのインストールが行えます。 これは便利です。コマンドは 'yum' ではなく 'vzyum' を使い、VPS の ID を指定して実行します。 なお、VPS内では、もちろんのこと、通常通り、普通の 'yum' コマンドでインストールやアンインストールが行えます。

例として、以下のように指定して実行します。ホストOS側から ID が 101 の VPS へ 'yum' コマンドをインストールしています。 ちなみに、[1] の手順で作った CentOS 4 の VPS にはデフォルトで yum コマンドがインストールされていませんので、 これはどなたも必ず実行することになるでしょう。
# ホストOSから IDが101のVPSへyumをインストール

[root@ns ~]#
vzyum 101 install yum


# ついでにファステストミラーのプラグインもインストール
# CentOS 5 とはパッケージ名が異なるので注意

[root@ns ~]#
vzyum 101 install yum-plugin-fastestmirror
関連コンテンツ