CentOS 8:配置本地yum源并通过dnf命令实现软件的安装过程

配置本地yum源

1.在终端进行以下命令,挂载光盘。

[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# df /mnt/cdrom
文件系统               1K-块    已用     可用 已用% 挂载点
/dev/mapper/cl-root 17811456 4744832 13066624   27% /
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom
mount: /mnt/cdrom: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# df -hT /mnt/cdrom
文件系统       类型     容量  已用  可用 已用% 挂载点
/dev/sr0       iso9660   11G   11G     0  100% /mnt/cdrom

2.在终端进行以下命令,更改配置文件。

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 48
-rw-r--r--. 1 root root  719 9月  14 2021 CentOS-Linux-AppStream.repo
-rw-r--r--. 1 root root  704 9月  14 2021 CentOS-Linux-BaseOS.repo
-rw-r--r--. 1 root root 1130 9月  14 2021 CentOS-Linux-ContinuousRelease.repo
-rw-r--r--. 1 root root  318 9月  14 2021 CentOS-Linux-Debuginfo.repo
-rw-r--r--. 1 root root  732 9月  14 2021 CentOS-Linux-Devel.repo
-rw-r--r--. 1 root root  704 9月  14 2021 CentOS-Linux-Extras.repo
-rw-r--r--. 1 root root  719 9月  14 2021 CentOS-Linux-FastTrack.repo
-rw-r--r--. 1 root root  740 9月  14 2021 CentOS-Linux-HighAvailability.repo
-rw-r--r--. 1 root root  693 9月  14 2021 CentOS-Linux-Media.repo
-rw-r--r--. 1 root root  706 9月  14 2021 CentOS-Linux-Plus.repo
-rw-r--r--. 1 root root  724 9月  14 2021 CentOS-Linux-PowerTools.repo
-rw-r--r--. 1 root root 1124 9月  14 2021 CentOS-Linux-Sources.repo
[root@localhost yum.repos.d]# vim CentOS-Linux-Media.repo
[root@localhost yum.repos.d]# vim CentOS-Linux-AppStream.repo
[root@localhost yum.repos.d]# vim CentOS-Linux-BaseOS.repo
[root@localhost yum.repos.d]# vim CentOS-Linux-Extras.repo

使用vim编辑器时,通过Insert插入或Delete删除并根据下图显示进行更改,更改完成后按下Esc确保在命令模式下,输入“:wq”并按下回车键,保存并退出vim编辑器。

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.在终端进行以下命令,更新并验证yum源。

[root@localhost yum.repos.d]# yum clean all
13 文件已删除
[root@localhost yum.repos.d]# yum makecache
CentOS Linux 8 - Media - BaseOS                        196 MB/s | 2.6 MB     00:00    
CentOS Linux 8 - Media - AppStream                     251 MB/s | 7.5 MB     00:00    
元数据缓存已建立。
[root@localhost yum.repos.d]# yum install httpd

在这里插入图片描述

如图所示表明yum源成功配置。


dnf命令与软件包的安装

命令作用
dnf repolist all列出所有仓库
dnf list all列出仓库中所有软件包
dnf info 软件包名称查看软件包信息
dnf install 软件包名称安装软件包
dnf reinstall 软件包名称重新安装软件包
dnf update 软件包名称升级软件包
dnf remove 软件包名称移除软件包
dnf clean all清除所有仓库缓存
dnf check-update检查可更新的软件包
dnf grouplist查看系统中已经安装的软件包组
dnf groupinstall 软件包组安装软件包组
dnf groupremove 软件包组移除软件包组
dnf groupinfo 软件包组查询软件包组信息

以network-scripts为例进行安装过程演示。

1.在终端中进行以下命令,查看network-scripts软件包信息。

[root@localhost ~]# dnf info network-scripts
上次元数据过期检查:0:58:31 前,执行于 2023年09月23日 星期六 11时14分59秒。
可安装的软件包
名称         : network-scripts
版本         : 10.00.15
发布         : 1.el8
架构         : x86_64
大小         : 196 k
源           : initscripts-10.00.15-1.el8.src.rpm
仓库         : media-baseos
概况         : Legacy scripts for manipulating of network devices
URL          : https://github.com/fedora-sysv/initscripts
协议         : GPLv2
描述         : This package contains the legacy scripts for activating &
             : deactivating of most network interfaces. It also provides a legacy
             : version of 'network' service.
             : 
             : The 'network' service is enabled by default after installation of
             : this package, and if the network-scripts are installed alongside
             : NetworkManager, then the ifup/ifdown commands from network-scripts
             : take precedence over the ones provided by NetworkManager.
             : 
             : If user has both network-scripts & NetworkManager installed, and
             : wishes to use ifup/ifdown from NetworkManager primarily, then they
             : has to run command: $ update-alternatives --config ifup
             : 
             : Please note that running the command above will also disable the
             : 'network' service.

2.在终端中进行以下命令,安装network-scripts,输入“y”表示确定安装。

[root@localhost ~]# dnf install network-scripts
上次元数据过期检查:0:01:16 前,执行于 2023年09月24日 星期日 18时52分00秒。
依赖关系解决。
=======================================================================================
 软件包                     架构         版本                 仓库                大小
=======================================================================================
安装:
 network-scripts            x86_64       10.00.15-1.el8       media-baseos       196 k
安装依赖关系:
 ipcalc                     x86_64       0.2.4-4.el8          media-baseos        38 k
安装弱的依赖:
 network-scripts-team       x86_64       1.31-2.el8           media-baseos        28 k

事务概要
=======================================================================================
安装  3 软件包

总下载:262 k
安装大小:245 k
确定吗?[y/N]: y
下载软件包:
[MIRROR] ipcalc-0.2.4-4.el8.x86_64.rpm: Curl error (1): Unsupported protocol for #file://media/CentOS/BaseOS/Packages/ipcalc-0.2.4-4.el8.x86_64.rpm [Protocol "#file" not supported or disabled in libcurl]
[MIRROR] network-scripts-10.00.15-1.el8.x86_64.rpm: Curl error (1): Unsupported protocol for #file://media/CentOS/BaseOS/Packages/network-scripts-10.00.15-1.el8.x86_64.rpm [Protocol "#file" not supported or disabled in libcurl]
[MIRROR] network-scripts-team-1.31-2.el8.x86_64.rpm: Curl error (1): Unsupported protocol for #file://media/CentOS/BaseOS/Packages/network-scripts-team-1.31-2.el8.x86_64.rpm [Protocol "#file" not supported or disabled in libcurl]
(1/3): ipcalc-0.2.4-4.el8.x86_64.rpm                   514 kB/s |  38 kB     00:00    
(2/3): network-scripts-10.00.15-1.el8.x86_64.rpm       8.3 MB/s | 196 kB     00:00    
(3/3): network-scripts-team-1.31-2.el8.x86_64.rpm      4.2 MB/s |  28 kB     00:00    
---------------------------------------------------------------------------------------
总计                                                   1.3 MB/s | 262 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                        1/1 
  安装    : ipcalc-0.2.4-4.el8.x86_64                                              1/3 
  安装    : network-scripts-10.00.15-1.el8.x86_64                                  2/3 
  运行脚本: network-scripts-10.00.15-1.el8.x86_64                                  2/3 
  安装    : network-scripts-team-1.31-2.el8.x86_64                                 3/3 
  运行脚本: network-scripts-team-1.31-2.el8.x86_64                                 3/3 
  验证    : ipcalc-0.2.4-4.el8.x86_64                                              1/3 
  验证    : network-scripts-10.00.15-1.el8.x86_64                                  2/3 
  验证    : network-scripts-team-1.31-2.el8.x86_64                                 3/3 

已安装:
  ipcalc-0.2.4-4.el8.x86_64                  network-scripts-10.00.15-1.el8.x86_64    
  network-scripts-team-1.31-2.el8.x86_64    

完毕!

在这里插入图片描述
在这里插入图片描述
如图所示即为成功安装。


参考资料

Centos7配置yum源(本地yum源和阿里网络yum源)_centos7yum源配置_跑不完的脚本的博客

CentOS8配置本地yum源_HaifengQi的博客

centos8,yum本地源报错checksum的经历_yum checksum 不正确_大橘的博客

  • 25
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

STRANGEX-03

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值