RHEL7.4之YUM更换CentOS源

Linux基础入门教程-RHEL7.4之YUM更换CentOS

1.配置YUM本地源

1.挂载镜像
[root@linuxidc ~]# mount /dev/cdrom /mnt

2.查看是否挂载成功
[root@linuxidc ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        49G  1.3G  48G  3% /
devtmpfs        479M    0  479M  0% /dev
tmpfs          489M    0  489M  0% /dev/shm
tmpfs          489M  6.6M  482M  2% /run
tmpfs          489M    0  489M  0% /sys/fs/cgroup
/dev/sda1      497M  112M  385M  23% /boot
tmpfs            98M    0  98M  0% /run/user/0
/dev/sr0        3.8G  3.8G    0 100% /mnt


3.备份原来的仓库
[root@linuxidc ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d_bak
[root@linuxidc ~]# rm -f /etc/yum.repos.d/*

4.创建新的repo配置文件
[root@linuxidc ~]# vi /etc/yum.repos.d/dvd.repo

[dvd]
name=install dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0


5.刷新repos生成缓存
[root@linuxidc ~]# yum makecache
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
dvd                                                                            | 4.1 kB  00:00:00   
(1/5): dvd/group_gz                                                            | 137 kB  00:00:00   
(2/5): dvd/filelists_db                                                        | 3.4 MB  00:00:00   
(3/5): dvd/primary_db                                                          | 4.0 MB  00:00:00   
(4/5): dvd/other_db                                                            | 1.5 MB  00:00:00   
(5/5): dvd/productid                                                          | 1.6 kB  00:00:00   
Metadata Cache Created

2.使用CentOS源

1.卸载红帽yum
[root@linuxidc Packages]# rpm -e $(rpm -qa | grep yum) --nodeps
[root@linuxidc Packages]# echo $?
0

2.删除yum相关文件
[root@linuxidc Packages]# rm -rf /etc/yum.conf
[root@linuxidc Packages]# rm -rf /etc/yum.repos.d/*
[root@linuxidc Packages]# rm -rf /var/cache/yum


3.下载CentOS相关yum组件
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-45.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/yum-utils-1.1.31-45.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
[root@linuxidc ~]# rpm -ivh *.rpm
warning: Python-chardet-2.2.1-1.el7_1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
  1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 14%]
  2:yum-plugin-fastestmirror-1.1.31-4################################# [ 29%]
  3:yum-3.4.3-158.el7.centos        ################################# [ 43%]
  4:python-chardet-2.2.1-1.el7_1    ################################# [ 57%]
  5:python-kitchen-1.1.1-5.el7      ################################# [ 71%]
  6:yum-utils-1.1.31-45.el7          ################################# [ 86%]
  7:yum-updateonboot-1.1.31-45.el7  ################################# [100%]
[root@linuxidc ~]#

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/12546.html