PXEブートサーバー構築
ディスクレスLVS構築のために、PXEブート(ネットワークブート)のイメージ元になるサーバーをCentOSで構築しました。
syslinux、tftp、DHCPのインストール
sudo yum install -y syslinux tftp* dhcp rpcbind dracut-networkhosts.allowでIP制限を掛けている場合、許可設定をする
sudo vi /etc/hosts.allow
in.tftpd : 許可IP/etc/xinet.d/tftp の編集
sudo vi /etc/xinet.d/tftp
service tftp
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -v -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
xinetdのリスタート
sudo /etc/inet.d/xinetd restart
YUMレポジトリ書き換え(これを行わないと後のgroupinstall実行不可)
sudo vi /etc/yum.repos.d/CentOS-Base.repo# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-6.3 - Base
mirrorlist=http://mirrorlist.centos.org/?release=6.3&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/6.3/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#released updates 
[updates]
name=CentOS-6.3 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=6.3&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/6.3/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful
[extras]
name=CentOS-6.3 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=6.3&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/6.3/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.3 - Plus
mirrorlist=http://mirrorlist.centos.org/?release=6.3&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/6.3/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.3 - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=6.3&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/6.3/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[cloudera-cdh3]
# Packages for Cloudera's Distribution for Hadoop, Version 3, on RedHat or CentOS 6
name=Cloudera's Distribution for Hadoop, Version 3
mirrorlist=http://archive.cloudera.com/redhat/6/x86_64/cdh/3/mirrors
gpgkey = http://archive.cloudera.com/redhat/6/x86_64/cdh/RPM-GPG-KEY-cloudera    
gpgcheck = 1
tftpディレクトリにYUMパッケージをgroupinstall
sudo yum -y groupinstall "Base" "Server Platform" --installroot=/var/lib/tftpboot/centos6/root/ファイル整理
sudo cp -f -R /root /var/lib/tftpboot/centos6/root/
grep ^root /etc/shadow | cut -d: -f2 
$6$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
vi /var/lib/tftpboot/centos6/root/etc/shadow# クライアント配信用システムの rootパスワードを設定
root:$6$xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:14937:0:99999:7:::sudo vi /var/lib/tftpboot/centos6/root/etc/fstabnone    /tmp        tmpfs   defaults   0 0
tmpfs   /dev/shm    tmpfs   defaults   0 0
sysfs   /sys        sysfs   defaults   0 0
proc    /proc       proc    defaults   0 0
初期ブートイメージ作成
sudo cp /boot/vmlinuz-2.6.32-279.5.2.el6.x86_64 /var/lib/tftpboot/centos6/
sudo dracut initramfs-2.6.32-279.5.2.el6.x86_64.img 2.6.32-279.5.2.el6.x86_64
sudo mv initramfs-2.6.32-279.5.2.el6.x86_64.img /var/lib/tftpboot/centos6/pxeのconfig作成
sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg
vi /var/lib/tftpboot/pxelinux.cfg/defaultdefault centos6.3
label centos6.3
   kernel centos6/vmlinuz-2.6.32-279.5.2.el6.x86_64
   append initrd=centos6/initramfs-2.6.32-279.5.2.el6.x86_64.img root=nfs:192.168.134.178:/var/lib/tftpboot/centos6/root rw selinux=0
dhcpのconf設定
vi /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
ddns-update-style interim;
ignore client-updates;
subnet 192.168.0.0 netmask 255.255.0.0 {
# --- default gateway
        option routers                  192.168.10.2;
        option subnet-mask              255.255.0.0;
        option domain-name              "domain.org";
        option domain-name-servers      192.168.10.2;
        filename "pxelinux.0";
        option root-path "/home/tftpboot";
        next-server 192.168.10.2;
        option time-offset              -18000; # Eastern Standard Time
        range dynamic-bootp 192.168.10.150 192.168.10.151;
        default-lease-time 21600;
        max-lease-time 43200;
}
NFS設定
sudo vi /etc/exports/var/lib/tftpboot/centos6/root 192.168.10.0/24(rw,sync,no_root_squash,no_all_squash)各サービスの起動
sudo /etc/init.d/dhcpd start
sudo /etc/init.d/rpcbind start
sudo /etc/init.d/nfslock start
sudo /etc/init.d/nfs start
これでPXEブートサーバーの設定は完了です。クライアントになるLVSの設定は別途。

