-m ogg 图形界面 tftp txt rip tftp 服务 pxelinux
1、基础网络建设与搭建 DHCP 服务
1) 配置静态 IP 地址并重起网卡
- cat/etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE=eth0
- TYPE=Ethernet
- ONBOOT=yes
- NM_CONTROLLED=yes
- BOOTPROTO=static
- IPADDR=10.0.0.4
- NETMASK=255.255.255.0
- GATEWAY=10.0.0.2/etc/init.d/network restart
- ifconfigeth0
2)安装配置 DHCP 服务
- yum-yinstall dhcp
- vim /etc/dhcp/dhcpd.conf
- default-lease-time 600;
- max-lease-time 7200;
- ddns-update-style none;
- option domain-name-servers202.106.0.20; #DNS地址可配置2个用逗号分隔
- ignore client-updates;
- subnet 10.0.0.0netmask255.255.255.0 {
- range 10.0.0.100 10.0.0.150; #宣告获取地址段
- option subnet-mask255.255.255.0; #子网
- option routers 10.0.0.2; #获取网关地址
- next-server10.0.0.4; #重点配置PEX地址
- filename "pxelinux.0"; #内核文件名
#配置开机自启动 chkconfig --add dhcpdchkconfig dhcpd onchkconfig --list dhcpd# 查看 DHCP 监听端口好 UDP 67netstat -lntup|grep 67
2、搭建 TFTP 服务
yum -y install tftp-server tftp
- vim /etc/xinetd.d/tftp
- #配置TFTP配置文件:
- service tftp
- {
- socket_type = dgram
- protocol = udp
- wait= yes
- user = root
- server = /usr/sbin/in.tftpd
- server_args = -s /tftpboot #修改TFTP服务目录
- disable = no #修改为no,启动TFTP
- per_source =11
- cps =100 2
- flags = IPv4
- }
#配置自启动 chkconfig tftp onchkconfig --list tftpchkconfig --list xinetd# 重启动 xinetd 服务,TFTP 是由 xinetd 服务运行的 / etc/init.d/xinetd restart netstat -lntup|grep 69 ;netstat -a|grep tftpudp 0 0 0.0.0.0:69 0.0.0.0:* 1877/xinetd udp 0 0 *:tftp #TFTP 端口号为 UDP 的 69# 测试下载 mkdir /tftpbootcd /tftpboot/touch test.txtlstest.txtcd ..tftp 10.0.0.4 -c get test.txtls #下载成功!test.txt
3、搭建 HTTP 服务
yum -y install httpd# 配置自启动 chkconfig --add httpdchkconfig httpd onchkconfig --list httpd# 启动 http 服务 / etc/init.d/httpd startnetstat -lntup|grep 80
#使用浏览器测试 http://10.0.0.4
4、组建 PXE 服务环境
1) 安装 syslinux 包 yum -y install syslinux# 如不安装 syslinux 包就没有 pxelinux.0 文件 find / -type f -name "pxelinux.0" /usr/share/syslinux/pxelinux.0# 将 pxelinux.0 拷贝到 tftp 服务目录 cp /usr/share/syslinux/pxelinux.0 /tftpboot/# 在 tftp 服务目录下创建 pxelinux.cfg 目录 mkdir /tftpboot/pxelinux.cfg -p2) 挂载 linux 系统盘,拷贝 linux 内核,初始化镜像文件 mkdir -p /media/cdrommount -t iso9660 -o loop /dev/sr0 /media/cdromcd /media/cdrom/images/pxebootcp vmlinuz initrd.img /tftpboot/cd /tftpboot/lsinitrd.img pxelinux.0 pxelinux.cfg vmlinuz# 配置启动菜单文件,将系统自带的启动文件拷贝到 TFTP 目录下改名为 cp /media/cdrom/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default# 修改启动菜单文件
- cat default
- default auto #指定默认启动项
- prompt 0 #为0时不选择自动按默认安装,为1时可选择选项安装
- label auto #配置选项auto
- kernel vmlinuz #指定内核
- append initrd=initrd.img ks=http://10.0.0.4/ks.cfg devfs=nomount ramdisk_size=8192 #指定自动安装文件ks.cfg
- label linux text
- kernel vmlinuz
- append initrd=initrd.img devfs=nomount ramdisk_size=8192
- label rescue
- kernel vmlinuz
- append initrd=initrd.img rescue
- #重启动TFTP服务加载配置
- /etc/init.d/xinetd restart
5、创建 kickstart 文件
1) 安装 system-config-kickstartyum -y install system-config-kickstart# 注意安装桌面服务才能启动 KICKSTART,创建启动文件 / usr/bin/system-config-kickstart
- cat ks.cfg
- #platform=x86, AMD64, or Intel EM64T
- #version=DEVEL
- # Firewall configuration关闭防火墙
- firewall --disabled
- # Install OS instead of upgrade 安装系统
- install
- # Use network installation 使用网络安装,这里配置http获取安装包
- url --url="http://192.168.146.128/"
- key --skip
- # Root password 配置ROOT密码
- rootpw --iscrypted $1$jIsDXG2F$EGT.VAhEBlZ/ww9GNOTo7.
- # System authorization information 系统授权信息
- auth --useshadow --passalgo=md5
- # Use graphical install 图形安装
- graphical
- # System keyboard 配置键盘
- keyboard us
- # System language 配置系统语言
- lang en_US
- # SELinux configuration 关闭selinux
- selinux --disabled
- # Do not configure the X Window System 不安装图形界面
- skipx
- # Installation logging level 安装系统日志记录级别
- logging --level=info
- # Reboot after installation 安装完重新引导
- reboot
- # System timezone #配置时区
- timezone Asia/Shanghai
- # Network information 配置网络为自动获取
- network --bootproto=dhcp --device=eth0 --onboot=on
- # System bootloader configuration 系统引导程序配置
- bootloader --location=mbr
- # Clear the Master Boot Record 清除主引导记录
- zerombr
- # Partition clearing information 分区信息
- clearpart --all
- # Disk partitioning information 指定分区大小
- part swap --fstype="swap"--size=2048
- part /boot --fstype="ext4"--size=200
- part / --fstype="ext4"--grow --size=1%packages
- @base
- @compat-libraries
- @debugging
- @development
- %end
#将应答脚本拷贝到 http 目录,并赋予权限 cp ks.cfg /var/www/html/chown apache.apache /var/www/html/ks.cfg
6、启动客户机安装
注意:客户机要和服务器在同一个局域网内如果使用 vmware 做实验,需要关闭 VMware 自带的 DHCP 功能
排除思路:1) 客户机是否获取 IP 地址,可查看网络和 DHCP 服务 2) 查看链接 TFTP 是否正常如链接正常在获取 IP 地址后会显示:TFTP prefix:trying to load: pxelinux.cfg/default ok 然后加载内核:loading vmlinuz........loading initrd.img.........3) 加载完内核后会链接下载安装系统文件,如 tfp,http 获取等
PXE 批量自动部署 linux 系统环境
来源: http://www.bubuko.com/infodetail-2030920.html