Centos7中PXE自动化安装服务器

首先修改作为DHCP服务器的网卡配置信息

[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens192

TYPE=Ethernet

BOOTPROTO=static

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPADDR=15.1.1.1

NETMASK=255.255.255.0

NAME=ens192

DEVICE=ens192

ONBOOT=yes

安装httpd tftp-server dhcp syslinux xinetd

[[email protected] ~]# yum install httpd tftp-server dhcp syslinux xinetd –y

修改dhcp配置文件做广播服务器

[[email protected] ~]# vim /etc/dhcp/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

authoritative;

allow booting;

allow bootp;

subnet 15.1.1.0 netmask 255.255.255.0   #指定网段

{   option routers        15.1.1.1;     #指定网关

option subnet-mask    255.255.255.0;

range dynamic-bootp 15.1.1.2 15.1.1.200;     #分配地址池

next-server 15.1.1.1;       #DHCP服务器地址

filename "pxelinux.0";      #PXE所需文件

default-lease-time      21000;

max-lease-time        43200;

option time-offset      -18000;

}

修改tftp配置将disable选项由yes改为no

[[email protected] ~]# 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

per_source              = 11

cps                     = 100 2

flags                   = IPv4

}

拷贝安装所有需要的cfg文件

[[email protected] ~]# cp /root/anaconda-ks.cfg /var/www/html/ks.cfg

[[email protected] ~]# chmod 555 /var/www/html/ks.cfg

修改cfg文件

[[email protected] ~]# vim /var/www/html/ks.cfg

#version=RHEL7

# Install OS instead of upgrade

install

# System authorization information

auth --enableshadow --passalgo=sha512

# Use CDROM installation media

url --url "http://15.1.1.1/centos"    #安装源修改为网络路径

# Use graphical install

graphical

# Run the Setup Agent on first boot

firstboot --enable

ignoredisk --only-use=sda

# Keyboard layouts

keyboard --vckeymap=us --xlayouts=‘us‘

reboot

# System language

lang en_US.UTF-8

# Firewall configuration

firewall --disabled

# SELinux configuration

selinux --disabled

# Network information

network  --bootproto=dhcp --device=ens160 --onboot=off --ipv6=auto

network  --hostname=localhost.localdomain

# Root password

rootpw --iscrypted $6$AtHUq/R7EaCq4m4t$j17qu0sg1DwO2vYoyOmaTtyqsLRjPD.PW0mrj92.OXWb9ujyAfx.Cp9SJQwYAzeBpd1KN4Lq8CsygWZRZw610/

# System timezone

timezone Asia/Shanghai --isUtc --nontp

# System bootloader configuration

bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda

autopart --type=lvm

# Partition clearing information

clearpart --none --initlabel

%packages

@core

kexec-tools

%end

%addon com_redhat_kdump --enable --reserve-mb=‘auto‘

%end

创建安装源和安装文件

[[email protected] ~]# mkdir /var/www/html/centos

[[email protected] ~]# mkdir /var/www/html/centos

[[email protected] ~]# mount /dev/cdrom /mnt/

[[email protected] ~]# cp -r /mnt/* /var/www/html/centos/

[[email protected] ~]# yum install tree –y

[[email protected] ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

[[email protected] ~]# mkdir /var/lib/tftpboot/pxelinux.cfg

[[email protected] ~]# cp /var/www/html/centos/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

[[email protected] ~]# cp /var/www/html/centos/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/

[[email protected] ~]# cp /var/www/html/centos/isolinux/{vesamenu.c32,boot.msg,splash.png} /var/lib/tftpboot/

[[email protected] ~]# tree -aL 2 /var/www/html/

/var/www/html/

├── centos

│   ├── CentOS_BuildTag

│   ├── EFI

│   ├── EULA

│   ├── GPL

│   ├── images

│   ├── isolinux

│   ├── LiveOS

│   ├── Packages

│   ├── repodata

│   ├── RPM-GPG-KEY-CentOS-7

│   ├── RPM-GPG-KEY-CentOS-Testing-7

│   └── TRANS.TBL

└── ks.cfg

7 directories, 7 files

修改default文件

[[email protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default

default vesamenu.c32

timeout 60

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 CentOS 7

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 CentOS 7

kernel vmlinuz

menu default

#append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet

append initrd=initrd.img inst.ks=http://15.1.1.1/ks.cfg quiet

label check

menu label Test this ^media & install CentOS 7

menu default

kernel vmlinuz

#append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

append initrd=initrd.img inst.ks=http://15.1.1.1/ks.cfg quiet

menu separator # insert an empty line

# utilities submenu

menu begin ^Troubleshooting

menu title Troubleshooting

label vesa

menu indent count 5

menu label Install CentOS 7 in ^basic graphics mode

text help

Try this option out if you‘re having trouble installing

CentOS 7.

endtext

kernel vmlinuz

append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet

label rescue

menu indent count 5

menu label ^Rescue a CentOS 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=CentOS\x207\x20x86_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

[[email protected] ~]# tree /var/lib/tftpboot/

/var/lib/tftpboot/

├── boot.msg

├── initrd.img

├── pxelinux.0

├── pxelinux.cfg

│   └── default

├── splash.png

├── vesamenu.c32

└── vmlinuz

1 directory, 7 files

开启服务并且查看服务开启情况

[[email protected] ~]# systemctl start httpd dhcpd tftp xinetd

[[email protected] ~]# systemctl enable httpd dhcpd tftp xinetd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.

Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.

[[email protected] ~]# netstat -tupln

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name

tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      2385/dnsmasq

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1079/sshd

tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1077/cupsd

tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1758/master

tcp6       0      0 :::80                   :::*                    LISTEN      5884/httpd

tcp6       0      0 :::22                   :::*                    LISTEN      1079/sshd

tcp6       0      0 ::1:631                 :::*                    LISTEN      1077/cupsd

tcp6       0      0 ::1:25                  :::*                    LISTEN      1758/master

udp        0      0 0.0.0.0:43741           0.0.0.0:*                           5890/dhcpd

udp        0      0 192.168.122.1:53        0.0.0.0:*                           2385/dnsmasq

udp        0      0 0.0.0.0:67              0.0.0.0:*                           5890/dhcpd

udp        0      0 0.0.0.0:67              0.0.0.0:*                           2385/dnsmasq

udp        0      0 0.0.0.0:69              0.0.0.0:*                           5897/xinetd

udp        0      0 0.0.0.0:123             0.0.0.0:*                           6105/ntpdate

udp        0      0 127.0.0.1:323           0.0.0.0:*                           742/chronyd

udp        0      0 0.0.0.0:5353            0.0.0.0:*                           779/avahi-daemon: r

udp        0      0 0.0.0.0:1282            0.0.0.0:*                           779/avahi-daemon: r

udp6       0      0 :::55402                :::*                                5890/dhcpd

udp6       0      0 :::69                   :::*                                1/systemd

udp6       0      0 :::123                  :::*                                6105/ntpdate

udp6       0      0 ::1:323                 :::*                                742/chronyd

时间: 2024-11-06 03:50:36

Centos7中PXE自动化安装服务器的相关文章

Linux 中PXE远程安装服务器部署

Linux 中PXE远程安装服务器部署将光盘挂在mnt 目录下1 yum –y install vsftpd dhcp tftp-server syslinux2 centos7安装源准备mkdir /var/ftp/centos7cp –rf /mnt/ /var/ftp/centos7systemctl start vsftpd3启用tftp服务vim /etc/xinetd.d/tftp将disable=yes 改为disable=nosystemctl start tftpsystemc

Centos通过PXE自动化安装

Centos的安装管理程序是anaconda,系统安装完成之后会在root的家目录下自动生成一个kickstart配置文件:anaconda_ks.cfg.这个文件主要是由命令段,软件包段和脚本段构成. 命令段:包含安装系统是的各种操作命令 软件包段:包含指定安装或者不安装的软件包和包组 %packages表示此段是软件包段,以%end结束段 PKG_NAME:指定要安装的软件包 @GROUP_NAME: 指定要按装的包组 -PKG_NAME:表示不安装此包,如果此包被依赖,也会被安装 脚本段:

Centos6.5 PXE自动化安装

Centos6.5 PXE自动化安装 首先我们将根据此图说明PXE自动安装的过程: 主机1开机以网卡方式启动,发现自己没有IP地址, 那么网卡rom中的dhcp客户端会发起discovery的广播请求,dhcp服务器发现请求后会给网卡分配一个ip地址告诉客户端TFTP服务器的地址及pxelinux.0所在的路径(相对路径).于是客户端启动网络卡rom中的tftp客户端到TFTP服务器下载pxelinux.0及其配置文件pxelinux.cfg/default 和相关文件[此配置文件会告诉pxel

配置pxe 自动化安装centos6.7

dhcp服务器是pxe自动化安装的必要条件,因此先搞定dhcp服务器,yum -y install dhcp,  rpm -ql dhcp查看安装了哪些包,less /etc/dhcp/dhcpd.conf  打开dhcp的主配置文件,如下图: 没有任何配置,但提示了去哪找主配置文件,cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcp.conf  覆盖主配置文件,vim /etc/dhcp/dhcpd.conf 再次打开,d

在windows下使用gpxelinux进行ESXi 5.x的PXE自动化安装

在windows下使用gpxelinux进行ESXi 5.x的PXE自动化安装.网上许多的教程都是使用Linux作为PXE服务器,对于不怎么熟悉Linux的孩纸这着实是件头疼的事情,like me.所以我通过收集资料,尝试出一个在windows下就可以搭建PXE服务器并用其批量安装ESXi 5.x. 首先自我总结下服务器使用PXE启动的过程.1.ESXi服务器以PXE方式启动后,首先从DHCP服务器拿到IP地址.网关.DNS服务器.TFTP服务器地址.指定的pxelinux.0或者gpxelin

PXE自动化安装centos系统

PXE自动化安装centos系统 ①安装前准备:关闭防火墙和SELINUX,DHCP服务器静态IP iptables -vnL #查看防火墙状态 systemctl stop firewall #关闭防火墙 getenforce #查看SELinux状态 setenforce 0 #禁用SELinux cat > /etc/sysconfig/network-scripts/ifcfg-ens37 <<EOF DEVICE=ens37 #网卡名称 ONBOOT=yes #开启网卡 BOO

初步使用pxe自动化安装系统

1.安装dhcp服务 #yum install dhcpd 修改配置文件 /etc/dhcp/dhcpd.conf # This is a very basic subnet declaration. subnet 172.16.249.0 netmask 255.255.255.0 {  range 172.16.249.111 172.16.249.115;  option routers 172.16.0.1;  next-server 172.16.249.161;  filename

centos7中使用yum安装tomcat以及它的启动、停止、重启

centos7中使用yum安装tomcat 介绍 Apache Tomcat是用于提供Java应用程序的Web服务器和servlet容器. Tomcat是Apache Software Foundation发布的JavaServlet和JavaServer Pages技术的开源实现. 本教程介绍在CentOS 7服务器上使用yum进行Tomcat 7的基本安装和一些配置.请注意,这将安装在官方Ubuntu存储库中的最新版本的Tomcat,它可能是或不是最新版本的Tomcat.如果你想保证你安装的

百晓生带你玩转linux系统服务搭建系列----pxe远程安装服务器的搭建及无人值守安装

实验环境系统环境:centos6.5:程安装服务器WIN7:客户端一.pxe远程安装服务器的搭建 安装并开启需要的服务,tftp,ftp,dhcp.1) yum -y install tftp-server,安装tftp环境软件包(如没有安装yum仓库,请参考http://blog.51cto.com/13842738/2135806)2) 编辑tftp配置文件vim /etc/xinetd.d/tftp 将"disable = yes"改为"disable = no&quo