Linux系统的pxe自动化运维部署

来源:互联网 发布:动漫 神作 知乎 编辑:程序博客网 时间:2024/05/23 11:52

1.packags

安装所需包:need packages:system-config-kickstart                ## 自动应答脚本制作工具syslinux                               ## 获得pxelinux.0文件安装包dhcp                                   ##分配ip给客户机的服务tftp-server                            ##提供tftp协议的服务httpd                                  ##安装源共享服务

自动安装原理:
1.客户机从自己的PXE网卡启动,向本网络中的DHCP服务器索取IP
2.DHCP服务器返回分给客户机IP
3.客户机向本网络中的TFTP服务器索取文件
4.客户机取得bootstrap文件后之执行引导文件完成引导
5.然后读取配置文件,通过TFTP服务器加载内核和文件系统
6.进入安装画面, 此时可以通过选择HTTP方式进行安装

>

从这里我们不难得到实现PXE网络安装必需的4个要素
1.客户机的网卡必须为PXE网卡
2.网络中必须要有HTTP,DHCP和TFTP服务器,当然这两个服务器可以是同一台物理主机
3.所安装的必须支持网络安装。

步骤

1、配置yum源,下面仅做简单的介绍,在系统软件安装那篇博客有详细解释

特别注意的是在操作步骤之前需要在源文件挂载挂载在
/var/www/html/rhel7.2下
这里写图片描述

vim /etc/yum/repos.d/rhel7.2
这里写图片描述

表示挂载已成功了
这里写图片描述

2.配置dhcpd 服务

vim  /etc/dhcpd/dhcpd.confoption domain-name "example.com";           ##域名option domain-name-servers 192.168.0.79;    ##dnsdefault-lease-time 600;                     ##默认租约期max-lease-time 7200;                        ##最长租约期log-facility local7;                        ##日志级别subnet 192.168.0.0 netmask 255.255.255.0 {  ##网段,子网掩码  range 192.168.0.102 192.168.0.111;        ##地址范围  option routers 192.168.0.254;             ##网关  filename "pxelinux.0";                    ##pxe启动程序  next-server 192.168.0.79;                 ##tftp主机地址}

填写域名,dhcp共享服务的IP地址

这里写图片描述

注释相应的网段
这里写图片描述

systemctl restart dhcpd ##重启dhcpd服务
systemctl stop firewalld ##关闭firewalld服务

3.配置system-config-kickstart 自动应答脚本制作工具
[root@foundation27 ~]# yum install system-config-kickstart
[root@foundation27 ~]#system-config-kickstart

1.填写root密码
这里写图片描述
2.填写HTTP协议
这里写图片描述
3.全选第一个,进行分区
这里写图片描述
4./boot 200M
这里写图片描述
5.swap 500M
这里写图片描述
6.剩下的都给/
这里写图片描述
7.配置DHCP服务
这里写图片描述
8.设置开机不启动
这里写图片描述
9.保存在file system /var/www/html
这里写图片描述

>

vim /var/www/html/ks.cfg ##配置ks.cfg文件

测试效果

这里写图片描述
vim /bin/xnjaz.sh
这里写图片描述

4配置tftp文件服务

vim  /etc/xinetd.d/tftpservice tftp{        socket_type    = dgram        protocol       = udp        wait           = yes        user           = root        server         = /usr/sbin/in.tftpd        server_args    = -s /var/lib/tftpboot        disable        = <<<<<<<<<yes--->no>>>>>>        per_source     = 11        cps            = 100 2        flags          = IPv4}        systemctl restart xinetd

1)
cd /var/lib/tftpboot/
mkdir pxelinux.cfg
2)
mount the iso of the rhel7
cp isolinux/* /var/lib/tftpboot
3)
cp /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
4)
make a userfully install source and kickstart,my of this is in the ftp’s pub
ftp://192.168.0.252/pub/rhel6
ftp://192.168.0.252/pub/ks.cfg
5)
config the file of /var/lib/tftpboot/pxelinux.cfg/default like this:

default vesamenu.c32
timeout 600 ##等待时间

display boot.msg

Clear the screen when exiting the menu, instead of leaving the menu displayed.
For vesamenu, this means the graphical background is still displayed without
the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title Red Hat Enterprise Linux 7.0 ##大标题
menu vshift 8
menu rows 18
menu margin 8
menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

Border Area
menu color border * #00000000 #00000000 none

Selected item
menu color sel 0 #ffffffff #00000000 none

Title bar
menu color title 0 #ff7ba3d0 #00000000 none

Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

Help text
menu color help 0 #ffffffff #00000000 none

A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

label linux
menu label ^Install Red Hat Enterprise Linux 7.0 ##小标题
menu default ##默认标题设定
kernel vmlinuz
append initrd=initrd.img repo=http://172.25.254.100/soucre ks=http://172.25.254.100/ks.cfg ##安装源和ks

label check
menu label Test this ^media & install Red Hat Enterprise Linux 7.0
#menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.0\x20Server.x86_64 rd.live.check quiet

menu separator # insert an empty line

utilities submenu
menu begin ^Troubleshooting
menu title Troubleshooting

label vesa
menu indent count 5
menu label Install Red Hat Enterprise Linux 7.0 in ^basic graphics mode
text help
Try this option out if you’re having trouble installing
Red Hat Enterprise Linux 7.0.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.0\x20Server.x86_64 xdriver=vesa nomodeset quiet

label rescue
menu indent count 5
menu label ^Rescue a Red Hat Enterprise Linux system
text help
If the system will not boot, this lets you access files
and edit config files to try to get it booting again.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.0\x20Server.x86_64 rescue quiet

label memtest
menu label Run a ^memory test
text help
If your system is having issues, a problem with your
system’s memory may be the cause. Use this utility to
see if the memory is working correctly.
endtext
kernel memtest

menu separator # insert an empty line

label local
menu label Boot from ^local drive
localboot 0xffff

menu separator # insert an empty line
menu separator # insert an empty line

label returntomain
menu label Return to ^main menu
menu exit

menu end

>

修改标题
这里写图片描述

修改yum源及ks源
这里写图片描述

测试界面:

1.设置开机网卡启动
这里写图片描述
2进入修改的界面
这里写图片描述
3.成功启动
这里写图片描述