PXE+cobbler+kickstart全自动无人值守网络安装系统
通过配置cobbler自动部署DHCP、TFTP、HTTP,在安装过程中加载kiskstart无人值守安装应答文件实现无人值守。从客户端使用PXE引导启动安装。
1. 安装相关软件:
wget rpm -ivh rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm yum -y install cobbler tftp-server dhcp httpd xinetd
注意 /var/www/cobbler 目录必须具有足够容纳 Linux 安装文件的空间(移动,建软链接) #ln -s /cobbler /var/www
2. 检查 cobbler 配置:
cobbler check
按提示解决相关问题,把 /etc/cobbler/settings 中的 server 和 next_server 设为本服务器的 IP 地址,manage_dhcp 设为 1,以便管理 DHCP 将 /etc/xinetd.d/tftp 中 disable = no
3. 导入CentOS 安装 DVD ISO 中的文件:
mount -o loop /home/dtm/CentOS-5.5-x86_64-bin-DVD.iso /mnt/iso # 将ISO文件挂载到 /mnt/iso 目录 cobbler import --mirror=/mnt/iso --name=centos5.5 # 从 /mnt/iso目录导入所有安装文件,命名为 centos5.5 cobbler distro list # 查看导入结果
[root@testding www]# cobbler distro list centos5.5-x86_64 centos5.5-xen-x86_64
------------------------------- cobbler目录及文件
cobbler相关配置文件: /etc/cobbler cobbler数据存储目录: /var/www/cobbler dhcp配置文件: /etc/cobbler/dhcp.template #需修改 pxe配置文件: /tftpboot/pxelinux.cfg/default ks模板文件: /var/lib/cobbler/kickstart_fc6.ks #需修改 -------------------------------- 4. 修改 DHCP 和 Kickstart 配置模板:
vi /etc/cobbler/dhcp.template # DHCP 配置模板,根据提示修改下面模板 ################################ ddns-update-style interim;
allow booting; allow bootp;
ignore client-updates; set vendorclass = option vendor-class-identifier;
subnet 192.168.20.0 netmask 255.255.255.0 { option routers 192.168.20.100; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.20.101 192.168.20.200; filename "/pxelinux.0"; default-lease-time 21600; max-lease-time 43200; next-server 192.168.20.100; } ############################### vi /etc/cobbler/kickstart_fc6.ks # Kickstart 配置模板 ##################### #platform=x86, AMD64, 或 Intel EM64T #created by dingtm #date:2011.01.04 # System authorization information auth --useshadow --enablemd5 # System bootloader configuration bootloader --location=mbr # Partition clearing information clearpart --all --initlabel # Use text mode install text # Firewall configuration firewall --disabled # Run the Setup Agent on first boot firstboot --disable # System keyboard keyboard us # System language lang zh_CN # Installation logging level logging --level=info # Use network installation url --url= # Network information network --bootproto=bootp --device=eth0 --onboot=on # Reboot after installation reboot #Root password rootpw 123465
# SELinux configuration selinux --disabled # Do not configure the X Window System skipx # System timezone timezone Asia/Chongqing # Install OS instead of upgrade install # Disk partitioning information(根据不同服务需求更改分区大小) part /boot --asprimary --bytes-per-inode=4096 --fstype="ext3" --grow --maxsize=200 --size=1 part / --asprimary --bytes-per-inode=4096 --fstype="ext3" --grow --maxsize=8920 --size=1 part swap --bytes-per-inode=4096 --fstype="swap" --grow --maxsize=500 --size=1 part /home --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%packages @ development-libs @ admin-tools @ system-tools @ x-software-development @ base @ chinese-support @ editors @ legacy-software-support %post
echo "NETWORKING=yes" >/etc/sysconfig/network echo "HOSTNAME=tmding" >>/etc/sysconfig/network echo "nameserver 202.106.0.20" >/etc/resolv.conf
#给系统添加用户: groupadd tmding -g 98 useradd -u 98 -g tmding tmding
#关闭不必要的服务 for service in `chkconfig --list|awk '{print $1}'|egrep -v "^$"|awk -F ":" '{print $1}'`; do chkconfig $service off;done for service in crond sshd syslog network; do chkconfig $service on;done
#更改SSH远程默认端口 echo "Port 15157" >>/etc/ssh/sshd_config ################################# 5. 生成并同步所有配置:
cobbler sync
注:每次更改Kickstart 配置文件,都需要使用cobbler sync重新同步所有配置
6. 启动相关服务:
/etc/init.d/httpd start /etc/init.d/xinetd start /etc/init.d/dhcpd start /etc/init.d/cobblerd start
7.客户端启动PXE 安装
启动另一台新服务器,通过 PXE 启动进入,提示"boot:"时输入"menu"即可进入蓝色的 Cobbler 安装界面,选择安装项,自动完成系统安装。
http方式安装:服务器:192.168.20.100 目录:/cobbler/ks_mirror/centos/
8.重装系统:
在要重装的机器安装koan yum install koan 查看cobbler服务器有哪些安装盘 koan --list-profiles --server=192.168.20.100 选择要重装的系统并重启 koan --replace-self --server=192.168.20.100 --profile=centos5.5 reboot
附上服务控制脚本: [root@testding ~]# cat cobbler.sh #!/bin/sh # created by dingtm # date: 2010.12.31
case $1 in start) /etc/init.d/httpd start /etc/init.d/xinetd start /etc/init.d/dhcpd start /etc/init.d/cobblerd start ;; stop) /etc/init.d/httpd stop /etc/init.d/xinetd stop /etc/init.d/dhcpd stop /etc/init.d/cobblerd stop ;; status) /etc/init.d/httpd status /etc/init.d/xinetd status /etc/init.d/dhcpd status /etc/init.d/cobblerd status ;; sync) cobbler sync ;; *) echo "Input error,please in put 'start|stop|status|sync'!"; exit 2>&1 >/dev/null & ;; esac |
阅读(1616) | 评论(0) | 转发(0) |