Redhat 8 yum 配置
yum自带不能用,配置方法有本地和线上。
一般配置目录 /etc/yum.repos.d/
1、本地yum配置,环境 虚拟机
一、挂载安装镜像iso
[root@localhost ~]# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: device write-protected, mounted read-only.
或者
[root@localhost ~]# mount /dev/cdrom /mnt/
注:都是一次性挂载,重启后消失
二、切换到yum源仓库配置目录
[root@localhost ~]# cd /etc/yum.repos.d/
备份原配置,重新创建一个配置文件并打开编辑
mv redhat.repo rehat.repo.bak
vi redhat.repo
[BaseOS]
name = BaseOS
baseurl = file:///mnt/BaseOS
gpgcheck = 0
gpgkey=file:///mnt/RPM-GpG-KEY-redhat-release
enabled = 1
[AppStream]
name = AppStream
baseurl = file:///mnt/AppStream
gpgcheck = 0
gpgkey=file:///mnt/RPM-GpG-KEY-redhat-beta
enabled = 1
三、验证是否成功
yum repolist
执行更新
yum clean all
yum makecache
yum常用命令
yum repolist all #列出所有仓库
yum list all #列出仓库中所有软件包
yum info <软件包名> #查看软件包信息
yum install <软件包名> #安装软件包
yum reinstall <软件包名> #重新安装软件包
yum update <软件包名> #升级软件包
yum remove <软件包名> #移除软件包
yum clean all #清除所有仓库缓存
yum check-update #检查可更新的软件包
2、线上yum配置,暂时可用,镜像地址可能会做调整
阿里云镜像
# 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-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[debug]
name=CentOS-$releasever - DebugInfo
baseurl=http://debuginfo.centos.org/$releasever/$basearch/
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-6
enabled=1
protect=1
priority=1