RHEL7配置yum软件源

使用本地软件源

Ubuntu下使用kvm虚拟RHEL7,查看虚拟机的参数配置:

sudo vim /etc/libvirt/qemu/rhel7.8.xml

1
2
3
4
5
6
7
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/media/sandy/soft/学习/rhel-server-7.8-x86_64-dvd.iso'/>
      <target dev='sdb' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>

重启虚拟机服务:

sudo service libvirtd restart

启动rhel服务器,在虚拟机内打开shell或者在主机用shell ssh连接到rhel服务器。

挂在光盘文件。

1
2
sudo mkdir -p /media/cdrom
sudo mount /dev/cdrom /media/cdrom

编辑yum本地源:

1
2
3
4
5
6
7
8
9
[[email protected] yum.repos.d]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# vim rhel7.repo

[rhel7]
name=rhel7
baseurl=file:///media/cdrom
enabled=1
gpgcheck=0

替换为腾讯centos软件源

1
2
[[email protected] ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 (Maipo)

腾讯软件源

https://mirrors.cloud.tencent.com/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
[[email protected] ~]# cd /etc/yum.repos.d/

[[email protected] yum.repos.d]# rm -rf  //清理存在xxx.repo

[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo

[[email protected] yum.repos.d]# sed -i 's#$releasever#7#g' CentOS-Base.repo  ###替换版本号,不然路径不对

[[email protected] yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo

[[email protected] yum.repos.d]# sed -i 's#$releasever#7#g' epel.repo
[[email protected] yum.repos.d]# yum clean all && yum makecache

[[email protected] yum.repos.d]# yum repolist

参考:https://www.cnblogs.com/xiaochina/p/12423872.html

点击刷新