了解常见的网络yum源及学会本地、网络yum源的配置

一、常见的网络yum源

网络yum源一般是指公共的网络yum源,如163、阿里云、中国科技大学等,或者是自建的局域网yum仓库。这些网络yum源提供了丰富的软件包和快速的下载速度,方便用户安装和更新系统。

常见的公共网络yum源包括:
  • 163 yum源:由网易提供,访问速度快,适用于国内用户。
  • 阿里云yum源:由阿里云提供,同样具有较快的访问速度和丰富的软件包。
  • 中国科技大学yum源:由中国科技大学维护,提供稳定的软件源服务。
  • 华为云yum源:由华为公司提供,适合需要高可靠性和稳定性的用户。

二、网络yum源的配置

配置网络yum源主要有两种方式:

  1. 直接下载官方的yum配置文件替换到本地
    • 首先备份原有的yum配置文件(如/etc/yum.repos.d/CentOS-Base.repo)。
    • 然后从网络yum源的镜像站下载对应的yum配置文件,并将其放置到/etc/yum.repos.d/目录下。
    • 最后清除yum缓存并重新生成缓存(使用yum clean allyum makecache命令)。
  2. 修改本地的yum配置文件中的baseurl地址
    • 编辑/etc/yum.repos.d/目录下的yum配置文件(如CentOS-Base.repo)。
    • 将baseurl的地址修改为你想要使用的网络yum源的地址。
    • 同样需要清除并重新生成yum缓存。

三、本地yum源的配置

本地yum源通常用于无法访问外网的服务器或需要保证软件包安全性的场景。配置本地yum源的主要步骤如下:

  1. 挂载系统安装光盘或ISO镜像
    • 将系统安装光盘插入光驱或使用mount命令挂载ISO镜像文件。
    • 例如,使用mount -o loop /path/to/iso/file.iso /mnt命令挂载ISO镜像。
  2. 配置yum仓库文件
    • /etc/yum.repos.d/目录下创建一个新的yum仓库文件(以.repo结尾)。
    • 编辑该文件,设置仓库的namebaseurl(指向挂载的目录,如file:///mnt)、enabled(设置为1以启用仓库)和gpgcheck(根据需要设置是否进行GPG校验)。
  3. 清除并重新生成yum缓存
    • 使用yum clean all命令清除旧的缓存。
    • 使用yum makecache命令重新生成缓存。

四、总结

配置yum源是Linux系统管理中常见且重要的任务之一。通过合理配置网络yum源和本地yum源,可以确保系统软件的及时更新和安全性。在配置过程中,需要注意选择可靠的yum源,并根据实际需求进行配置调整。同时,定期检查和更新yum源也是保证系统稳定性和安全性的重要措施。

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
redhat 7.2 可用yum源, 亲自测试可以使用 ,使用过程: 1.卸载已经存在的yum: rpm -qa | grep yum | xargs rpm -e --nodeps 2.将yum 文件放到server中 3.执行rpm -ivh yum-* 4.创建repo文件: #CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$7 - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=os baseurl=http://mirrors.163.com/centos/7/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$7 - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/7/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$7 - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$7&arch;=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/7/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$7 - Plus - 163.com baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 5.测试是否安装成功 yum -y install tree
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值