当前位置:   article > 正文

银河麒麟服务器系统PXE部署_麒麟 pxe-16

麒麟 pxe-16

银河麒麟服务器系统PXE部署

前言:本文介绍在vmware中麒麟服务器操作系统上部署PXE服务端,集成麒麟系统安装源,TFTP服务,DHCP服务,HTTP服务,能够向客户机裸机发送PXE引导程序、Linux内核、启动菜单等数据,以及提供安装文件。

系统引导模式分为uefi引导以及legacy引导,文档内容均有列出。

(1)2.7步骤为必填项
(2)ks文件(除了2.7必填项以外),dhcp配置文件,grub引导文件等配置均作为示例进行参考,请实际情况进行更改。
(3)测试的客户端内存必须≥4GB,否则加载会报错no space left on device
(4)vmware测试过程中虚拟机的网卡建议使用仅主机模式,并且需要关闭dhcp服务,不然会影响pxe服务端的IP地址下发和客户端的IP地址获取。

添加虚拟网络的具体步骤:点击vmware界面左上角编辑–>虚拟网络编辑器–>添加网络–>添加虚拟网络–>关闭该虚拟网络的dhcp服务(取消勾选使用本地DHCP服务将IP地址分配给虚拟机),保存。

将服务端和客户端的网络适配器设置为自定义,选择新添加的虚拟网络网段。例如VMnet2

(5)uefi引导,legacy引导设置步骤:右击顶部状态栏的虚拟机名称–>设置–>选项–>高级–>固件类型

一 系统环境

1.1 服务端/客户端系统版本
[root@localhost ~]# nkvers
##############Ky1in Linux Version#################
Release:
Kylin Linux Advanced Server release V10 (Sword)
Kernel:
4.19.90-24.4.v2101.ky10.x86_64
Build:
Kylin Linux Advanced Server
release V10(SP2) /(sword)-x86_64-Build09/20210524|
#################################################
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
1.2 服务端环境信息
IP地址: 192.168.134.100
子网掩码:255.255.255.0
网关:   192.168.134.2
分配的地址段:      192.168.146.{200-210}
uefi引导需要的文件:  grubx64.efi
legacy引导需要的文件:pxelinux.0
ISO镜像位置:/root/Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

二 组件安装部署

2.1 安装软件包
2.1.1 uefi配置
yum install dhcp tftp tftp-server httpd xinetd -y 
  • 1
2.1.2 legacy配置
yum install dhcp tftp tftp-server httpd xinetd syslinux-nonlinux -y
  • 1
2.2 dhcp服务配置
2.2.1 uefi配置
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename "grubx64.efi";
next-server 192.168.134.100;

subnet 192.168.134.0 netmask 255.255.255.0 {
    option routers 192.168.134.2;
    option subnet-mask 255.255.255.0;
    range dynamic-bootp 192.168.134.200 192.168.134.210;
    default-lease-time 21600;
    max-lease-time 43200;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
2.2.2 legacy配置
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename "pxelinux.0";
next-server 192.168.134.100;

subnet 192.168.134.0 netmask 255.255.255.0 {
    option routers 192.168.134.2;
    option subnet-mask 255.255.255.0;
    range dynamic-bootp 192.168.134.200 192.168.134.210;
    default-lease-time 21600;
    max-lease-time 43200;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
2.3 xinetd服务配置
/etc/xinetd.d/tftp文件中:disable yes改成no
  • 1
2.4 http服务配置
2.4.1 uefi配置
(1)创建kylin和ks目录,用来存放安装源和ks文件
mkdir /var/www/html/kylin
mkdir /var/www/html/ks
mount Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso /mnt/
rsync -a /mnt/ /var/www/html/kylin
chmod -R 755 /var/www/html/

(2)将客户端启动引导所需文件拷贝至/var/lib/tftpboot/目录下
cp -rf /mnt/images/pxeboot/* /var/lib/tftpboot/
cp /mnt/EFI/BOOT/grubx64.efi /mnt/EFI/BOOT/BOOTX64.EFI /var/lib/tftpboot/
chmod 755 /var/lib/tftpboot/*
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
2.4.2 legacy配置
(1)创建kylin和ks目录,用来存放安装源和ks文件
mkdir /var/www/html/kylin
mkdir /var/www/html/ks
mount Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso /mnt/
rsync -a /mnt/ /var/www/html/kylin
chmod -R 755 /var/www/html/

(2)将客户端启动引导所需文件拷贝至/var/lib/tftpboot/目录下
cp -f /mnt/isolinux/* /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
cp -f /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
chmod -R 755 /var/lib/tftpboot/*
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
2.5 grub配置
2.5.1 uefi配置
[root@localhost ~]# vim /var/lib/tftpboot/grub.cfg 
set default="0"

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=10

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install Kylin Linux Advanced Server V10 HTTP' --class red --class gnu-linux --class gnu --class os {
    set root=(tftp,192.168.134.100)
    linux /vmlinuz ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 ip=dhcp inst.repo=http://192.168.134.100/kylin inst.ks=http://192.168.134.100/ks/kylin-ks.cfg
    initrd /initrd.img
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
2.5.2 legacy安装
[root@localhost ~]#  vim /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
timeout 100
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 Kylin Linux Advanced Server V10
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 http
  menu label ^Install Kylin Linux Advanced Server V10 HTTP
  menu default
  kernel vmlinuz
  append initrd=initrd.img ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 ip=dhcp inst.repo=http://192.168.134.100/kylin inst.ks=http://192.168.134.100/ks/kylin-ks.cfg rd.debug rd.udev.debug systemd.log_level=debug
menu end
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
2.6 ks文件配置
[root@localhost ~]# cat /var/www/html/ks/kylin-ks.cfg
# Installation disks
ignoredisk --only-use=sda
autopart --type=lvm

# nfs install

# Partition clearing information
clearpart --drives=sda --all

# Use graphical install
graphical

# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'

# System language
lang zh_CN.UTF-8

# Network information
network  --bootproto=dhcp --device= --ipv6=auto --activate
network  --hostname=localhost.localdomain

# Run the Setup Agent on first boot
firstboot --enable

# X Window System configuration information
xconfig  --startxonboot

# System services
services --enabled="chronyd"

# System timezone
timezone Asia/Shanghai --utc --nontp

# Environment groups
# Minimal Install/最小安装
# Server/基础设施服务器
# File and Print Server/文件及打印服务器
# Basic Web Server/基本网页服务器
# Virtualization Host/虚拟化主机
# Server with UKUI GUI/带 UKUI GUI 的服务器
%packages
@^kylin-desktop-environment
wget
%end

# Root password "Kylin123123"
rootpw --iscrypted $6$2RNyJf8iEMumDVFd$jGlgTmmUkLG2NquH9zUfa/S/UJKsBuF5PXdbKdosRYxQOzh4uWaq9tuxL/EwSCmgsjnRNWXu66ILmtSbIBDn.0

# Password policies
%anaconda
pwpolicy root --minlen=8 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=8 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=8 --minquality=1 --notstrict --nochanges --notempty
%end

%post
# Get kyinfo
wget http://192.168.134.100/kylin/{.kyinfo,LICENSE} --random-wait --directory-prefix /etc/
systemctl unmask systemd-timedated.service
systemctl disable systemd-networkd-wait-online.service
systemctl disable multipathd.service
systemctl enable cockpit.socket
rm -f /1ib/udev/rules.d/60-block-scheduler.rules
rm -f /etc/cron.daily/rpm
sed -i "s/instal1_items/instal1_optional_items/g"/etc/dracut.conf
sed -i "s?/usr/share/fonts/kingsoft/FZKTK.TTF?/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc?g"
/etc/dracut.conf
if  [! -f "/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc"]; then
	mkdir -p /usr/share/fonts/google-noto-cjk
	wget http://192.168.134.100/ky1in/images/NotoSansCJK-Bold.ttc --random-wait --directory-prefix
/usr/share/fonts/google-noto-cjk/
fi
dracut -f

# Enable kdump
#sed -i "s/ crashkernel=auto / /" /boot/efi/EFI/kylin/grub.cfg
%end
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
2.7 ks文件必填项,post字段中
%post
# Get kyinfo
wget http://192.168.134.100/kylin/{.kyinfo,LICENSE} --random-wait --directory-prefix /etc/
systemctl unmask systemd-timedated.service
systemctl disable systemd-networkd-wait-online.service
systemctl disable multipathd.service
systemctl enable cockpit.socket
rm -f /1ib/udev/rules.d/60-block-scheduler.rules
rm -f /etc/cron.daily/rpm
sed -i "s/instal1_items/instal1_optional_items/g"/etc/dracut.conf
sed -i "s?/usr/share/fonts/kingsoft/FZKTK.TTF?/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc?g"
/etc/dracut.conf
if  [! -f "/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc"]; then
	mkdir -p /usr/share/fonts/google-noto-cjk
	wget http://192.168.134.100/ky1in/images/NotoSansCJK-Bold.ttc --random-wait --directory-prefix
/usr/share/fonts/google-noto-cjk/
fi
dracut -f
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
2.8 重启服务
systemctl enable httpd && systemctl restart httpd
systemctl enable dhcpd && systemctl restart dhcpd
systemctl enable xinetd && systemctl restart xinetd
systemctl enable tftp && systemctl restart tftp
systemctl disable firewalld && systemctl stop firewalld
  • 1
  • 2
  • 3
  • 4
  • 5
2.9 客户端测试
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/189220
推荐阅读
相关标签
  

闽ICP备14008679号