Centos7yum warehouse service and pxe network installation

Overview and deployment of YUM warehouse

YUM warehouse: complete tasks such as installation, upgrade, and uninstallation of rpm packages through YUM warehouse; it can automatically find and resolve dependencies between rpm packages.
Applicable environment: a YUM can be built in a local network with a large number of Linux hosts Source server to ease the
classification of software installation and upgrades :
1. Local YUM (you are your own YUM warehouse)

[root@YUM-server ~]# mount /dev/cdrom /media/cdrom
mount: /dev/sr0 写保护,将以只读方式挂载
[root@YUM-server ~]# cd /etc/yum.repos.d/
[root@YUM-server yum.repos.d]# vim CentOS7.repo
[aaa]		#名称,随便写
name=111	#描述信息,随便写
baseurl=file:///media/cdrom   #光盘所挂载位置
enabled=1		      #开启自启
gpgcheck=0		      #不检查软件包信息

2. Network YUM (a server is the source, yum warehouse is provided through ftp or http protocol)
Case environment: 2 Linux servers;
192.168.1.10 YUM warehouse (source)
192.168.1.110 YUM client (location of yum warehouse) 192.168.1.10)

Implementation steps:
192.168.1.10 operation steps:
1. Install vsftpd service to provide ftp access

[root@YUM-Server ~]# mount /dev/cdrom /media/cdrom  (挂载光盘)
[root@YUM-Server ~]# yum -y install vsftpd     (安装vsftpd软件包)
[root@YUM-Server ~]# systemctl start vsftpd    (启用ftp服务)
[root@YUM-Server ~]# systemctl enable vsftpd   (将ftp服务设置为开机自启)

2. Prepare the official software warehouse of YUM warehouse

[root@YUM-server ~]# mkdir /var/ftp/centos7   (在ftp下创建一个目录)
[root@YUM-server ~]# cp -rf /media/cdrom/* /var/ftp/centos7/  
(将光盘中所有内容复制到该软考仓库的目录中;时间有点长)

3. Prepare other software packages that are not included in the CentOS7 CD

[root@YUM-server ~]# mkdir /var/ftp/other    (创建非光盘自带软件包存放目录)
[root@YUM-server ~]# createrepo -g /media/cdrom/repodata/repomd.xml /var/ftp/other/
(将源发布的其他rpm包存放到/var/ftp/other/目录中)

Insert picture description here
The above is the preparation of YUM warehouse
4. Specify YUM source on the client
192.168.1.110上:

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
root@localhost yum.repos.d]# rm -rf *  (删除本地yum源)
[root@localhost yum.repos.d]# vim aaa.repo  (重新创建一个)
[local]          (随便起)
name=centos7     (随便起,但必须要有)
baseurl=ftp://192.168.1.10/centos7  (指向yum服务器刚才创建的目录)
enabled=1       (开机自启)
gpgcheck=0	(不检查软件包信息)

[other]
name=other
baseurl=ftp://192.168.1.10/other
enabled=1
gpgcheck=0

Insert picture description here
5. The client passes the yum installation verification

[root@localhost yum.repos.d]# yum -y install httpd
(随意安装个服务,只要能安装成功,就说明成功了)

Insert picture description here

Use YUM related tools to manage software packages

在客户端上进行操作验证
(1) Query software package

[root@localhost ~]# yum list  (查询系统中软件安装情况,和软件仓库中可用的软件包列表)
[root@localhost ~]# yum list installed     (只列出系统中已安装的软件包)
[root@localhost ~]# yum list available     (只列出软件仓库中可以(尚未安装的)的软件包)
yum info 查询软件包的描述信息                (搜索的是yum仓库)
[root@localhost ~]# yum info httpd      
yum search 查询指定的软件包
[root@localhost ~]# yum search all vsftpd   (本地可以没有,搜索的是yum仓库)
[root@localhost ~]# yum grouplist  (获得软件的分组信息)
[root@localhost ~]# yum groupinfo "GNOME 桌面" (可查询出这个分组所包括的软件包信息)

(Two), install, upgrade, uninstall software package

[root@localhost ~]# yum -y install vsftpd  (安装)
[root@YUM-server ~]# yum -y update vsftpd   (更新,前提是软件仓库要有新的包)
[root@localhost ~]# yum -y remove  vsftod  (卸载)
[root@localhost ~]# rpm -qa vsftpd  (通过rpm方式查询软件包是否安装,未显示说明未安装,或被删除)
[root@localhost ~]# yum -y groupinstall "GNOME 桌面"  (下载该软件包组)
[root@localhost ~]# yum -y groupremove "GNOME 桌面"   (删除该软件包组)

Deploy PXE remote installation service

PXE: Working in the C/S mode, allowing the client to download the boot image from the server through the network, and load the installation file or the entire operating system
experimental materials:
a Centos7 graphical interface: 192.168.1.10
a centos7 bare metal
构建PXE网络体系的前提:
1. The network needs There is a DHCP server to automatically assign addresses to the client, specify the location of the boot file
2. The server provides the download of the boot image file through TFTP
3. The client network card needs to support the PXE protocol, and the motherboard supports network startup

部署PXE远程安装服务器:
1. Prepare the installation source of CentOS7 (via FTP protocol)
可以直接使用上面做yum实验的机器,但得是图形化

[root@PXE-Server ~]# mount /dev/cdrom /media/cdrom  (挂载光盘)
[root@PXE-Server ~]# yum -y install vsftpd     (安装vsftpd软件包)
[root@PXE-Server ~]# systemctl start vsftpd    (启用ftp服务)
[root@PXE-server ~]# mkdir /var/ftp/centos7   (在ftp下创建一个目录)
[root@PXE-server ~]# cp -rf   /media/cdrom/*/var/ftp/centos7/  
(将光盘中所有内容复制到该软考仓库的目录中;时间有点长)

2. Install and enable the TFTP server to
configure local yum, the configuration method is as follows

[root@PXE-server ~]# yum -y install tftp-server   (安装)
[root@PXE-server ~]# vim /etc/xinetd.d/tftp       (修改tftp的配置文件)
 "disable=yes" 改为 "disable=no"

Insert picture description here

[root@PXE-server ~]# systemctl start tftp     (启用tftp服务器)
[root@PXE-server ~]# systemctl enable tftp    (将tftp设置为开机自启)

3. Prepare the Linux kernel and initialize the image file (the kernel and the initial image file are on the CD, copy them to the root directory of the tftp server)

[root@PXE-server ~]# cd /media/cdrom/images/pxeboot/
[root@PXE-server pxeboot]# ls
initrd.img  TRANS.TBL  vmlinuz   (initrd.img:初始化镜像文件;vmlinuz:内核文件)
[root@PXE-server pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/
(把2个文件复制到tftp服务器根目录)

Insert picture description here
4. Prepare PXE boot program and boot menu file (pxe boot program is called pxelinux.0, which is provided by syslinux software package and must be installed first )

[root@PXE-server ~]# yum -y install syslinux   (安装)
注意:该引导也要放在tftp 服务器的根目录下: 
[root@PXE-server ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

Write the boot menu file:

[root@PXE-server ~]# mkdir /var/lib/tftpboot/pxelinux.cfg  (创建启动菜单文件所在的目录)
[root@PXE-server ~]# vim  /var/lib/tftpboot/pxelinux.cfg/default   (编辑文件)
default auto   //指定默认入口名称是auto
prompt 1      //1表示等待用户控制
label auto   //图形化安装(默认)
  kernel vmlinuz
  append initrd=initrd.img method=ftp://192.168.1.10/centos7

label linux text  //文本安装
  kernel vmlinuz
  append text initrd=initrd.img method=ftp://192.168.1.10/centos7

label linux rescue  //救援模式
  kernel vmlinuz
  append rescue initrd=initrd.img method=ftp://192.168.1.10/centos7
  实现无人值守安装时只需要第一个图形化安装就可以了

5. Install and configure DHCP service

[root@PXE-server ~]# yum -y install dhcp  (安装)
[root@PXE-server ~]# vim /etc/dhcp/dhcpd.conf   (编辑配置文件)
subnet 192.168.1.0  netmask  255.255.255.0 {
    
        (网段声明)
 range 192.168.1.188 192.168.1.200;             (分配地址范围)
option routers 192.168.1.254;			(默认网关)
next-server 192.168.1.10;			(指定TFTP服务器的地址)
filename "pxelinux.0";				(指定PXE引导程序的文件名)
}

Insert picture description here

[root@PXE-server ~]# systemctl start dhcpd   (启动dhcp服务)
[root@PXE-server ~]# systemctl enable dhcpd  (将服务设置为开机自启)

Verify PXE network installation

Create a bare-metal centos on the virtual machine, the memory needs to be at least 2GB, otherwise an error will be reported when starting the installation
Insert picture description here

Implement Kickstart unattended installation

Kickstart tool: Configure the installation answer file, automatically complete various settings during the installation process, so that manual intervention is not required, and improve the efficiency of network installation.
Implementation steps:
(1) Prepare the installation answer file
1. Install the system-config-kickstart tool:

[root@PXE-server ~]# yum -y install system-config-kickstart
[root@PXE-server ~]# reboot  (重启)

Go to GUI
Application>System Tools>Kickstart to open
Insert picture description here
1) Basic Configuration
Insert picture description here
2). Installation Method
Insert picture description here
3). Boot Loader Options
Choose to install a new boot loader, and other things don’t need to be changed.

4).
Click to add partition information , the following interface will pop up and
Insert picture description herecontinue to be divided into the following
Insert picture description here
5). Network configuration
Add network equipment

Insert picture description here
6). Verify that the
default is OK

7). The firewall configuration
is set to police use
directly click on the upper left corner of the file> save> root directory, the name defaults to ks.cfg, then close that window and
Insert picture description here
Insert picture description here
return to Xshell

[root@PXE-server ~]# grep -v "^#" /root/ks.cfg (可以查看一些刚刚配置的参数)
[root@PXE-server ~]# vim anaconda-ks.cfg

These are the package options for automatic installation
Insert picture description here

[root@PXE-server ~]# vim ks.cfg
粘贴到最后面

Insert picture description here

Realize batch automatic installation

1. Start the automatic answer file

[root@PXE-server ~]# cp /root/ks.cfg /var/ftp/  (复制到ftp目录中)
[root@PXE-server ~]# vim /var/lib/tftpboot/pxelinux.cfg/default (简单修改一下配置文件)

Insert picture description here

[root@PXE-server ~]# systemctl restart dhcpd
[root@PXE-server ~]# systemctl restart vsftpd
[root@PXE-server ~]# systemctl restart tftp

2. Verify the unattended installation.
Open the test machine, you can see the skip language option directly.
This step is relatively slow, wait a moment, don't use the mouse to

complete the result as follows
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_46902396/article/details/108679711