[実践編] Ubuntu Serverをスケールアウト型サーバーに配備する(後編)
2014年3月13日(木)

Ubuntu ServerをHTTP経由で自動インストールするための設定
Ubuntu Severをネットワークインストールするためのプロトコルはいくつか存在しますが、今回はHTTP経由でインストールする管理サーバーを構築してみましょう。WebサービスがUbuntu Server標準の/var/wwwディレクトリで提供されているか確認後、管理サーバーでApache Webサービスを起動します。
# grep "/var/www" /etc/apache2/sites-available/default DocumentRoot /var/www <Directory /var/www/> # sysv-rc-conf apaceh2 on # service apache2 start
Ubuntu ServerのisoイメージをApache Webサービスで提供する/var/www/ubuntusvr120403ltsディレクトリに置き、ループバックマウントします。今回はディレクトリ名を「/var/www/ubuntusvr120403lts」にしました。このディレクトリ名は、上記のdefaultファイル内のpreseed/url=で指定した記述と矛盾がないようにします。
# mkdir -p /var/www/ubuntusvr120403lts/iso # ls -l /var/www/ubuntusvr120403lts/ total 680964 -rw-r--r-- 1 root root 697303040 Aug 28 15:18 ubuntu-12.04.3-server-amd64.iso # cd /var/www/html/ubuntusvr120403lts/ # mount -o loop,ro ubuntu-12.04.3-server-amd64.iso iso/
isoディレクトリにマウントされたUbuntu Serverのisoイメージの内容をコピーします。
# mkdir /var/www/ubuntusvr120403lts/dvd # cd /var/www/ubuntusvr120403lts/iso # find . ! -type l | cpio -pdum ../dvd/
Packages.gzファイルの処理において、Ubuntu12.04.xの自動インストールが停止する問題を回避する設定を行います。
# cd /var/www/ubuntusvr120403lts/dvd/dists/precise/restricted/binary-amd64 # gunzip Packages.gz # cp /var/www/ubuntusvr120403lts/iso/dists/precise/restricted/binary-amd64/Packages.gz . # ls Packages Packages.gz Release
preseed.cfgファイルの記述
Ubuntu Serverを自動インストールための設定ファイルpreseed.cfgを用意します。以下にGPTパーティションに対応したpreseed.cfgファイルの例を示します。
# vi /var/www/ubuntusvr120403lts/preseed.cfg d-i debian-installer/locale string en_US d-i localechooser/supported-locales en_US.UTF-8, ja_JP.UTF-8 d-i console-setup/ask_detect boolean false d-i console-setup/layoutcode string us d-i preseed/run string http://172.16.12.1/netcfg.sh ←固定IPアドレス設定に必要 d-i netcfg/use_autoconfig boolean false d-i netcfg/disable_autoconfig boolean true d-i netcfg/choose_interface select eth0 d-i netcfg/disable_dhcp boolean true d-i netcfg/get_nameservers string 172.16.12.1 d-i netcfg/get_ipaddress string 172.16.255.254 ←管理対象サーバーのIPアドレス d-i netcfg/get_netmask string 255.255.0.0←管理対象サーバーのネットマスク d-i netcfg/get_gateway string 172.16.12.1←デフォルトゲートウェイ d-i netcfg/confirm_static boolean true d-i netcfg/get_hostname string ubuntusvr254 ←管理対象サーバーのホスト名 d-i netcfg/get_domain string jpn.linux.hp.com←管理対象サーバーのドメイン名 d-i netcfg/wireless_wep string d-i keyboard-configuration/layoutcode string us←キーボードを指定(例では英語) d-i keyboard-configuration/modelcode pc105 d-i mirror/country string manual d-i mirror/http/hostname string 172.16.12.1 ←管理サーバーのIPアドレス d-i mirror/http/directory string /ubuntusvr120403lts/dvd/←isoイメージのコピー先 d-i mirror/http/proxy string d-i mirror/suite precise ←Ubuntu 12.04.xではpreciseを指定 d-i clock-setup/utc boolean false←UTCを使用しない d-i time/zone string Japan d-i clock-setup/ntp boolean false d-i partman-md/device_remove_md boolean true d-i partman-lvm/device_remove_lvm boolean true d-i partman/confirm_nooverwrite boolean true d-i partman-auto/disk string /dev/sda ←管理対象マシンの内蔵ディスクのデバイス名 d-i partman-auto/method string regular d-i partman/confirm boolean true d-i partman-auto/choose_recipe string ProLiant d-i partman/choose_partition select Finish partitioning and write changes to disk d-i partman/mount_style select traditional d-i partman-partitioning/default_label string gpt d-i partman-auto/expert_recipe string ProLiant :: \ 1 1 1 free \ $iflabel{ gpt } \ method{ biosgrub } \ . \ boot-root :: \ 300 50 300 ext4 \ ←/bootパーティションを300MB確保 $gptonly{ } \ $primary{ } $bootable{ } \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext4 } \ ←/bootパーティションをext4で利用 mountpoint{ /boot } \ . \ 500 10000 -1 ext4 \ ←残りのディスク全て/パーティションに割り当て $gptonly{ } \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext4 } \←/パーティションをext4で利用 mountpoint{ / } \ . \ 4096 600 4096 linux-swap \ ←スワップ領域を4GB確保 $gptonly{ } \ $primary{ } \ method{ swap } format{ } \ . d-i base-installer/install-recommends boolean true d-i base-installer/kernel/image string linux-generic d-i passwd/root-login boolean true ←rootアカウントでログイン可能にする d-i passwd/make-user boolean false d-i passwd/root-password password password←rootアカウントのパスワード設定 d-i passwd/root-password-again password password d-i passwd/user-password password insecure d-i passwd/user-password-again password insecure d-i user-setup/allow-password-weak boolean true d-i user-setup/encrypt-home boolean false d-i apt-setup/use_mirror boolean true d-i debian-installer/allow_unauthenticated boolean true tasksel tasksel/first multiselect none d-i pkgsel/include string openssh-server build-essential d-i pkgsel/upgrade select none d-i pkgsel/update-policy select none popularity-contest popularity-contest/participate boolean false d-i pkgsel/updatedb boolean true d-i grub-installer/grub2_instead_of_grub_legacy boolean true ←GRUB2を指定 d-i grub-installer/only_debian boolean true d-i grub-installer/bootdev string /dev/sda ←ブートデバイスを指定 d-i finish-install/reboot_in_progress note
管理対象サーバーに固定のIPアドレスを設定する場合、以下のnetcfg.shスクリプトを管理サーバーに配置します。上記preseed.cfgファイル内で指定していますので、記述方法を確認してみてください。
# vi /var/www/netcfg.sh #!/bin/sh killall.sh; netcfg
Ubuntu Serverの自動インストールサーバー構築に使用する「preseed」
『スケールアウト型OSSクラウド基盤に最適なUbuntu Serverをひも解く』 第6回のサンプルファイルです。
連載バックナンバー
Think ITメルマガ会員登録受付中
Think ITでは、技術情報が詰まったメールマガジン「Think IT Weekly」の配信サービスを提供しています。メルマガ会員登録を済ませれば、メルマガだけでなく、さまざまな限定特典を入手できるようになります。
全文検索エンジンによるおすすめ記事
- [実践編] Ubuntu Serverをスケールアウト型サーバーに配備する(前編)
- Ansibleの機能を拡張するAnsible Tower
- [入門編] Ubuntu Serverとその他のサーバーOSを比較する
- ownCloud導入はじめの一歩(仮想マシンイメージとCentOS 7のインストール手順)
- [実践編] MaaSとJujuによるOSS配備、Ubuntu Serverの運用・管理(前編)
- Windows Azure上にLinuxインスタンスを立ち上げる(クエスト5)
- XML-RPCを利用したWeb API
- Windows Azure仮想マシンでLinuxサーバーを構築しよう
- Ansible:さらにPlaybookをきわめる
- [入門編] Ubuntu Serverの基礎(後編)