六、无人值守安装的完整示例(实验环境RHEL6.2):
示例拓扑图如下:
| 注意事项:以下6.1、6.2、6.3的实验步骤在192.168.0.1(启动服务器)上操作。 |
6.1 DHCP服务:
[root@localhost ~]#yum install dhcp
[root@localhost ~]#cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
[root@localhost ~]#vim /etc/dhcp/dhcpd.conf 修改该文件后,内容如下
- # dhcpd.conf
- option domain-name "example.org";
- default-lease-time 600;
- max-lease-time 7200;
- log-facility local7;
- subnet 192.168.0.0 netmask 255.255.255.0 {
- range 192.168.0.100 192.168.0.200;
- option routers 192.168.0.1;
- next-server 192.168.0.1;
- filename "pxelinux.0";
- }
- host PXE {
- hardware ethernet 00:0C:29:7B:86:E1;
- fixed-address 192.168.0.1;
- }
- host install {
- hardware ethernet 00:0C:29:7B:86:A2;
- fixed-address 192.168.0.2;
- }
[root@localhost ~]#/sbin/service dhcpd restart
6.2 TFTP服务:
[root@localhost ~]#yum install tftp-server
[root@localhost ~]#vim /etc/xinetd.d/tftp 修改该文件后,内容如下
- service tftp
- {
- socket_type = dgram
- protocol = udp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -s /var/lib/tftpboot
- disable = no
- per_source = 11
- cps = 100 2
- flags = IPv4
- }
[root@localhost ~]# /sbin/service xinetd restart
6.3 复制pxelinux.0以及Linux内核文件至TFTP共享目录:
[root@localhost ~]#yum install syslinux
[root@localhost ~]#cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost ~]#mount /dev/cdrom /media 挂载红帽6.2安装光盘
[root@localhost ~]#cp /media/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/
[root@localhost ~]#mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]#cp /media/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@localhost ~]#vim /var/lib/tftpboot/pxelinux.cfg/default 修改该文件后,内容如下
- default linux
- prompt 0
- timeout 600
- display boot.msg
- menu background splash.jpg
- menu title Welcome to Red Hat Enterprise Linux 6.2!
- menu color border 0 #ffffffff #00000000
- menu color sel 7 #ffffffff #ff000000
- menu color title 0 #ffffffff #00000000
- menu color tabmsg 0 #ffffffff #00000000
- menu color unsel 0 #ffffffff #00000000
- menu color hotsel 0 #ff000000 #ffffffff
- menu color hotkey 7 #ffffffff #ff000000
- menu color scrollbar 0 #ffffffff #00000000
- label linux
- menu label ^Install or upgrade an existing system
- menu default
- kernel vmlinuz
- append initrdinitrd=initrd.img ks=nfs:192.168.0.2:/ks/ks.cfg
注意事项:以下6.4、6.5实验步骤在192.168.0.2(安装服务器)上操作
6.4 生成Kickstart文件:
yum安装system-config-kickstart软件,使用该软件生成Kickstart文件,使用方法见第五节内容。
生成Kickstart文件后保存至/ks目录下(该目录默认不存在,需要手动创建目录)
[root@localhost ~]#vim /ks/ks.cfg Kickstart文件内容如下
- #platform=x86, AMD64, or Intel EM64T
- #version=DEVEL
- # Firewall configuration
- firewall --disabled
- # Install OS instead of upgrade
- install
- # Use NFS installation media
- nfs --server=192.168.0.2 --dir=/media
- # Root password
- rootpw --iscrypted $1$k7gSaGFT$cRcT1X9SNOuEuvUHHkkAD0
- # System authorization information
- auth --useshadow --passalgo=sha512
- # Use text mode install
- text
- firstboot --disable
- # System keyboard
- keyboard us
- # System language
- lang en_US
- # SELinux configuration
- selinux --disabled
- # Installation logging level
- logging --level=info
- # Reboot after installation
- reboot
- # System timezone
- timezone Asia/Shanghai
- # Network information
- network --bootproto=static--device=eth0--gateway=192.168.0.1 --ip=192.168.0.201 --nameserver=202.106.0.20 --netmask=255.255.255.0 --onboot=on
- # System bootloader configuration
- bootloader --location=mbr
- # Partition clearing information
- clearpart --all --initlabel
- # Disk partitioning information
- part /boot --fstype="ext4"--size=200
- part swap --fstype="swap"--size=2000
- part /home --fstype="ext4"--size=500
- part /var --fstype="ext4"--size=2000
- part / --fstype="ext4"--size=5000
- %packages
- @base
- @basic-desktop
- @chinese-support
- @desktop-debugging
- @desktop-platform
- @fonts
- @general-desktop
- @graphical-admin-tools
- @input-methods
- @internet-browser
- @x11
- cjkuni-fonts-ghostscript
- cjkuni-fonts-ghostscript
- %end
6.5 NFS共享Kickstart文件与安装源(发布安装树)
[root@localhost ~]#mount /dev/cdrom /media 挂载红帽6.2安装光盘
[root@localhost ~]#vim /etc/exports 修改该文件后,内容如下
- /ks *(ro)
- /media *(ro)
[root@localhost ~]#/sbin/service nfs restart
6.6 该步骤在安装客户机操作,通过BIOS设置开机启动项为网络启动,重启电脑即可实现无人值守安装系统!
