YUM warehouse service and PXE network installation of Centos7

Bowen catalogue
I. YUM software warehouse
II. Type of YUM source
III. precautions for configuration of PXE automatic bulk chemical installation machine
IV. deploy PXE remote installation service

I. YUM software warehouse

With the help of YUM software warehouse, the tasks of installing, uninstalling and upgrading rpm software packages can be completed, and the dependency between rpm packages can be automatically found and solved, without the need for administrators to install each rpm package one by one and manually, so that administrators can maintain a large number of Linux servers more easily.
In order to successfully use YUM mechanism to update system and software, a software repository containing various rpm installation package files and their dependent software is needed. The server providing software repository is also called "source" server. As long as the address and other information of the software warehouse are correctly specified in the client, the software can be installed or updated through the corresponding "source" server.
YUM software warehouse usually uses HTTP or FTP protocol to publish, which can provide software source services for all clients in the network. In order to facilitate the client to query the software package. To obtain dependency information, we need to provide warehouse data (repodata) in the software warehouse, which collects the header information of all rpm packages in the directory.

1. Client configuration software warehouse location

You need to specify at least one available software warehouse on the client before you can download and install the software package using the yum tool described in the next section. The software warehouse information used by the yum tool is stored in the file with the extension ". repo" under the directory / etc/yum.repos.d.

[root@centos01 ]# vim /etc/yum.repos.d/local.repo 
[local]                              <!--Warehouse statement-->
name=centos                   <!--yum Source name-->
baseurl=file:///Root / bent <! -- warehouse location -- >
enabled=1                   <!--open yum function-->
gpgcheck=0                    <!--Do not verify package signature-->

In the above operations, the file centos7.repo needs to be created manually. / etc/yum.repos.d. if there are other unused "*. Repo" files, it is recommended to delete them. "enabled=1" is the default item, which can be omitted; "gpgcheck" and "gpgkey" are two lines of configuration to check the integrity of the software package. If there is no such requirement, it can be omitted.

II. Type of YUM source

  • Local source: Linux operating system CD is a yum warehouse;
  • FTP source: upload data to FTP users for access;
  • HTTP source: need to connect to the Internet, update data easily, need high-speed bandwidth;

1. Configure local source

[root@centos01 ]# vim /etc/yum.repos.d/local.repo 

2. Configure ftp source

[root@centos01 ~]# vim /etc/yum.repos.d/local.repo 

3. Configure HTTP source

[root@centos01 ~]#cd /etc/yum.repos.d/
[root@centos01 yum.repos.d]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyum.com/repo/Centos-7.repo

4. Use of YUM

[root@centos01 ~]#yum clean all <! -- clear yum cache -- >
[root@centos01 ~]#Yum list <! -- query software list -- >
[root@centos01 ~]#Yum info DHCP <! -- Query package information -- >
[root@centos01 ~]#Yum - y install dhcp <! -- install dhcp software -- >
[root@centos01 ~]#Yum - y remove dhcp <! -- uninstall dhcp software -- >
[root@centos01 ~]#Yum search httpd <! -- query software -- >

5. Source of RPM package

1) centos official

Update system encapsulates rpm software directly in IOS

2) the third party organization publishes rpm package

Update new features; make changes on an official basis

3) user defined rpm package set

Open source hobby personal modification data package update data package

4) user creates yum source

[root@centos01 ~]#createrepo -g /mnt/repodata/repomd.xml ./benet/

III. precautions for configuration of PXE automatic bulk chemical installation machine

PXE is a network boot technology developed by intel company. It works in Client/Server mode. It allows clients to download boot images from remote servers through the network and load installation files or the entire operating system.

  • The network card of the client supports PXE protocol (integrated BOOTROM chip), and the main board supports network boot;
  • There is a DHCP server in the network to automatically assign the address and specify the location of the boot file for the client;
  • The server provides download of boot image file through TFTP (simple file transfer protocol);
    One of the conditions is the hardware requirements. At present, most servers and most PC s can provide this support. You only need to allow the startup from the nearwork or LAN in BIOS settings.

IV. deploy PXE remote installation service

1. Configure YUM warehouse and install ftp service:

[root@centos01 ~]# mount /dev/cdrom /media
[root@centos01 ~]# cd /etc/yum.repos.d/
[root@centos01 yum.repos.d]# rm -rf *
[root@centos01 yum.repos.d]# vim a.repo


[root@centos01 yum.repos.d]# yum -y install vsftpd*

2. Prepare centos7 installation source and start ftp service:

[root@centos01 yum.repos.d]# mkdir /var/ftp/centos7
[root@centos01 yum.repos.d]# cp -rf /media/* /var/ftp/centos7/
[root@centos01 yum.repos.d]# Systemctl start vsftpd <! -- start ftp service -- >
[root@centos01 yum.repos.d]# Systemctl enable vsftpd <! -- set to power on and self start -- >

3. Install and start TFTP service:

[root@centos01 yum.repos.d]# yum -y install tftp-server
[root@centos01 yum.repos.d]# VIM / etc / xinetd.d/tftp <! -- edit TFTP configuration file -- >

service tftp
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no               <!--Default here yes Change to no that will do-->
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4

[root@centos01 yum.repos.d]# Systemctl start TFTP <! -- start TFTP Service -- >
[root@centos01 yum.repos.d]# Systemctl enable TFTP <! -- set auto start after power on -- >

4. Prepare the Linux kernel and initialize the image file (on the system disk):

[root@centos01 ~]# cd /media/images/pxeboot/
[root@centos01 pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot/

5. Prepare PXE boot program:

[root@centos01 pxeboot]# Yum - y install syslinux <! -- install bootstrap -- >
[root@centos01 pxeboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

6. Configure the Startup menu (for typical and unattended installation, choose one from the other according to the actual demand):

[root@centos01 pxeboot]# mkdir /var/lib/tftpboot/pxelinux.cfg

1) typical Startup menu, unable to realize unattended installation:

[root@centos01 pxeboot]# vim /var/lib/tftpboot/pxelinux.cfg/default            

default auto
prompt 1
label auto
        kernel vmlinuz
        append initrd=initrd.img method=
label linux text
        kernel vmlinuz
        append text initrd=initrd.img method=
label linux rescue
        kernel vmlinuz
        append rescue initrd=initrd.img method=

2) Startup menu of unattended installation:

[root@centos01 pxeboot]# vim /var/lib/tftpboot/pxelinux.cfg/default 

default auto
prompt 0
label auto
        kernel vmlinuz
        append initrd=initrd.img method= 

In the above two startup menus, I configure unattended installation here. If I choose a typical Startup menu, then there are many unnecessary operations. Just install the DHCP server to deploy the system.

7. Install and enable the DHCP server:

[root@centos01 pxeboot]# yum -y install dhcp
[root@centos01 pxeboot]# vim /etc/dhcp/dhcpd.conf

subnet netmask {
  option domain-name-servers;
  option domain-name "internal.example.org";
  option routers;
  option broadcast-address;
  default-lease-time 21600;
  max-lease-time 43200;
  next-server;                 <!--Appoint TFTP Address of the server-->
  filename "pxelinux.0";                     <!--Appoint PXE The file name of the bootstrap-->

[root@centos01 pxeboot]# Systemctl start dhcp <! -- start dhcp Service -- >
[root@centos01 pxeboot]# Systemctl enable dhcpd <! -- set auto start when power on -- >

8. Prepare the installation response file:

If the system config kickstart tool is installed in centos 7 system, you can configure the installation answer file through the graphical Wizard tool:

[root @ centos01 pxeboot] ා Yum - y install system config kickstart & lt;! -- install required tools -- & gt;

1) open the graphical program:

2) configure the installation response parameters:

3) since the ftp service allows anonymous access by default, you do not need to specify the user name and password:

4) boot loader:

5) partition information (select the appropriate hard disk partition scheme according to the actual demand):

6) network configuration and firewall:

7) write the post installation script and save it in the document directory:

Saved answer file:

[root@centos01 ~]# VIM ks.cfg <! -- the final response file is as follows -- >
(The steps of graphical configuration can be omitted by directly copying this file, and can be used after modification in combination with actual needs):

#platform=x86, AMD64, or Intel EM64T
# Install OS instead of upgrade
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$bauETRq3$WOpze2jeKD9q3qgKK50xj0
# Use network installation
url --url="ftp://ftp:"
# System language
lang zh_CN
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
firstboot --disable
# SELinux configuration
selinux --disabled

# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=ens32
# Reboot after installation
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs" --size=500
part /home --fstype="xfs" --size=4096
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1

%post --interpreter=/bin/bash
cd /etc/yum.repos.d
rm -rf *
echo -e "[base]" > aa.repo
echo -e "baseurl=" >> aa.repo
echo -e "gpgcheck=0" >> aa.repo

However, the above configuration file is almost the same. You need to write three lines at the end of the configuration file to select the minimum installation:


After writing, save and exit.

9. Copy the auto answer file to the specified directory (the path of "ks =" specified in the previous boot menu):

[root@centos01 ~]# cp /root/ks.cfg /var/ftp/

10. OK, turn on the client and verify the effect (wait patiently to finish):

Installation successful:

——————Thank you for reading——————

Tags: Linux yum ftp network RPM

Posted on Thu, 14 Nov 2019 07:10:52 -0500 by genetheblue