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

栏目: 服务器 · 发布时间: 5年前

内容简介:Linux基础入门教程-RHEL7.4之YUM更换CentOS源1.配置YUM本地源1.挂载镜像

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 ~]#

4.创建新的repo文件

[base]

name=CentOS-7 - Base

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/os/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-7 - Updates

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/updates/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-7 - Extras

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/extras/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-7 - Plus

baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/centosplus/$basearch/

#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

5.使用yum makecache刷新生成缓存

[root@linuxidc ~]# yum makecache

Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager

This system is not registered with an entitlement server. You can use subscription-manager to register.

Loading mirror speeds from cached hostfile

base                                                                          | 3.6 kB  00:00:00   

extras                                                                        | 3.4 kB  00:00:00   

updates                                                                        | 3.4 kB  00:00:00   

(1/12): base/x86_64/group_gz                                                  | 166 kB  00:00:06   

(2/12): base/x86_64/primary_db                                                | 5.9 MB  00:00:02   

(3/12): base/x86_64/filelists_db                                              | 6.9 MB  00:00:08   

(4/12): base/x86_64/other_db                                                  | 2.5 MB  00:00:01   

(5/12): extras/x86_64/prestodelta                                              |  68 kB  00:00:06   

(6/12): extras/x86_64/primary_db                                              | 173 kB  00:00:00   

(7/12): extras/x86_64/other_db                                                | 110 kB  00:00:00   

(8/12): extras/x86_64/filelists_db                                            | 588 kB  00:00:06   

(9/12): updates/x86_64/prestodelta                                            | 409 kB  00:00:06   

(10/12): updates/x86_64/filelists_db                                          | 2.4 MB  00:00:07   

(11/12): updates/x86_64/other_db                                              | 381 kB  00:00:00   

(12/12): updates/x86_64/primary_db                                            | 4.3 MB  00:00:01   

Metadata Cache Created

6.epel扩展源

首先从CentOS Extras这个源(tuna也有镜像)里安装epel-release:

yum install epel-release -y

编辑epel.repo

[epel]

name=Extra Packages for Enterprise Linux 7 - $basearch

baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch

#mirrorlist=https://mirrors.Fedoraproject.org/metalink?repo=epel-7&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]

name=Extra Packages for Enterprise Linux 7 - $basearch - Debug

baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/debug

#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1

[epel-source]

name=Extra Packages for Enterprise Linux 7 - $basearch - Source

baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/SRPMS

#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

gpgcheck=1

这些做完以后要删除/etc/pki/rpm-gpg/的文件

把epel中新的文件下载放入其中

[root@linuxidc ~]# ls /etc/pki/rpm-gpg/

RPM-GPG-KEY-EPEL-7

RPM-GPG-KEY-CentOS-7

更多 YUM 相关教程见以下内容

RHEL7 本地yum源配置 https://www.linuxidc.com/Linux/2017-01/139140.htm

CentOS 6.5 配置本地Yum源  https://www.linuxidc.com/Linux/2017-04/143127.htm

CentOS 7 使用阿里云的yum源、PIP源 https://www.linuxidc.com/Linux/2017-01/13966.htm

CentOS及Red Hat Linux安装yum源  https://www.linuxidc.com/Linux/2017-02/140205.htm

CentOS 7更改yum源与更新系统 https://www.linuxidc.com/Linux/2017-01/140067.htm

RedHat7.0配置本地yum源  https://www.linuxidc.com/Linux/2017-01/139148.htm

RedHat Linux 7安装CentOS 7 yum源  https://www.linuxidc.com/Linux/2017-04/142444.htm

软件包管理之前端管理工具yum  https://www.linuxidc.com/Linux/2017-02/140270.htm

CentOS 7 使用阿里云的yum源、PIP源 https://www.linuxidc.com/Linux/2017-01/13966.htm

Linux yum的配置使用和程序包的编译安装  https://www.linuxidc.com/Linux/2017-09/146903.htm

YUM命令使用示例  https://www.linuxidc.com/Linux/2018-01/150690.htm

Linux公社的RSS地址: https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址: https://www.linuxidc.com/Linux/2018-09/154064.htm


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

新内容创业:我这样打造爆款IP

新内容创业:我这样打造爆款IP

南立新、曲琳 / 机械工业出版社 / 2016-5-10 / 39.00

这是个内容创业爆棚的时代,在采访几十家内容创业公司,与一线最优秀的创业者独家对话之后,作者写作了这本书,其中包括对这个行业的真诚感触,以及希望沉淀下来的体系化思考。 本书共分三个部分讲述了爆红大号的内容创业模式和方法。其中第一部分,讲述了新的生产方式,即内容形态发展的现状--正在被塑造;第二部分,讲述了新的盈利探索,即从贩卖产品到贩卖内容的转变,该部分以多个案例进行佐证,内容翔实;第三部分,......一起来看看 《新内容创业:我这样打造爆款IP》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

html转js在线工具
html转js在线工具

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具