新しく到着したサーバには、CD ドライブがついていないということでネットワークインストールしてみようと考えた。そこで、巷で話題の cobbler 0.8.3 を使ってみた。まず、試験環境を VMWare 上の CentOS 5.1 64 ビット版で用意して試してみた。mizzy さんの記事がとても参考になった。
まず、rpmforge をインストールする。
# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
# rpm -ivh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
次に、cobbler をインストールする。
# yum install cobbler
tftp とか httpd とか必要なものがいっきにインストールされる。
さっそく設定してみる。
# cobbler check
The following potential problems were detected:
#0: The ’server’ field in /var/lib/cobbler/settings must be set to something other than localhost, or kickstarting features will not work. This should be a resolvable hostname or IP for the boot server as reachable by all machines that will use it.
#1: For PXE to be functional, the ‘next_server’ field in /var/lib/cobbler/settings must be set to something other than 127.0.0.1, and should match the IP of the boot server on the PXE network.
#2: change ‘disable’ to ‘no’ in /etc/xinetd.d/tftp
ということで、/var/lib/cobbler/settings を次のように変更する。変更する部分は、manage_dhcp を 1、next_server と server の部分をホストの IP アドレスに書き換える。
—
bootloaders:
ia64: /var/lib/cobbler/elilo-3.6-ia64.efi
standard: /usr/lib/syslinux/pxelinux.0
default_kickstart: /etc/cobbler/default.ks
dhcpd_bin: /usr/sbin/dhcpd
dhcpd_conf: /etc/dhcpd.conf
dnsmasq_bin: /usr/sbin/dnsmasq
dnsmasq_conf: /etc/dnsmasq.conf
httpd_bin: /usr/sbin/httpd
kernel_options:
ksdevice: eth0
lang: ‘ ‘
text: ~
koan_path: ”
manage_dhcp: 1
manage_dhcp_mode: isc
minimize_syncs: 1
next_server: ‘192.0.168.1′
server: ‘192.0.168.1′
syslog_port: 25150
tftpboot: /tftpboot
tftpd_bin: /usr/sbin/in.tftpd
tftpd_conf: /etc/xinetd.d/tftp
webdir: /var/www/cobbler
xmlrpc_port: 25151
yum_core_mirror_from_server: 0
次に tftp を有効にするために、/etc/xinetd.d/tftp を次のように変更する。disable を yes から no にする。
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
cobblerd を起動する。
# /etc/init.d/cobblerd start
# chkconfig cobblerd on
xinetd を起動する。
# /etc/init.d/xinetd start
# chkconfig xinetd on
httpd を起動する。
# /etc/init.d/httpd start
# chkconfig httpd on
とりあえず、iptables をオフにしておく。
# /etc/init.d/iptales stop
# chkconfig iptables off
dhcpd をインストールする。
# yum install dhcp
/etc/cobbler/dhcp.template を次のように変更する。IP アドレスの部分を環境に応じて書き換える。
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
subnet 192.0.168.0 netmask 255.255.255.0 {
option routers 192.0.168.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.0.168.10 192.0.168.20;
filename “/pxelinux.0″;
default-lease-time 21600;
max-lease-time 43200;
next-server $next_server;
}
$insert_cobbler_system_definitions
そして、ネットワークに必要なファイルを作る。今回は、CentOS 5.1 DVD イメージをダウンロードしてマウントしてある。/var/www/cobbler に必要なファイルを自動的に作ってくれるので便利。容量は、だいだい くらい 4GB くらい必要。けっこう時間がかかる。僕の環境 (Macboom on VMware fusion)だと、だいだい 30 分くらいかかった。
# mount -rt iso9660 /dev/cdrom /mnt
# cobbler import –mirror=/mnt –name=centos51
(書略)
—————- (syncing)
sync distro: centos51-xen-x86_64
sync distro: centos51-x86_64
sync profile: centos51-xen-x86_64
sync profile: centos51-x86_64
cobbler のキックスタートファイルを変更したときは、次のコマンドを実行する。
# cobbler sync
sync distro: centos-xen-x86_64
sync distro: centos-x86_64
sync profile: centos-xen-x86_64
sync profile: centos-x86_64
Shutting down dhcpd: [FAILED]
Starting dhcpd: [OK]
どんなファイルがあるか確認してみる。
# cobbler report
distro : centos-x86_64
kernel : /var/www/cobbler/ks_mirror/centos/images/pxeboot/vmlinuz
initrd : /var/www/cobbler/ks_mirror/centos/images/pxeboot/initrd.img
kernel options : {}
architecture : x86_64
ks metadata : {’tree’: ‘http://192.0.168.1/cblr/links/centos-x86_64′}
breed : redhat
(略)
profile : centos-x86_64
distro : centos-x86_64
kickstart : /etc/cobbler/kickstart_fc6.ks
kernel options : {}
ks metadata : {}
virt file size : 5
virt ram : 512
repos : []
(略)
cd
# cobbler list
distro centos-xen-x86_64
profile centos-xen-x86_64
distro centos-x86_64
profile centos-whx86_64
kickstart のファイルは、/etc/cobbler/kickstart_fc6.ks だということが分かる。
付属の /etc/init.d/cobbler は restart がおかしいので、次のように修正する
45c45
< killproc /usr/bin/cobblerd -TERM >& /dev/null
—
> pkill -9 cobblerd >/dev/null 2>/dev/null
ちなみに上の不具合は、最新版の 1.x 系では修正されているので、今から試してみる人は 1.x 系をおすすめします。
cobbler を使うと、ローカルの yum ミラーリポジトリも扱うことができるので、かなり便利なのでおすすめです。
Tags: cobbler