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

news/2024/8/26 17:41:20

我是用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)

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

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


http://www.niftyadmin.cn/n/3095313.html

相关文章

python 第三天 编写文件查询、添加、删除

需求如下:输出:1、获取ha记录2、增加ha记录3、删除ha记录num raw_input(请输入操作序号:)如果用户输入的 1:read raw_input(请输入backend:) 如输入:www.oldboy.org讲配置文件 backend www.oldboy.or…

VMware12安装centos8

centos8就是创建虚拟机选5.x的,硬盘类型选IDE 的 centos6也是选5.x,硬盘类型随便 下面是语言 我是最小安装,第一个是完整安装 root密码 centos8重启网卡是,把配置文件里ONBOOTno里的no改为yes 然后使用nmcli重新回载网络配置 nmc…

Junit测试私有方法

2019独角兽企业重金招聘Python工程师标准>>> 首先先用eclipse建立一个一个Maven工程,然后在新建工程下添加一个Database类如下: public class Database {private static final Logger log LogManager.getLogger();public static boolean cre…

敏捷开发的原则

1. 快速迭代相对那种半年一次的大版本发布来说,小版本的需求、开发和测试更加简单快速。一些公司,一年仅发布仅2~3个版本,发布流程缓慢,它们仍采用瀑布开发模式,更严重的是对敏捷开发模式存在误解。2. 让测试人员和开发…

centos7搭建owncloud

有的公有云不靠谱,那就搭建一个私有云 目前来说, ownCloud 是私有云的最佳解决方案。它不仅是开源的,而且个人用户全免费, 1.安装http和数据库 yum install -y httpd mariadb-server mariadb 2.启动http和数据库 systemctl sta…

优化IPOL网站中基于DCT(离散余弦变换)的图像去噪算法(附源代码)。

在您阅读本文前,先需要告诉你的是:即使是本文优化过的算法,DCT去噪的计算量依旧很大,请不要向这个算法提出实时运行的苛刻要求。 言归正传,在IPOL网站中有一篇基于DCT的图像去噪文章,具体的链接地址是&am…

SpringJUnit4加载类目录下(src)和WEF-INF目录下的配置文件二--获取注入的bean的二种方式...

前言: spring容器以xml的形式注入bean,然后可以在类中获取,获取的形式主要有二种:第一种最简单--采用Resource 或Autowired关键字在加载spring文件时将bean注入到相应的类中;第二种方式是先用FileSystemXmlApplication…

Log4j自定义生成文件的名称

我们在使用Log4j的RollingFileAppender循环生成文件的时候,生成的文件的名称有点儿恶心,例如,文件名称为app.log,那么生成的文件名依次为app.log.1,app.log.2,....那么如何去改变生成文件的名称的规则呢?下面是一个简单…