Kickstart 实现Centos系统的批量自动部署
环境:Centos 6.8服务器一台,提供FTP、DHCP和镜像安装源
未安装系统的客户机一台
步骤:
1、关闭Selinux、firewall
# vi /etc/selinux/config
SELINUX=enforcing ###将enforcing 修改为disable
# service iptables stop ###停止防止墙服务
# chkconfig iptables off ###关闭开机自启
2、关闭NetworkManger
# service NetworkManager stop ###停止NetworkManger服务
# chkconfig NetworkManager off ###禁止NetworkManger开机自动
3、安装DHCP服务并配置
配置好YUM源
# yum install -y dhcp
# cp -p /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp:是否覆盖"/etc/dhcp/dhcpd.conf"?
# vi /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers 192.168.1.1;
next-server 192.168.1.11;
filename “pxelinux.0”;
default-lease-time 86400;
max-lease-time 86400;
# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.152.187.0 netmask 255.255.255.0 {
}
# This is a very basic subnet declaration.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.20192.168.1.100;
option routers 192.168.1.1;
}
# service dhcpd restart
正在启动 dhcpd: [确定]
# chkconfig dhcpd on
4、安装ftp服务并配置
# yum install -y tftp-serverxinetd vsftpd
# vim /etc/xinetd.d/tftp
# 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 /var/lib/tftpboot
disable = no ####此处将原来的yes改为no
per_source = 11
cps = 100 2
flags = IPv4
}
# service xinetd start
正在启动 xinetd: [确定]
# chkconfig xinetd on
# service vsftpd start
为 vsftpd 启动 vsftpd: [确定]
# chkconfig vsftpd on
5、安装syslinux、system-config-kickstart
syslinux 提供pxenux.0软件
system-config-kickstart 提供kickstart 软件
# yum install -y syslinux system-config-kickstart
6、拷贝相应文件并创建pxlinux.cfg文件
# mount /dev/cdrom /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
# cp /mnt/cdrom/isolinux/vmlinuz /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/initrd.img /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/boot.cat /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/boot.msg /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/vesamenu.c32 /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/splash.jpg /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/isolinux.bin /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/memtest /var/lib/tftpboot/
# cp /mnt/cdrom/isolinux/TRANS.TBL /var/lib/tftpboot/
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
vmlinuz:内核,提供驱动和识别代码
initrd.img:提供根镜像底部命令
boot.cat:菜单格式
boot.msg:菜单消息
vesamenju.c32:菜单颜色
splash.jgp:菜单背景
isolinux.bin:GRUB引导程序的前身
memtest:内存检测
TRANS.TBL:
pxelinux.0:pxeclient用于提供给pxelinux.0做程序交接
# mkdir /var/lib/tftpboot/pxelinux.cfg
# cp -p /mnt/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot//pxelinux.cfg/default
# vi /var/lib/tftpboot//pxelinux.cfg/default
default vesamenu.c32
#prompt 1
timeout 600 ####此处为启动菜单等待操作时间,默认为60S
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.8!
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 initrd=initrd.img ks=ftp://192.168.1.11/ks/s.cfg #### ks配置文件存放位置
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
# chmod 777 /var/lib/tftpboot/pxelinux.cfg/default
7、配置kickstart应答文件并配置
# system-config-kickstart
http://i2.运维网.com/images/blog/201804/24/41a054128d0f9506612e5aeab4ef6b8f.png
http://i2.运维网.com/images/blog/201804/24/721dc2b67a7dcdbbd0209e63edb9160e.png
http://i2.运维网.com/images/blog/201804/24/946586854e510a59b7ec2c8805feb535.png
http://i2.运维网.com/images/blog/201804/25/9836c75400af251a24a932629b030cce.png
http://i2.运维网.com/images/blog/201804/25/4621bf10e87968dcb60fbed8b5a7a4fa.png
http://i2.运维网.com/images/blog/201804/25/28b92a76358df1b9e0fa4745096d3ccf.png
# mount /dev/cdrom /var/ftp/pub
# mkdir/var/ftp/ks
# cp /root/ks.cfg /var/ftp/ks/
# chmod 777 /var/ftp/ks/ks.cfg
# cat /var/lib/tftpboot/pxelinux.cfg/default | grep ks
append initrd=initrd.img ks=ftp://192.168.1.11/ks/ks.cfg
8、客户机开机
http://i2.运维网.com/images/blog/201804/25/ee5949f2a909d8241b7fe2650ffc8aa1.png
http://i2.运维网.com/images/blog/201804/25/6053ee8e2fccf9b63038c7f7fafd546e.png
页:
[1]