YUM仓库服务与PXE网络装机

实验案例一:软件仓库部署及应用
创建bak目录,把以Censtos开头的文件剪切到bak目录
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mkdir bak
[[email protected] yum.repos.d]# mv CentOS-* ./bak/
挂载光盘
YUM仓库服务与PXE网络装机
创建bdqn目录,剪切vsftpd、frp和dhcp的rpm包到bdqn目录
[[email protected] ~]# mkdir bdqn
[[email protected] ~]# cp /mnt/Packages/vsftpd-3.0.2-22.el7.x86_64.rpm ./bdqn/
[[email protected] ~]# cp /mnt/Packages/ftp-0.17-67.el7.x86_64.rpm ./bdqn/
[[email protected] ~]# cp /mnt/Packages/dhcp-4.2.5-58.el7.centos.x86_64.rpm ./bdqn/
创建yum源
[[email protected] ~]# createrepo -g /mnt/repodata/repomd.xml ./bdqn/
修改本地源位置
[[email protected] ~]# vim /etc/yum.repos.d/local.repo
[local]
name=centos
baseurl=file:///root/bdqn
enabled=1
gpgcheck=0
安装vsftpd
[[email protected] ~]# yum -y install vsftpd
YUM仓库服务与PXE网络装机
修改主配置文件
[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
anon_root=/centos7
创建目录,将光盘中的内容复制到该目录下
[[email protected] ~]# mkdir /centos7
[[email protected] ~]# cp -r /mnt/* /centos7/
重启vsftpd服务
[[email protected] ~]# systemctl start vsftpd
客户端访问
YUM仓库服务与PXE网络装机
配置ftp源
[[email protected] ~]# vim /etc/yum.repos.d/local.repo
[ftp]
name=centos
baseurl=ftp://192.168.100.10/
enabled=1
gpgcheck=0
安装程序
[[email protected] ~]# yum -y install bind bind-chroot bind-utils
YUM仓库服务与PXE网络装机
查看当前系统中安装了那些软件包
[[email protected] ~]# yum list installed
查看yum软件仓库中有那些软件包可用
[[email protected] ~]# yum list available
搜索与dns相关的软件包
[[email protected] ~]# yum search aal dns
安装软件包net-snmp
[[email protected] ~]# yum -y install net-snmp
YUM仓库服务与PXE网络装机
卸载软件包autofs
[[email protected] ~]# yum -y remove autofs
YUM仓库服务与PXE网络装机
执行yum grouplist命令查看yum软件创库中的软件分组
[[email protected] ~]# yum grouplist
YUM仓库服务与PXE网络装机
实验案例二:CentOS7批量自动装机
清空yum源
[[email protected] ~]# rm -rf /etc/yum.repos.d/CentOS-*
挂载系统光盘
[[email protected] ~]# mount /dev/cdrom /mnt/
YUM仓库服务与PXE网络装机
安装tftp
[[email protected] ~]# yum -y install tftp-server
YUM仓库服务与PXE网络装机
启动sftp服务
[[email protected] ~]# systemctl start tftp
[[email protected] ~]# systemctl enable tftp
复制主配置文件
[[email protected] ~]# cp /etc/xinetd.d/tftp /etc/xinetd.d/tftp.bak
配置ftpd
[[email protected] ~]# vim /etc/xinetd.d/ftpd
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
}
复制linux内核到tdtp根目录
[[email protected] ~]# cd /mnt/images/pxeboot/
[[email protected] pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/

安装pex引导程序
[[email protected] ~]# yum -y install syslinux
YUM仓库服务与PXE网络装机
复制引导程序
[[email protected] ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
配置引导菜单
[[email protected] ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[[email protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
default auto
timeout 600
prompt 1
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.100.10/centos7
label text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.100.10/ce
ntos7
label rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.100.10/c
entos7

安装ftp
[[email protected] ~]# yum -y install vsftpd ftp
YUM仓库服务与PXE网络装机
创建ftp的根目录
[[email protected] ~]# mkdir /ftproot
[[email protected] ~]# vim /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
local_enable=YES
anon_root=/ftproot
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

创建存储centos系统目录复制系统
[[email protected] ~]# mkdir -p /ftproot/centos7
[[email protected] ~]# cp -r /mnt/* /ftproot/centos7/
启动ftp服务开机自启
[[email protected] ~]# systemctl start vsftpd
[[email protected] ~]# systemctl enable vsftpd

安装dhcp服务
[[email protected] ~]# yum -y install dhcp
YUM仓库服务与PXE网络装机
配置dhcp
[[email protected] ~]# cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak
[[email protected] ~]# vim /etc/dhcp/dhcpd.conf
:r /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example

[[email protected] ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style none;
option domain-name “benet.com”;
option domain-name-servers 192.168.100.10, 202.106.0.10;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.100 192.168.100.200;
option routers 192.168.100.254;
next-server 192.168.100.10;
filename “pxelinux.0”;
}

host passacaglia {
hardware ethernet 0:0:c0:5d:bd:95;
fixed-address fantasia.fugue.com;
}
启动dhcp服务
[[email protected] ~]# systemctl start dhcpd
[[email protected] ~]# systemctl enable dhcpd
客户端自动获取IP地址
YUM仓库服务与PXE网络装机
客户端访问ftp
YUM仓库服务与PXE网络装机
新建虚拟机
YUM仓库服务与PXE网络装机
不需要挂载光盘
YUM仓库服务与PXE网络装机
开启虚拟机按回车键
YUM仓库服务与PXE网络装机
选择语言
YUM仓库服务与PXE网络装机
软件选择
YUM仓库服务与PXE网络装机
创建分区
YUM仓库服务与PXE网络装机
配置网络和主机名
YUM仓库服务与PXE网络装机
配置密码
YUM仓库服务与PXE网络装机
创建用户
YUM仓库服务与PXE网络装机
安装完成重新启动
YUM仓库服务与PXE网络装机
关闭防火墙
[[email protected] ~]# vim /etc/selinux/config
SELINUX=disabled
停止firewalld防火墙,关闭开机自动启动
[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# systemctl disable firewalld.service
创建yum源
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mkdir bak
[[email protected] yum.repos.d]# mv CentOS-* bak
[[email protected] yum.repos.d]# vim local.repo
[ftp]
name=centos
baseurl=ftp://192.168.100.10/centos7
enabled=1
gpgcheck=0

安装kickstart
重启虚拟机,开始安装kickstart
[[email protected] ~]# yum -y install system-config-kickstart
配置kickstart
YUM仓库服务与PXE网络装机
安装方法
YUM仓库服务与PXE网络装机
引导装载程序选项
YUM仓库服务与PXE网络装机
自定义分区
YUM仓库服务与PXE网络装机
网络配置
YUM仓库服务与PXE网络装机
防火墙配置
YUM仓库服务与PXE网络装机
安装后脚本
YUM仓库服务与PXE网络装机
useradd stu01
echo 123456 | passwd --stdin stu01
rm -rf /etc/yum.repos.d/*
cat <> /etc/yum.repos.d/centos.repo
[ftp]
name=ftp
baseurl=ftp://192.168.100.10/centos7
enabled=1
gpgcheck=0
END
yum -y install wget dhcp vsftpd
将编写脚本复制到ftp加载
[[email protected] ~]# cd /home/test/
[[email protected] test]# cd 文档
[[email protected] 文档]# scp ./ks.cfg [email protected]:/ftproot/centos7
YUM仓库服务与PXE网络装机
验证是否上传成功
[[email protected] ~]# cd /ftproot/centos7/
YUM仓库服务与PXE网络装机
配置引导菜单加载ks.cfg文件
[[email protected] ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
default auto
timeout 600
prompt 0
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.100.10/centos7 ks=ftp://192.168.100.10/centos7/ks.cfg
label text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.100.10/centos7 ks=ftp://192.168.100.10/centos7/ks.cfg
label rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.100.10/centos7 ks=ftp://192.168.100.10/centos7/ks.cfg

验证自动装机
YUM仓库服务与PXE网络装机
自动装机中
YUM仓库服务与PXE网络装机
YUM仓库服务与PXE网络装机
YUM仓库服务与PXE网络装机
自动装机完成

YUM仓库服务与PXE网络装机

相关文章:

  • 2022-12-23
  • 2021-05-19
  • 2021-12-14
  • 2021-04-20
  • 2021-06-20
  • 2021-08-07
  • 2021-10-01
  • 2021-12-10
猜你喜欢
  • 2021-10-12
  • 2021-04-21
  • 2021-09-03
相关资源
相似解决方案