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

4 篇文章 0 订阅
1 篇文章 0 订阅

我是用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 root@192.168.10.103:/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)

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

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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是CentOS7 PXE安装的步骤: 1. 准备PXE服务器 在一台服务器安装并配置DHCP、TFTP和FTP服务。其中DHCP服务用于分配IP地址,TFTP服务用于传输PXE启动文件,FTP服务用于存放CentOS7安装文件。 2. 准备CentOS7安装文件 将CentOS7安装文件下载到FTP服务器上,并解压缩。 3. 修改isolinux.cfg配置文件 在FTP服务器上找到/var/lib/tftpboot/isolinux/isolinux.cfg文件,将其修改为以下内容: ```shell default linux prompt 0 timeout 300 label linux menu label ^Install CentOS 7 kernel vmlinuz append initrd=initrd.img inst.repo=ftp://192.168.10.51/centos7 ``` 4. 配置DHCP服务 在DHCP服务器上找到/etc/dhcp/dhcpd.conf文件,将其修改为以下内容: ```shell subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.100 192.168.10.200; option domain-name-servers 192.168.10.1; option routers 192.168.10.1; filename "pxelinux.0"; next-server 192.168.10.51; } ``` 5. 配置TFTP服务 在TFTP服务器上找到/etc/xinetd.d/tftp文件,将其修改为以下内容: ```shell 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 } ``` 6. 启动服务 在FTP服务器上启动FTP服务,在DHCP服务器上启动DHCP服务,在TFTP服务器上启动TFTP服务。 7. 安装CentOS7 将需要安装CentOS7的计算机设置为PXE启动,并连接到网络。计算机启动时会自动获取IP地址,并从PXE服务器上下载启动文件。之后,按照CentOS7安装向导进行安装即可。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值