当前位置:首页 > 操作系统 > 正文内容

Linux的YUM源配置(本地YUM源及网络YUM源)

李云召8个月前 (12-01)操作系统2737

大部分情况下服务器是不允许访问公网的,安装软件是很不方便,那么引用下YUM源安装就方便许多了,下边介绍下两种的配置方式:本地和网络的。

本地配置YUM源

1、根据个人喜好使用各种方法上传到服务器,或者是通过cdrom的方式挂载下。

创建两个目录,一个用来存放ISO文件,一个用来挂在ISO镜像
[root@centos01 soft]# mkdir -p /opt/soft /mnt/cdrom

2、执行挂在镜像的命令

[root@centos01 soft]# mount -o loop /opt/soft/CentOS-7.5-x86_64-DVD-1804.iso /mnt/cdrom/
mount: /dev/loop0 写保护,将以只读方式挂载

3、配置到本地YUM源文件,切换到/etc/yum.repos.d目录,将所有repo文件备份后删除,然后创建Local.repo文件

如目录下有其他的“.repo”文件请先删除,或者使用mv命令重新命名为“.repo.bak

[root@centos01 yum.repos.d]# cd /etc/yum.repos.d/
[root@centos01 yum.repos.d]# touch Local.repo
[CentOS7]                  //yum的ID,本地唯一,用于区分不同yum源
name=CentOS-server                //描述信息
baseurl=file:///mnt/cdrom                 //前面的file://是协议,后面的/mnt/cdrom是光盘挂载点
enabled=1                  //1启用当前yum源,0禁用
gpgcheck=0               //1使用公钥验证rpm包的正确性,0不验证

4、执行yum clean all清除历史缓存

[root@centos01 yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: Local-Centos7.5
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@centos01 yum.repos.d]#

执行 yum makecache和yum repolist创建缓存并查看当前yum源的可用资源数

[root@centos01 yum.repos.d]#yum makecache
[root@centos01 yum.repos.d]#yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
源标识                         源名称                     状态
Local-Centos7.5                CentOS-7.5                 3,971
repolist: 3,971
[root@centos01 yum.repos.d]#

5、测试安装软件:利用yum进行telnet包安装测试

[root@centos01 /]# yum install telnet
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 telnet.x86_64.1.0.17-64.el7 将被 安装
--> 解决依赖关系完成
 
依赖关系解决
 
==============================================================================================================
 Package              架构                 版本                           源                             大小
==============================================================================================================
正在安装:
 telnet               x86_64               1:0.17-64.el7                  Local-Centos7.5                64 k
 
事务概要
==============================================================================================================
安装  1 软件包
 
总下载量:64 k
安装大小:113 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
  正在安装    : 1:telnet-0.17-64.el7.x86_64                                                               1/1 
  验证中      : 1:telnet-0.17-64.el7.x86_64                                                               1/1 
 
已安装:
  telnet.x86_64 1:0.17-64.el7                                                                                 
 
完毕!
[root@centos01 /]#

网络YUM源更换方法:

阿里云
http://mirrors.aliyun.com/repo/

网易
http://mirrors.163.com/.help/centos.html

清华
https://mirrors.tuna.tsinghua.edu.cn/help/centos/

1、进入/etc/yum.repos.d/

执行命令如下:cd /etc/yum.repos.d
将yum源进行备份:mv Centos-Base.repo Centos-Base.repo.bak   也可以删除目录下所有.repo的文件,然后再下载新的配置文件

2、下载Yum源文件,我们以阿里的为例子:执行命令:wget -O Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

[root@localhost yum.repos.d]# wget -O Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
--2023-12-01 10:58:06--  http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 36.143.195.224, 111.32.210.190, 111.32.210.193, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|36.143.195.224|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘Centos-Base.repo’
100%[========================================================>] 2,523       --.-K/s   in 0.001s  
2023-12-01 8:08:06 (3.41 MB/s) - ‘Centos-Base.repo’ saved [2523/2523]

3、执行命令:yum makecache,生成YUM缓存

[root@localhost yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                       | 3.6 kB  00:00:00     
extras                                                                     | 2.9 kB  00:00:00     
updates                                                                    | 2.9 kB  00:00:00     
Metadata Cache Created
[root@localhost yum.repos.d]#

4、执行执行命令:yum -y install update

执行 yum makecache和yum repolist创建缓存并查看当前yum源的可用资源数

[root@localhost yum.repos.d]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                          repo name                                                status
base/7/x86_64                    CentOS-7 - Base - mirrors.aliyun.com                     10,070+2
extras/7/x86_64                  CentOS-7 - Extras - mirrors.aliyun.com                        518
updates/7/x86_64                 CentOS-7 - Updates - mirrors.aliyun.com                   5,426+8
repolist: 16,014
[root@localhost yum.repos.d]#

5、执行yum install telnet 安装telnet   安装成功表示当前网络YUM源配置成功

[root@centos01 yum.repos.d]# yum install telnet


声明:本文由云召博客收集发布,如有侵权,请联系我们,我们将第一时间进行处理。

本文链接:https://www.liyunzhao.com/post/138.html

标签: LinuxYUM源
分享给朋友:

“Linux的YUM源配置(本地YUM源及网络YUM源)” 的相关文章

删除Win8.1这台电脑中视频、图片、文档、下载

删除Win8.1这台电脑中视频、图片、文档、下载

最近把系统安装了8.1,只是为了解决偶尔计算机偶尔不能正常睡醒的问题,只要升级系统了,可是安装了发现多了一些头疼的文件夹,而且名字变成了“这台电脑”,只要想办法去解决。Windows 8.1 默认将视频、图片、文档、下载、音乐、桌面等常用文件夹显示我的电脑中。这些文件夹在这里对我来跟本就没有用,而且...

ssh_exchange_identification:read:Connection reset by peer

ssh_exchange_identification:read:Connection reset by peer

SSH登录相关主机时,提示如下报错如何解决?在客户端连接服务端:[root@foundation66 ~]# ssh root@172.25.254.1ssh_exchange_identification: read: Connection reset by peer## -v表示查看连接详细信息...

Windows server 2008 R2 更新补丁失败进入恢复模式

Windows server 2008 R2 更新补丁失败进入恢复模式

故障现象:由于安全需要,需要再现网的服务器上安装系统补丁,Windows 2008 R2,但是升级补丁后,重启进入了恢复页面,正常进入系统,多次重启仍然无法正常进入系统。解决方法:经过确认,仅仅是修补了相关补丁,导致此问题发生,那么我们按照如下操作进行修复下:1、可使用USB WinPE系统引导,也...

Windows 7 访问部分网站提示非安全链接问题解决

Windows 7 访问部分网站提示非安全链接问题解决

Windows 7 操作系统是一款大家非常熟悉从操作系统,虽然官方已经在2020年1月14日全面停止对Windows 7的支持,然而,直到现在还有很多人在使用,有些程序的兼容性在Windows 7上也非常的优秀,不过在重新安装windows 7后不知大家是否碰到过类似的问题,访问淘宝、京东,甚至百度...

统信UOS桌面操作系统【汇总目录】

统信UOS桌面操作系统【汇总目录】

随着各类的国产化,桌面操作系统也开始逐渐国产化,使用习惯了Windows,突然转变,还是很有必要去适应下,也从网上整理了下材料(正月十六工作室),以免自己用的时候不好找,后续可能会根据需求持续更新。信创操作系统–统信UOS桌面版(系统安装:分别在虚拟机、物理机和Win10上安装,驱动安装)保姆级教程...

Linux系统下bonding配置方法

Linux系统下bonding配置方法

由于每次使用都需要搜索查找,所以就搞来一篇文章记录下,方便后续使用,顺便也琢磨了下各个bond模式的区别。接下来先简单介绍下七种工作模式,常用的模式有 0、1、4、6,每种工作模式都有其各自的优缺点:一、bond工作模式:1、mode=0(balance-rr):Round-robin policy...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。