2008/06/21
Xen Domain-U 作成
現在のサーバーは VMware Server で仮想化しているが、新しいサーバーはXenにて仮想化したいと思う。この記事では、CentOS 5.1 をDomain-0(ホストOS)とした環境で、同じく CentOS 5.1 のDomain-U(ゲストOS)を作成する。今回はseedという名前のDomain-Uを作成することにし、今後 CentOS 5.1 のDomain-Uを作成する場合はこのイメージをコピーして基とすることにする。つまり、以下のインストール・プロセスは最初で最後になるということだ。
なお、今回は省略するが、CentOS 5.1 でDomain-0を構築するのは非常に簡単で、最小限のインストール構成にxen-3.0.3-41.el5_1.6.rpmをインストールして再起動するだけだ。
# yum install xen
それでは、まずはディスク・イメージを置くディレクトリを作成しておこう。
# mkdir -p /var/lib/xen/images/seed
Domain-Uの作成にはGUIのvirt-managerとCUIのvirt-installが使えるが、今回はvirt-installを使用した。なお、virt-installで使用するTUIのインストーラーではLVMのボリューム・グループの作成 / 編集が行えないため、その必要がある場合はvirt-managerを使用するか、--nographicsをつけずにVNC経由でインストーラーを進める必要がある。ただしこの場合はSSH経由でvirt-installを実行できない。
以下のオプションは上から順に「準仮想化」「名前」「CPU数」「メモリー量(MB)」「ディスク・イメージのパスと名前」「ディスク・イメージ容量(GB)」「スパース・ファイルにしない」「インストール・リポジトリの場所」「GUIインストールしない」を意味する。
# virt-install \ > --paravirt \ > --name=seed \ > --vcpus=1 \ > --ram=2048 \ > --file=/var/lib/xen/images/seed/system.img \ > --file-size=10 \ > --nonsparse \ > --location=http://ftp.riken.jp/Linux/centos/5/os/x86_64/ \ > --nographics
CentOSでDomain-Uを作るのであれば、特殊なドライバーを使用しない限り準仮想化が性能的に良いだろう。今回の実マシンのCPUはデュアルコアの AMD Athlon X2 だが、むやみに仮想CPU数を複数にしてしまうと物理CPUが二つ空くまで待機してしまって(一つ空いただけではDomain-Uは動かない)Domain-Uのレスポンス時間が悪化するので1にした。また、スパース・ファイルにしないと実際に使っている容量がたとえ2GBでも設定した10GBまるまるの容量のファイルができてしまうが、スパース・ファイルの書込み性能はかなり悪いので、本番環境ではnonsparseにしておきたい。(参考: @IT: 実践! Xenで実現するサーバ統合(2)(2/2))
Starting install... Retrieving CentOS... 730 kB 00:00 Retrieving vmlinuz... 100% |=========================| 1.8 MB 00:00 Retrieving initrd.img... 100% |=========================| 5.2 MB 00:00 Creating storage file... 100% |=========================| 10 GB 02:21 Creating domain... 0 B 00:02 Bootdata ok (command line is method=http://ftp.riken.jp/Linux/centos/5/os/x86_64/) Linux version 2.6.18-53.el5xen (mockbuild@builder6.centos.org) (gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)) #1 SMP Mon Nov 12 02:46:57 EST 2007 .......
virt-installの設定に問題がなければインストーラーがTUIで起動する。まずはインストールで使用する言語を指定するが、TUIでは日本語が表示できないのでEnglishでいいだろう。なお、Mac OS X のターミナルが悪いのか、どれを選択したのかが画面にまったく反映されないが、選択したい項目上でスペースを押せば正しく選択されている。
Welcome to CentOS +---------+ Choose a Language +---------+ | | | What language would you like to use | | during the installation process? | | | | Danish ^ | | Dutch : | | English # | | Estonian : | | Finnish : | | French : | | German : | | Greek v | | | | +----+ | | | OK | | | +----+ | | | | | +---------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
インストール時に使用するTCP/IPの設定を行う。今回はIPv4のみをDHCPで使用するようにしている。
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
ここまでの設定で問題なければAnacondaがTUIで起動する。
Welcome to CentOS +------------------+ CentOS +-------------------+ | | | Welcome to CentOS! | | | | | | +----+ | | | OK | | | +----+ | | | | | +-----------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
仮想ディスクxvdaのパーティション・テーブルが読み込めないという警告が出るが、xvdaはまだフォーマットしていないので当然だ。Yesを選択してxvdaを初期化しよう。
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 10237 MB (Xen Virtual Block Device) ^ | | # | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------------------------------------+ <Space>,<+>,<-> selection | <F2> Add drive | <F12> next screen
xvdaのすべてのデータが消去されるという警告が出るが、そもそもまだ何も入っていないので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
自動で作成されたパーティションを編集したい場合はここでYesをクリック。
Welcome to CentOS +-------+ Review Partition Layout +-------+ | | | Review and modify partitioning layout? | | | | +-----+ +----+ | | | Yes | | No | | | +-----+ +----+ | | | | | +-----------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
今回は以下のようなパーティションに設定した。ボリューム・グループ(VG)の名前を変更したいんだけど、TUIからはそれができない。
Welcome to CentOS +------------------------------+ Partitioning +------------------------------+ | | | Device Start End Size Type Mount Point | | VG VolGroup00 10112M VolGroup ^ | | LV LVroot 2048M ext3 / # | | LV LVswap 2048M swap : | | LV LVhome 128M ext3 /home : | | LV LVopt 32M ext3 /opt : | | LV LVtmp 2048M ext3 /tmp : | | LV LVusr 3072M ext3 /usr : | | LV LVlocal 32M ext3 /usr/local : | | LV LVvar 512M ext3 /var : | | /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
ブート・ローダーにはGRUBを使うので、デフォルトのままOKをクリック。
Welcome to CentOS +----------+ Boot Loader Configuration +-----------+ | | | Which boot loader would you like to use? | | | | (*) Use GRUB Boot Loader | | ( ) No Boot Loader | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +--------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
特別なカーネル・オプションが必要な場合はここで設定する。通常はデフォルトのままでいいだろう。
Welcome to CentOS +------------------+ Boot Loader Configuration +------------------+ | | | A few systems will need to pass special options to the kernel | | at boot time for the system to function properly. If you need | | to pass boot options to the kernel, enter them now. If you | | don't need any or aren't sure, leave this blank. | | | | console=xvc0____________________________________ | | | | [ ] Force use of LBA32 (not normally required) | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
GRUBにパスワードを設定する場合はここで設定する。
Welcome to CentOS +-------------+ Boot Loader Configuration +-------------+ | | | A boot loader password prevents users from passing | | arbitrary options to the kernel. For highest | | security, we recommend setting a password, but this | | is not necessary for more casual users. | | | | [ ] Use a GRUB Password | | | | Boot Loader Password: ________________________ | | Confirm: ________________________ | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
ブート・ローダーに表示するOS一覧だが、Xenを使ってデュアル・ブートという構成はまずあり得ないだろうし、デフォルトのままOKをクリック。
Welcome to CentOS +-------------------+ Boot Loader Configuration +-------------------+ | | | The boot manager CentOS uses can boot other operating systems | | as well. You need to tell me what partitions you would like to | | be able to boot and what label you want to use for each of them. | | | | Default Boot label Device | | * CentOS /dev/VolGroup00/LVroot ^ | | : | | : | | # | | v | | | | +----+ +------+ +------+ | | | OK | | Edit | | Back | | | +----+ +------+ +------+ | | | | | +-------------------------------------------------------------------+ <Space> select | <F2> select default | <F4> delete | <F12> next screen>
ブート・ローダーのインストール先はMBRを選択してOKをクリック。
Welcome to CentOS +----------+ Boot Loader Configuration +----------+ | | | Where do you want to install the boot loader? | | | | /dev/xvda Master Boot Record (MBR) | | /dev/xvda1 First sector of boot partition | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
ネットワーク接続する場合はここでYesをクリック
Welcome to CentOS +----+ Configure Network Interface +-----+ | | | Would you like to configure the eth0 | | network interface in your system? | | | | +-----+ +----+ | | | Yes | | No | | | +-----+ +----+ | | | | | +----------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
IPv4のみを使用することにしてOKをクリック。
Welcome to CentOS ++ Network Configuration for eth0 ++ | | | Xen Virtual Ethernet | | 00:16:3E:1E:A4:08 | | | | [*] Activate on boot | | [*] Enable IPv4 support | | [ ] Enable IPv6 support | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +----------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
今回作成しているのはシード・イメージのため、とりあえずはDHCPを使用するようにした。
Welcome to CentOS +-----+ IPv4 Configuration for eth0 +-----+ | | | Xen Virtual Ethernet | | 00:16:3E:1E:A4:08 | | | | (*) Dynamic IP configuration (DHCP) | | ( ) Manual address configuration | | | | IP Address Prefix (Netmask) | | ________________ / ________________ | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
ホスト名もとりあえずはDHCP経由で取得することにしてOKをクリック。
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 a hostname for your system. If you | | do not, your system will be known as 'localhost.' | | | | (*) automatically via DHCP | | ( ) manually ________________________ | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +------------------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
タイム・ゾーンはAsia/Tokyoを選択して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のパスワードを設定してOKをクリック。
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
インストールするパッケージの種類を選択する。今回は Server - GUI を基本にカスタマイズすることにしたので「Customize software selection」をオンにしてOKをクリック。
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? | | | | [ ] Server ^ | | [*] Server - GUI # | | [ ] Clustering : | | [ ] Storage Clustering v | | | | [*] Customize software selection | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------------------------------+ <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen
今回はシード・イメージなので、以下のものだけをオンにした。
- Administration Tools
- Development Tools
- Editors
- GNOME Desktop Environment
- Graphical Internet
- Ruby
- Text-based Internet
- X Window System
Welcome to CentOS +----------+ Package Group Selection +----------+ | | | Please select the package groups you would | | like to have installed. | | | | [*] Administration Tools ^ | | [ ] Authoring and Publishing # | | [ ] DNS Name Server : | | [ ] Development Libraries : | | [*] Development Tools : | | [ ] Dialup Networking Support v | | | | +----+ +------+ | | | OK | | Back | | | +----+ +------+ | | | | | +-----------------------------------------------+ <Space>,<+>,<-> selection | <F2> Group Details | <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 | | | +----+ +------+ | | | | | +--------------------------------------------+ <Space>,<+>,<-> selection | <F2> Group Details | <F12> next screen
インストールが開始するのでしばらく待とう。
Welcome to CentOS +------------------+ Package Installation +------------------+ | | | Name : glibc-common-2.5-18-x86_64 | | Size : 65140k | | Summary: Common binaries and locale data for glibc | | | | | | Status: | | | | 32% | | | | Packages Bytes Time | | Total : 866 1902M 0:07:49 | | Completed: 18 26M 0:00:06 | | Remaining: 848 1876M 0:07:43 | | | | 1% | | | +------------------------------------------------------------+ <Space>,<+>,<-> selection | <F2> Group Details | <F12> next screen
インストールが完了すると以下の画面になるのでRebootをクリックしよう。
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
問題なく起動すればDomain-Uの作成は完了だ。
Red Hat nash version 5.1.19.6 starting Reading all physical volumes. This may take a while... Found volume group "VolGroup00" using metadata type lvm2 8 logical volume(s) in volume group "VolGroup00" now active Welcome to CentOS release 5 (Final) Press 'I' to enter interactive startup. ...... CentOS release 5 (Final) Kernel 2.6.18-53.el5xen on an x86_64 localhost.localdomain login:
Domain-0からも以下のコマンドでDomain-Uが動作していることが確認できる。
# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 512 2 r----- 12316.4 seed 1 2047 1 -b---- 118.2
このseed内の設定ファイルをお好みで編集したら、あとは @IT: 第4回 最短3分! ゲストOSの効率的なインストール の方法でDomain-Uを作成していける。
2 Trackbacks
xenでDomain-Uを作成する
xenを活用して複数ドメインを仮想的な独自サーバで運用することを目論んでいる。 ...
Xen(Domain-U)のインストール
こんにちは。猫ITソリューションズ取締役のメイ(♀)です。 本日は、Xen(Domain-U)のインストールについてです。 いわゆるゲストOSです。 **...
Track from Your Website
http://rewse.jp/fukugan/trackback/tb.php?id=993

Comment
No Comments