centos安装PXE(无人值守安装)服务器

我是用http协议传送安装源给客户机(我服务器的ip是192.168.10.103)

下面的centos6不能安装,在这里就是做比较,当然,用centos7不同版本也可以比较

这里上传的镜像都是完整版的,如果不想安装带桌面的,也可以上传centos7minimal版的,比较小点,步骤是一样的,kickstart文件只需要写最小安装的就行

我这里自动安装的centos7客户端的登录名是root   密码是yegoo@123

安装必要服务

DHCP服务器

TFTP服务器

Kickstart HTTP

1.安装服务

yum -y install httpd xinetd syslinux tftp-server system-config-kickstart dhcp

2.创建存放iso的目录

mkdir -p /tmp/iso

3.将iso文件上传到/tmp/iso(这里我用Windows自带的cmd上传,以前的文章有介绍cmd传文件的)

我的iso文件在E盘的镜像\centos\

进入里面

cd /d e:\镜像\centos\

上传

pscp CentOS-7-x86_64-DVD-1810.iso [email protected]:/tmp/iso

4.在/var/www/html创建挂载点和ks目录

mkdir -p /var/www/html/centos{6,7}

mkdir -p /var/www/html/ks

5.挂载光盘

mount -o loop /tmp/iso/CentOS-6.10-x86_64-bin-DVD1.iso /var/www/html/centos6/

mount -o loop /tmp/iso/CentOS-7-x86_64-DVD-1810.iso /var/www/html/centos7/

这是临时挂载   也可以开机自动挂载(写fstab文件,我写后会出错,这里不写了   )

6.创建 /var/lib/tftpboot/pxelinux.cfg

mkdir /var/lib/tftpboot/pxelinux.cfg

创建/var/lib/tftpboot/centos{6,7}

mkdir -p /var/lib/tftpboot/centos{6,7}

7.拷贝文件

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

下面两个是通用的,6的和7的都一样

cp /var/www/html/centos7/isolinux/vesamenu.c32 /var/lib/tftpboot/

cp /var/www/html/centos7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

下面的就不一样了

cp /var/www/html/centos6/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos6/

cp /var/www/html/centos7/isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos7/

8.修改default

vim /var/lib/tftpboot/pxelinux.cfg/default

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.

label 1
  menu label ^Install CentOS 6-GUI
  menu default
  kernel centos6/vmlinuz
  append initrd=centos6/initrd.img text ks=http://192.168.10.103/ks/6.cfg

label 2
  menu label ^Install CentOS 6-minimal
  menu default
  kernel centos6/vmlinuz
  append initrd=centos6/initrd.img text ks=http://192.168.10.103/ks/6-minimal.cfg

label 3
  menu label ^Install CentOS 7-GUI
  menu default
  kernel centos7/vmlinuz
  append initrd=centos7/initrd.img text ks=http://192.168.10.103/ks/7.cfg

label 4
  menu label ^Install CentOS 7-minimal
  menu default
  kernel centos7/vmlinuz
  append initrd=centos7/initrd.img text ks=http://192.168.10.103/ks/7-minimal.cfg

9.配置kickstart文件

cd /var/www/html/ks/

下面是centos6的完全安装

vim 6.cfg

  

   # version=DEVEL
   # X Window System configuration information
   xconfig  --startxonboot
   # License agreement
   eula --agreed
   # System authorization information
   auth --enableshadow --passalgo=sha512
   # Use CDROM installation media
   cdrom
   # Use network installation
   url --url="http://192.168.10.103/centos6"
   # Use graphical install
   graphical
   # Run the Setup Agent on first boot
   firstboot --enable
   # System services
   services --enabled="chronyd"
   # Keyboard layouts
   keyboard --vckeymap=us --xlayouts='us'
   # System language
   lang en_US.UTF-8

   ignoredisk --only-use=sda

   # Root password
   rootpw --iscrypted $6$QmzXBTCUJU1ANz4F$KKI3NS400dVdUL1PkQDumqUPLbq8wfyULZ0m0Mx7/C3l1.d8a8Moq6sTNP2Qfjgc.DydeHhQHlzscvaZerZk1.
   # System timezone
   timezone Asia/Shanghai --isUtc
   # System bootloader configuration
   bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
   autopart --type=lvm
   # Partition clearing information
   clearpart --none --initlabel

   %packages
   @^graphical-server-environment
   @base
   @desktop-debugging
   @dial-up
   @fonts
   @gnome-desktop
   @guest-agents
   @guest-desktop-agents
   @hardware-monitoring
   @input-methods
   @internet-browser
   @multimedia
   @print-client
   @x11
   chrony
   kexec-tools
   %end

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

   %anaconda
   pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
   pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   %end

下面是centos6的最小安装

vim 6-minimal.cfg

   # version=DEVEL
   # X Window System configuration information
   xconfig  --startxonboot
   # License agreement
   eula --agreed
   # System authorization information
   auth --enableshadow --passalgo=sha512
   # Use CDROM installation media
   cdrom
   # Use network installation
   url --url="http://192.168.10.103/centos6"
   # Use graphical install
   graphical
   # Run the Setup Agent on first boot
   firstboot --enable
   # System services
   services --enabled="chronyd"
   # Keyboard layouts
   keyboard --vckeymap=us --xlayouts='us'
   # System language
   lang en_US.UTF-8

ignoredisk --only-use=sda

# Root password
   rootpw --iscrypted $6$QmzXBTCUJU1ANz4F$KKI3NS400dVdUL1PkQDumqUPLbq8wfyULZ0m0Mx7/C3l1.d8a8Moq6sTNP2Qfjgc.DydeHhQHlzscvaZerZk1.
   # System timezone
   timezone Asia/Shanghai --isUtc
   # System bootloader configuration
   bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
   autopart --type=lvm
   # Partition clearing information
   clearpart --none --initlabel

%packages
   @^minimal
   %end

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

%anaconda
   pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
   pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   %end

下面是centos7的完全安装

vim 7.cfg

   # version=DEVEL
   # X Window System configuration information
   xconfig  --startxonboot
   # License agreement
   eula --agreed
   # System authorization information
   auth --enableshadow --passalgo=sha512
   # Use CDROM installation media
   cdrom
   # Use network installation
   url --url="http://192.168.10.103/centos7"
   # Use graphical install
   graphical
   # Run the Setup Agent on first boot
   firstboot --enable
   # System services
   services --enabled="chronyd"
   # Keyboard layouts
   keyboard --vckeymap=us --xlayouts='us'
   # System language
   lang en_US.UTF-8

   ignoredisk --only-use=sda

   # Root password
   rootpw --iscrypted $6$QmzXBTCUJU1ANz4F$KKI3NS400dVdUL1PkQDumqUPLbq8wfyULZ0m0Mx7/C3l1.d8a8Moq6sTNP2Qfjgc.DydeHhQHlzscvaZerZk1.
   # System timezone
   timezone Asia/Shanghai --isUtc
   # System bootloader configuration
   bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
   autopart --type=lvm
   # Partition clearing information
   clearpart --none --initlabel

   %packages
   @^graphical-server-environment
   @base
   @desktop-debugging
   @dial-up
   @fonts
   @gnome-desktop
   @guest-agents
   @guest-desktop-agents
   @hardware-monitoring
   @input-methods
   @internet-browser
   @multimedia
   @print-client
   @x11
   chrony
   kexec-tools
   %end

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

   %anaconda
   pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
   pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   %end

下面是centos7的最小安装

vim 7-minimal.cfg

   # version=DEVEL
   # X Window System configuration information
   xconfig  --startxonboot
   # License agreement
   eula --agreed
   # System authorization information
   auth --enableshadow --passalgo=sha512
   # Use CDROM installation media
   cdrom
   # Use network installation
   url --url="http://192.168.10.103/centos7"
   # Use graphical install
   graphical
   # Run the Setup Agent on first boot
   firstboot --enable
   # System services
   services --enabled="chronyd"
   # Keyboard layouts
   keyboard --vckeymap=us --xlayouts='us'
   # System language
   lang en_US.UTF-8

ignoredisk --only-use=sda

# Root password
   rootpw --iscrypted $6$QmzXBTCUJU1ANz4F$KKI3NS400dVdUL1PkQDumqUPLbq8wfyULZ0m0Mx7/C3l1.d8a8Moq6sTNP2Qfjgc.DydeHhQHlzscvaZerZk1.
   # System timezone
   timezone Asia/Shanghai --isUtc
   # System bootloader configuration
   bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
   autopart --type=lvm
   # Partition clearing information
   clearpart --none --initlabel

%packages
   @^minimal
   %end

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

%anaconda
   pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
   pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
   %end

10.配置dhcp

cd /etc/dhcp/

如果里面有dhcpd.conf ,就删除或改名字

然后复制示例的文件复制里面

cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

内容如下(47行---57行)

subnet 192.168.10.0 netmask 255.255.255.0 {
  range 192.168.10.2 192.168.10.254;
  option domain-name-servers 192.168.10.103;
  option domain-name "PXEserver";
  option routers 192.168.10.1;
  option broadcast-address 192.168.10.255;
  next-server 192.168.10.103;
  default-lease-time 600;
  max-lease-time 7200;
  filename "pxelinux.0";
}

11.启动服务

systemctl restart httpd
systemctl enable httpd
systemctl restart xinetd
systemctl enable xinetd
systemctl restart dhcpd
systemctl enable dhcpd

12.关闭防火墙与selinux

systemctl stop firewalld.service

systemctl disable firewalld.service

vim /etc/sysconfig/selinux

把SELINUX=enforcing改为SELINUX=disabled

source /etc/sysconfig/selinux

13.检查PXE Server的状态

service dhcpd status   

service tftp status

service httpd status

以上三者结果都应该为active(running)

如果关机后在开机  或重启服务器了  就看看挂载和状态

当你客户机选择网络安装是,会出下图

centos安装PXE(无人值守安装)服务器_第1张图片

你可能感兴趣的:(centos,服务器,PXE,centos安装PXE服务器,centos7安装pxe服务器)