公開日:2009/4/1 0:00:00

CentOS 5 Xen Domain-U関連

CentOS 5 on Xen(CnetOS5) 標準インストールマニュアル

CentOS 5にCentOS 5をセットアップ

CentOS 5 にXenが入っている状態を前提とした時の導入手順です。
「CentOS 5 Sixwish 標準インストールマニュアル」にしたがってインストール。
最小構成化まで進めた状態をベースとしています。構成が異なる場合でもほぼ同じように出来ると思うので、適宜、読替えて対応してください。

作業はリモートから putty でアクセス。その後、rootになって行ないます。

チェック

まず、CPUがXenに対応しているかどうかをチェックします。

[root@sixwish ~]# grep pae /proc/cpuinfo
flags           : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
flags           : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
[root@sixwish ~]#

上記は、Core2DuoなCPUを使っている場合の出力です。
Xenの仮想化に対応するためには、PAE 拡張のある CPU が必要となります。
ここ最近のCPUはほとんど対応していますが、旧型のPentium Mobile やCentrino ベース、VIA C3等は対応していないので仮想化することが出来ません。
(対応していない場合は、インストール時に選択できません)

次に完全仮想化できるかどうかをチェックします。
この資料を作成する際のベースに、Intel(R) Core2Duo E6320を使用しているので、完全仮想化に対応していますが、対応しないCPUもざらにあるので、以下の方法で確認してください。

[root@sixwish ~]# egrep -e 'vmx|svm' /proc/cpuinfo
flags           : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
flags           : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
[root@sixwish ~]#

何も返ってこない場合は、完全仮想化に対応していない事になります。

さらにBIOSで有効になっているかどうかを確認します。

[root@sixwish ~]# cat /sys/hypervisor/properties/capabilities
xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p
[root@sixwish ~]#

これが、BIOSで無効になっている場合は、以下のように表示されます。

[root@sixwish ~]# cat /sys/hypervisor/properties/capabilities
xen-3.0-x86_32p
[root@sixwish ~]#

この辺りはハードウェアによって異なるので、各々で確認してください。

なお、今回は完全仮想化でのインストールは行ないません。

準備

まずはイメージファイルの置き場所の確認を行います。
SELinuxでは、イメージファイルを /var/lib/xen/images/ におく事を前提としているので、その場所があるかどうかを確認します。
同時に、SELinuxのラベル付けに問題が無い事を確認します。

[root@sixwish ~]# ls -Z /var/lib/xen/
drwxr-xr-x  root root system_u:object_r:xend_var_lib_t dump
drwxr-xr-x  root root system_u:object_r:xen_image_t    images
drwxr-xr-x  root root system_u:object_r:xend_var_lib_t xend-db
[root@sixwish ~]#

それ以外にもディレクトリがありますが、dumpは仮想マシンダンプ(xm dump-core コマンドで実行)を行なった場合の保存場所、xend-dbは稼動中の何かしらのデータが入るようです。

次にブラウザ等を使って、OSイメージのある場所を確認します。
候補としては以下の場所になります。

http://ftp.riken.jp/Linux/centos/5/os/i386/
独立行政法人 理化学研究所のミラーサーバ。個人的には理研鯖と呼んでる。
http://ftp.iij.ad.jp/pub/linux/centos/5/os/i386/
IIJのミラー。
http://ftp.nara.wide.ad.jp/pub/Linux/centos/5/os/i386/
NAIST 奈良先端科学技術大学院大学のミラー
http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/5/os/i386/
山形大学のミラー

rikenはそれなりに混雑するので、負荷分散を考えて近所のところにするといい感じです。
OSのリリース時期と重なった場合、rikenはかなり混雑するので他の場所にした方が無難です。

ブラウザでアクセスできる事を確認したらインストールへと進みます。

インストール

virt-installのコマンドを使用してインストールを行ないます。
コマンドのオプションにグラフィカルモードの無効化と準仮想化の指定を追加して実行します。

[root@sixwish ~]# virt-install --nographics --paravirt
 What is the name of your virtual machine? labsixwish
 How much RAM should be allocated (in megabytes)? 256
 What would you like to use as the disk (path)? /var/lib/xen/images/labsixwish.pvm.img
 How large would you like the disk (/var/lib/xen/images/labsixwish.pvm.img) to be (in gigabytes)? 10
 What is the install location? http://ftp.iij.ad.jp/pub/linux/centos/5/os/i386/


Starting install...

ここで、initrd.imgなどをダウンロードして起動をかけているっぽい。
しばらくすると、仮想OSが起動します。

ちなみに、いちいち答えるのが面倒な場合は、

[root@sixwish ~]# virt-install --nographics --paravirt \
 --name=labsixwish --ram=256 --file=/var/lib/xen/images/labsixwish.pvm.img \
 --file-size=10 --location=http://ftp.iij.ad.jp/pub/linux/centos/5/os/i386/

でもいけます。

Starting install...
Linux version 2.6.18-8.el5xen (mockbuild@builder4.centos.org) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Thu Mar 15 21:02:53 EDT 2007
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000010800000 (usable)
0MB HIGHMEM available.
264MB LOWMEM available.
(以下略)

起動に関係する部分の表示が終わったあとは、CUIベースのインストーラが上がります。
基本的に「Tab」キーと「スペース」、「Enter」キーで操作する事になります。

Welcome to CentOS

                   +---------+ Choose a Language +---------+
                   |                                       |
                   | What language would you like to use   |
                   | during the installation process?      |
                   |                                       |
                   |       Catalan                ^        |
                   |       Chinese(Simplified)    :        |
                   |       Chinese(Traditional)   #        |
                   |       Croatian               :        |
                   |       Czech                  :        |
                   |       Danish                 :        |
                   |       Dutch                  :        |
                   |       English                v        |
                   |                                       |
                   |                +----+                 |
                   |                | OK |                 |
                   |                +----+                 |
                   |                                       |
                   |                                       |
                   +---------------------------------------+

  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

Japaneseを選択しても英語になるだけなので、気にせず[OK]へTabで移動してエンター。

Welcome to CentOS


             +----------------+ Configure TCP/IP +----------------+
             |                                                    |
             | [*] Enable IPv4 support                            |
             |        ( ) Dynamic IP configuration (DHCP)         |
             |        (*) Manual configuration                    |
             |                                                    |
             | [ ] Enable IPv6 support                            |
             |        (*) Automatic neighbor discovery (RFC 2461) |
             |        ( ) Dynamic IP configuration (DHCP)         |
             |        ( ) Manual configuration                    |
             |                                                    |
             |          +----+                  +------+          |
             |          | OK |                  | Back |          |
             |          +----+                  +------+          |
             |                                                    |
             |                                                    |
             +----------------------------------------------------+



  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

ネットワークの設定。
割り当てられているIPアドレスなどを振ってください。

Welcome to CentOS


         +--------------+ Manual TCP/IP Configuration +---------------+
         |                                                            |
         | Enter the IPv4 and/or the IPv6 address and prefix          |
         | (address / prefix).  For IPv4, the dotted-quad netmask     |
         | or the CIDR-style prefix are acceptable. The gateway and   |
         | name server fields must be valid IPv4 or IPv6 addresses.   |
         |                                                            |
         | IPv4 address: 172.16.2.72_____ / 255.255.240.0___          |
         | Gateway:      172.16.0.1_______________________________    |
         | Name Server:  172.16.0.1_______________________________    |
         |                                                            |
         |            +----+                      +------+            |
         |            | OK |                      | Back |            |
         |            +----+                      +------+            |
         |                                                            |
         |                                                            |
         +------------------------------------------------------------+



  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

マニュアル設定にすると上記のように表示されるので、適切な情報を入力します。
入力が終わったら以下のような画面が表示されるのでしばらく待ちます。

Welcome to CentOS








    +----------------------------+ Retrieving +----------------------------+
    |                                                                      |
    | Retrieving images/minstg2.img...                                     |
    |                                                                      |
    +----------------------------------------------------------------------+









  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

Welcomの画面が表示されるので、OKを選んで次へ。

Welcome to CentOS





               +------------------+ CentOS +-------------------+
               |                                               |
               | Welcome to CentOS!                            |
               |                                               |
               |                                               |
               |                    +----+                     |
               |                    | OK |                     |
               |                    +----+                     |
               |                                               |
               |                                               |
               +-----------------------------------------------+






  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

パーティションテーブルが無いから作っていいかと訪ねられたら、[Yes]を選択。

Welcome to CentOS

                +-----------------+ Warning +-----------------+
                |                                             |
                | The partition table on device xvda was      |
                | unreadable. To create new partitions it     |
                | must be initialized, causing the loss of    |
                | ALL DATA on this drive.                     |
                |                                             |
                | This operation will override any previous   |
                | installation choices about which drives     |
                | to ignore.                                  |
                |                                             |
                | Would you like to initialize this drive,    |
                | erasing ALL DATA?                           |
                |                                             |
                |        +-----+               +----+         |
                |        | Yes |               | No |         |
                |        +-----+               +----+         |
                |                                             |
                |                                             |
                +---------------------------------------------+

  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

インストールする場所を選べと言ってくるので、xvdaにチェックを入れて[OK]。

Welcome to CentOS
   +-------------------------+ Partitioning Type +-------------------------+
   |                                                                       |
   |    Installation requires partitioning of your hard drive.  The        |
   |    default layout is reasonable for most users.  You can either       |
   |    choose to use this or create your own.                             |
   |                                                                       |
   | Remove all partitions on selected drives and create default layout.   |
   | Remove linux partitions on selected drives and create default layout. |
   | Use free space on selected drives and create default layout.          |
   | Create custom layout.                                                 |
   |                                                                       |
   |       Which drive(s) do you want to use for this installation?        |
   |                              [*] xvda ^                               |
   |                                       #                               |
   |                                                                       |
   |                          +----+   +------+                            |
   |                          | OK |   | Back |                            |
   |                          +----+   +------+                            |
   |                                                                       |
   |                                                                       |
   +-----------------------------------------------------------------------+

<Space>,<+>,<-> selection   |   <F2> Add drive   |   <F12> next screen

パーティションの中をきれいに削除してよいかと尋ねられたら、[Yes]を選択。

Welcome to CentOS



                    +-------------+ Warning +-------------+
                    |                                     |
                    | You have chosen to remove all       |
                    | Linux partitions (and ALL DATA on   |
                    | them) on the following drives:      |
                    |                                     |
                    | /dev/xvda                           |
                    |                                     |
                    | Are you sure you want to do this?   |
                    |                                     |
                    |      +----+           +-----+       |
                    |      | No |           | Yes |       |
                    |      +----+           +-----+       |
                    |                                     |
                    |                                     |
                    +-------------------------------------+



  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

パーティションのレイアウトを確認しますか?と問われます。
基本的には確認する必要性は無いので、[No]を選択します。

Welcome to CentOS






                  +-------+ Review Partition Layout +-------+
                  |                                         |
                  | Review and modify partitioning layout?  |
                  |                                         |
                  |       +-----+             +----+        |
                  |       | Yes |             | No |        |
                  |       +-----+             +----+        |
                  |                                         |
                  |                                         |
                  +-----------------------------------------+






  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

なお、[Yes](確認する)を選択した場合、以下の様な画面が表示されます。
正直、上級者向けなので慣れているか、それなりの思い入れがある場合のみ選ぶと良いでしょう。

また、今回は省略していますが、いくつかの画面を経過して次へ進むことになります。
ついでに言うと、[Yes]を選択していた場合、どれだけ戻っても[No]を選択する事はできなくなるので注意してください。

Welcome to CentOS

   +----------------------------+ Partitioning +----------------------------+
   |                                                                        |
   |      Device        Start    End     Size       Type     Mount Point    |
   | VG VolGroup00                       10112M  VolGroup                 ^ |
   | LV LogVol00                          9568M  ext3        /            # |
   | LV LogVol01                           544M  swap                     : |
   | /dev/xvda                                                            : |
   |   xvda1                 1      13     101M  ext3        /boot        : |
   |   xvda2                14    1305   10134M  physical v               : |
   |                                                                      : |
   |                                                                      : |
   |                                                                      : |
   |                                                                      v |
   |                                                                        |
   |    +-----+   +------+   +--------+   +------+   +----+   +------+      |
   |    | New |   | Edit |   | Delete |   | RAID |   | OK |   | Back |      |
   |    +-----+   +------+   +--------+   +------+   +----+   +------+      |
   |                                                                        |
   |                                                                        |
   +------------------------------------------------------------------------+

    F1-Help     F2-New      F3-Edit   F4-Delete    F5-Reset    F12-OK

[No]を選ぶとここまでジャンプ

ネットワークの設定になります。
とりあえず、[Enable IPv6 support]を外す事。IPアドレスは指定された物を入力する事。

Welcome to CentOS

     +-----------------+ Network Configuration for eth0 +-----------------+
     |                                                                    |
     | Description: Xen Virtual Ethernet                                  |
     | Hardware Address: 00:16:3E:1A:27:80                                |
     |                                                                    |
     | [ ] Use dynamic IP configuration (DHCP)                            |
     | [*] Enable IPv4 support                                            |
     | [ ] Enable IPv6 support                                            |
     | [*] Activate on boot                                               |
     |                                                                    |
     |                        Address                    Prefix (Netmask) |
     | IPv4: 172.16.2.72______________________________ / 255.255.240.0___ |
     | IPv6: _________________________________________ / ________________ |
     |                                                                    |
     |             +----+                          +------+               |
     |             | OK |                          | Back |               |
     |             +----+                          +------+               |
     |                                                                    |
     |                                                                    |
     +--------------------------------------------------------------------+

  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

ゲートウェイとDNSの設定です。

Welcome to CentOS





          +------------+ Miscellaneous Network Settings +------------+
          |                                                          |
          | Gateway:       172.16.0.1_______________________________ |
          | Primary DNS:   172.16.0.1_______________________________ |
          | Secondary DNS: _________________________________________ |
          |                                                          |
          |           +----+                     +------+            |
          |           | OK |                     | Back |            |
          |           +----+                     +------+            |
          |                                                          |
          |                                                          |
          +----------------------------------------------------------+





  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

ホスト名をどうするかという設定。

Welcome to CentOS



     +--------------------+ Hostname Configuration +---------------------+
     |                                                                   |
     | If your system is part of a larger network where hostnames are    |
     | assigned by DHCP, select automatically via DHCP. Otherwise,       |
     | select manually and enter in a hostname for your system. If you   |
     | do not, your system will be known as 'localhost.'                 |
     |                                                                   |
     |        ( ) automatically via DHCP                                 |
     |        (*) manually               labsixwish______________        |
     |                                                                   |
     |             +----+                          +------+              |
     |             | OK |                          | Back |              |
     |             +----+                          +------+              |
     |                                                                   |
     |                                                                   |
     +-------------------------------------------------------------------+



  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

タイムゾーンをどこにしますか?という話。
Englishを選択している場合、海外を基準にするというのがデフォルトになっていると思うので、[Asia/Tokyo]を探して、カーソルを合わせた後、スペースキーを押してTabキーで[OK]に移動してください。

Welcome to CentOS


                    +-------+ Time Zone Selection +-------+
                    |                                     |
                    | What time zone are you located in?  |
                    |                                     |
                    | [*] System clock uses UTC           |
                    |                                     |
                    |  Asia/Tehran                     ^  |
                    |  Asia/Thimphu                    :  |
                    |  Asia/Tokyo                      #  |
                    |  Asia/Ulaanbaatar                :  |
                    |  Asia/Urumqi                     v  |
                    |                                     |
                    |      +----+          +------+       |
                    |      | OK |          | Back |       |
                    |      +----+          +------+       |
                    |                                     |
                    |                                     |
                    +-------------------------------------+


  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

rootアカウントのパスワード設定です。
安易につけず、きちんとしたパスワードを設定しましょう。
ここで手抜きをして「後でー」とか言うと、サーバーを乗っ取られます。

Welcome to CentOS


                +--------------+ Root Password +---------------+
                |                                              |
                | Pick a root password. You must type it       |
                | twice to ensure you know what it is and      |
                | didn't make a mistake in typing. Remember    |
                | that the root password is a critical part    |
                | of system security!                          |
                |                                              |
                | Password:           ********________________ |
                | Password (confirm): ********________________ |
                |                                              |
                |        +----+               +------+         |
                |        | OK |               | Back |         |
                |        +----+               +------+         |
                |                                              |
                |                                              |
                +----------------------------------------------+



  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

パッケージ情報などを読み込みしてるという画面がしばらく表示されます。

Welcome to CentOS







          +----------------+ Installation Progress +----------------+
          |                                                         |
          | Retrieving installation information...                  |
          |                                                         |
          |                           40%                           |
          |                                                         |
          +---------------------------------------------------------+








  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

インストールするパッケージを選択する画面が出ます。
Desktopをインストールしても仕方が無いので、チェックを外します。

Welcome to CentOS

      +----------------------+ Package selection +----------------------+
      |                                                                 |
      | The default installation of CentOS includes a set of software   |
      | applicable for general internet usage. What additional tasks    |
      | would you like your system to include support for?              |
      |                                                                 |
      |                    [ ] Desktop - Gnome    ^                     |
      |                    [ ] Desktop - KDE      #                     |
      |                    [ ] Server             :                     |
      |                    [ ] Server - GUI       v                     |
      |                                                                 |
      |                [ ] Customize software selection                 |
      |                                                                 |
      |             +----+                        +------+              |
      |             | OK |                        | Back |              |
      |             +----+                        +------+              |
      |                                                                 |
      |                                                                 |
      +-----------------------------------------------------------------+


  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

依存関係のチェックを行います。
遅いCPUを使っていると時間がかかりますが、のんびり待ちましょう。

Welcome to CentOS







      +----------------------+ Dependency Check +-----------------------+
      |                                                                 |
      | Checking dependencies in packages selected for installation...  |
      |                                                                 |
      |                                8%                               |
      |                                                                 |
      +-----------------------------------------------------------------+








  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

終わったら、インストールしていいかどうかの最終確認されます。
[OK]を選択してインストールを開始しましょう。

Welcome to CentOS




                 +---------+ Installation to begin +----------+
                 |                                            |
                 | A complete log of your installation will   |
                 | be in /root/install.log after rebooting    |
                 | your system. You may want to keep this     |
                 | file for later reference.                  |
                 |                                            |
                 |       +----+              +------+         |
                 |       | OK |              | Back |         |
                 |       +----+              +------+         |
                 |                                            |
                 |                                            |
                 +--------------------------------------------+





  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

ネットワークの状況にもよりますが、1.5Mbpsの回線で40分くらいかかりますので、しばらく待ちましょう。

終わったら、リブートしてくれと出てくるので、再起動します。

Welcome to CentOS




          +----------------------+ Complete +-----------------------+
          |                                                         |
          | Congratulations, your CentOS installation is complete.  |
          |                                                         |
          | Remove any media used during the installation process   |
          | and press <Enter> to reboot your system.                |
          |                                                         |
          |                                                         |
          |                       +--------+                        |
          |                       | Reboot |                        |
          |                       +--------+                        |
          |                                                         |
          |                                                         |
          +---------------------------------------------------------+




                               <Enter> to reboot

仮想OSのみがリブートしてログインが表示されますが、ここは何もせず、Ctrlキーを押しながら] キーを押してください。
Domain-0のコンソールに復帰します。

 [  OK  ]
Starting smartd: [  OK  ]

CentOS release 5 (Final)
Kernel 2.6.18-8.el5xen on an i686

labsixwish login: (Ctrl + ])[root@sixwish ~]#

Domain-0のコンソールに戻ったら、仮想OSへSSHで接続を試みます。

[root@sixwish ~]# ssh 172.16.2.72
The authenticity of host '172.16.2.72 (172.16.2.72)' can't be established.
RSA key fingerprint is 4d:15:f1:09:1a:d7:29:cb:87:cc:b5:93:6a:37:76:6b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.2.72' (RSA) to the list of known hosts.
root@172.16.2.72's password:
[root@labsixwish ~]#

できたら、logout。

ちなみに、仮想OSが起動中かどうかは以下の方法で確認できます。

[root@sixwish ~]# xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0     1764     2 r-----    302.0
labsixwish                                 2      255     1 -b----    409.8
[root@sixwish ~]#

とりあえずインストールまで。

参考サイト