Configure local yum source warehouse and online yum source warehouse (VMware virtual machine) in Linux system


Preface

  • After the Linux operating system is installed in the host, it has the basis to provide software services, network services and other functions
  • However, after all, there are only a few software packages installed with the operating system, and the functions implemented are relatively limited.
  • When you need to provide more functions for the host, installing a new application is called an inevitable job

1. The difference between RPM and YUM

  • RPM package is one of the most widely used software packages in various Linux distributions
  • The RPM software package management mechanism was first proposed by Red Hat. Later, as the version was upgraded, more excellent features were gradually integrated, which is called the recognized software package management standard in many Linux distributions.
  • Using RPM, we can easily install, query, uninstall, and upgrade software, but the dependency between RPM software packages is often cumbersome, especially when the software consists of multiple RPM packages
  • Yum (full name Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora, RedHat and CentOS
  • Based on RPM package management, it can automatically download and install RPM packages from the specified server, automatically handle dependencies, and install all dependent software packages at one time, without the need for tedious download and installation again and again

Two, configure the local yum source warehouse

  • I had a blog before with a detailed introduction, including learning materials for CentOS7.
    Link: https://blog.csdn.net/weixin_51486343/article/details/109815397
  • Previously, when setting up the virtual VMware virtual environment, the CentOS image file was added. Next, we need to check the "Connected" option in the virtual machine settings
    mark
  • At this time, you will find that something like "CentOS 7 x86_64" appears on the desktop.
    mark
  • Enter the terminal and start the next step
    • mount /dev/cdrom /mnt/
      ##Mount the CD to the /mnt directory
    • cd /etc/yum.repos.d/
      ##Enter the yum.repos.d directory under /etc
    • mkdir repos.bak
      ##Create a new directory called repos.bak
    • mv *.repo repos.bak
      ##Move all files with .repo to the repos.bak directory
  • Create yum source warehouse as follows
    • cd /etc/yum.repos.d/
    • vim local.repo
    • There is nothing inside, we need to edit, press "i" to enter the editing mode and start editing line by line
      mark
  • Also need to delete yum cache and update
    mark
  • Okay, let's install another file to verify
    mark
    success

Three, configure online yum source warehouse

  • The network yum source has newer and more complete packages than the mirror yum
  • And the installation is very simple, it is recommended to use in the network environment
  • The following is Alibaba Cloud yum
  • First, the first step is to download the online yum source configuration file to the local (copy and paste directly, a bit long)
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2020-12-11 14:57:15--  https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 117.91.177.244, 58.223.210.227, 58.216.4.238, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|117.91.177.244|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[====================================>] 2,523       --.-K/s 用时 0s      

2020-12-11 14:57:16 (802 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

[root@localhost ~]# 

  • Next we need to move the previous local yum source configuration file so that the system can read the online we just downloaded
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  local.repo  repos.bak        ##这里可以看到多了一个“CentOS-Base.repo,就它”
[root@localhost yum.repos.d]# mv local.repo repos.bak/
  • The last step is to clear the previous yum cache, and then create a new Alibaba Cloud yum cache (you need to wait a while)
[root@localhost yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache 
已加载插件:fastestmirror, langpacks
base                                                   | 3.6 kB     00:00     
extras                                                 | 2.9 kB     00:00     
updates                                                | 2.9 kB     00:00     
base/7/x86_64/primary_db       FAILED                                          
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Name or service not known"
正在尝试其它镜像。
(1/10): base/7/x86_64/group_gz                           | 153 kB   00:00     
(2/10): extras/7/x86_64/other_db                         | 134 kB   00:00     
(3/10): extras/7/x86_64/filelists_db                     | 224 kB   00:00     
(4/10): base/7/x86_64/other_db                           | 2.6 MB   00:00     
(5/10): updates/7/x86_64/filelists_db                    | 2.1 MB   00:00     
(6/10): updates/7/x86_64/other_db                        | 226 kB   00:00     
(7/10): base/7/x86_64/primary_db                         | 6.1 MB   00:00     
base/7/x86_64/filelists_db     FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/d6d94c7d406fe7ad4902a97104b39a0d8299451832a97f31d71653ba982c955b-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
extras/7/x86_64/primary_db     FAILED                                          
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/6de1755ab3e4e9bd0ee8ff31b6c979fe8a2e132b66629bf4b659b0a7878fe70f-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
updates/7/x86_64/primary_db    FAILED                                          
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/21d17a17af2a9bb0da67c098868bc431078c8dfc5ed7e36ee9b25300d6913b72-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
正在尝试其它镜像。
(8/10): extras/7/x86_64/primary_db                       | 222 kB   00:00     
(9/10): base/7/x86_64/filelists_db                       | 7.2 MB   00:00     
(10/10): updates/7/x86_64/primary_db                     | 3.7 MB   00:00     
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
元数据缓存已建立
[root@localhost yum.repos.d]# 

  • Finally, let’s verify
[root@localhost yum.repos.d]# yum -y install dhcp
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 dhcp.x86_64.12.4.2.5-58.el7.centos 将被 升级
---> 软件包 dhcp.x86_64.12.4.2.5-82.el7.centos 将被 更新
--> 正在处理依赖关系 dhcp-libs(x86-64) = 12:4.2.5-82.el7.centos,它被软件包 12:dhcp-4.2.5-82.el7.centos.x86_64 需要
--> 正在处理依赖关系 dhcp-common = 12:4.2.5-82.el7.centos,它被软件包 12:dhcp-4.2.5-82.el7.centos.x86_64 需要
--> 正在处理依赖关系 libisc-export.so.169()(64bit),它被软件包 12:dhcp-4.2.5-82.el7.centos.x86_64 需要
--> 正在处理依赖关系 libdns-export.so.1102()(64bit),它被软件包 12:dhcp-4.2.5-82.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 bind-export-libs.x86_64.32.9.11.4-26.P2.el7_9.2 将被 安装
---> 软件包 dhcp-common.x86_64.12.4.2.5-58.el7.centos 将被 升级
--> 正在处理依赖关系 dhcp-common = 12:4.2.5-58.el7.centos,它被软件包 12:dhclient-4.2.5-58.el7.centos.x86_64 需要
---> 软件包 dhcp-common.x86_64.12.4.2.5-82.el7.centos 将被 更新
---> 软件包 dhcp-libs.x86_64.12.4.2.5-58.el7.centos 将被 升级
---> 软件包 dhcp-libs.x86_64.12.4.2.5-82.el7.centos 将被 更新
--> 正在检查事务
---> 软件包 dhclient.x86_64.12.4.2.5-58.el7.centos 将被 升级
---> 软件包 dhclient.x86_64.12.4.2.5-82.el7.centos 将被 更新
--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================================================================
 Package                                         架构                                  版本                                                   源                                      大小
===========================================================================================================================================================================================
正在更新:
 dhcp                                            x86_64                                12:4.2.5-82.el7.centos                                 base                                   515 k
为依赖而安装:
 bind-export-libs                                x86_64                                32:9.11.4-26.P2.el7_9.2                                updates                                1.1 M
为依赖而更新:
 dhclient                                        x86_64                                12:4.2.5-82.el7.centos                                 base                                   286 k
 dhcp-common                                     x86_64                                12:4.2.5-82.el7.centos                                 base                                   176 k
 dhcp-libs                                       x86_64                                12:4.2.5-82.el7.centos                                 base                                   133 k

事务概要
===========================================================================================================================================================================================
安装           ( 1 依赖软件包)
升级  1 软件包 (+3 依赖软件包)

总下载量:2.2 M
Downloading packages:
No Presto metadata available for base
警告:/var/cache/yum/x86_64/7/base/packages/dhcp-4.2.5-82.el7.centos.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
dhcp-4.2.5-82.el7.centos.x86_64.rpm 的公钥尚未安装
(1/5): dhcp-4.2.5-82.el7.centos.x86_64.rpm                                                                                                                          | 515 kB  00:00:00     
(2/5): dhclient-4.2.5-82.el7.centos.x86_64.rpm                                                                                                                      | 286 kB  00:00:00     
(3/5): dhcp-libs-4.2.5-82.el7.centos.x86_64.rpm                                                                                                                     | 133 kB  00:00:00     
(4/5): dhcp-common-4.2.5-82.el7.centos.x86_64.rpm                                                                                                                   | 176 kB  00:00:00     
bind-export-libs-9.11.4-26.P2.el7_9.2.x86_64.rpm 的公钥尚未安装
(5/5): bind-export-libs-9.11.4-26.P2.el7_9.2.x86_64.rpm                                                                                                             | 1.1 MB  00:00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                       5.1 MB/s | 2.2 MB  00:00:00     
从 http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <[email protected]>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 来自       : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : 12:dhcp-libs-4.2.5-82.el7.centos.x86_64                                                                                                                                1/9 
  正在更新    : 12:dhcp-common-4.2.5-82.el7.centos.x86_64                                                                                                                              2/9 
  正在安装    : 32:bind-export-libs-9.11.4-26.P2.el7_9.2.x86_64                                                                                                                        3/9 
  正在更新    : 12:dhclient-4.2.5-82.el7.centos.x86_64                                                                                                                                 4/9 
  正在更新    : 12:dhcp-4.2.5-82.el7.centos.x86_64                                                                                                                                     5/9 
  清理        : 12:dhcp-4.2.5-58.el7.centos.x86_64                                                                                                                                     6/9 
  清理        : 12:dhclient-4.2.5-58.el7.centos.x86_64                                                                                                                                 7/9 
  清理        : 12:dhcp-common-4.2.5-58.el7.centos.x86_64                                                                                                                              8/9 
  清理        : 12:dhcp-libs-4.2.5-58.el7.centos.x86_64                                                                                                                                9/9 
  验证中      : 12:dhcp-common-4.2.5-82.el7.centos.x86_64                                                                                                                              1/9 
  验证中      : 32:bind-export-libs-9.11.4-26.P2.el7_9.2.x86_64                                                                                                                        2/9 
  验证中      : 12:dhclient-4.2.5-82.el7.centos.x86_64                                                                                                                                 3/9 
  验证中      : 12:dhcp-libs-4.2.5-82.el7.centos.x86_64                                                                                                                                4/9 
  验证中      : 12:dhcp-4.2.5-82.el7.centos.x86_64                                                                                                                                     5/9 
  验证中      : 12:dhcp-common-4.2.5-58.el7.centos.x86_64                                                                                                                              6/9 
  验证中      : 12:dhcp-4.2.5-58.el7.centos.x86_64                                                                                                                                     7/9 
  验证中      : 12:dhcp-libs-4.2.5-58.el7.centos.x86_64                                                                                                                                8/9 
  验证中      : 12:dhclient-4.2.5-58.el7.centos.x86_64                                                                                                                                 9/9 

作为依赖被安装:
  bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.2                                                                                                                                          

更新完毕:
  dhcp.x86_64 12:4.2.5-82.el7.centos                                                                                                                                                       

作为依赖被升级:
  dhclient.x86_64 12:4.2.5-82.el7.centos                      dhcp-common.x86_64 12:4.2.5-82.el7.centos                      dhcp-libs.x86_64 12:4.2.5-82.el7.centos                     

完毕!
[root@localhost yum.repos.d]# 

Guess you like

Origin blog.csdn.net/weixin_51486343/article/details/111035843