1.配置YUM本地源

1.挂载镜像

[root@qdlinux ~]# mount /dev/cdrom /mnt

2.查看是否挂载成功

[root@qdlinux ~]# 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@qdlinux ~]# cp -r /etc/yum.repos.d /etc/yum.repos.d_bak
[root@qdlinux ~]# rm -f /etc/yum.repos.d/*

4.创建新的repo配置文件

[root@qdlinux ~]# vi /etc/yum.repos.d/dvd.repo

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

5.刷新repos生成缓存

[root@qdlinux ~]# 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@qdlinux Packages]# rpm -e $(rpm -qa | grep yum) --nodeps
[root@qdlinux Packages]# echo $?
0

2.删除yum相关文件

[root@qdlinux Packages]# rm -rf /etc/yum.conf
[root@qdlinux Packages]# rm -rf /etc/yum.repos.d/*
[root@qdlinux 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@qdlinux ~]# 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@qdlinux ~]#

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@qdlinux ~]# 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@qdlinux ~]# ls /etc/pki/rpm-gpg/
RPM-GPG-KEY-EPEL-7
RPM-GPG-KEY-CentOS-7

Linux基础学习-RHEL7.4之YUM更换CentOS源的更多相关文章

  1. Linux基础学习系列目录导航

    Linux基础学习-通过VM安装RHEL7.4 Linux基础学习-命令行与图形界面切换 Linux基础学习-基本命令 Linux基础学习-RHEL7.4之YUM更换CentOS源 Linux基础学习 ...

  2. linux基础学习之软件安装以及常用命令

    linux基础学习之软件安装以及常用命令 调用中央仓库: yum install wget 然后下载nodejs: wget https://nodejs.org/dist/v10.14.2/node ...

  3. Linux 基础学习2

    目录 Linux 基础学习2 文件目录结构 文件命名规范 文件系统结构 linux应用程序的组成 绝对路径和相对路径 目录名和基名 切换目录 切换到家目录 切换到上一次的目录 显示当前的工作目录 列出 ...

  4. linux基础学习路线&review

    linux基础学习网址: https://www.runoob.com/linux/linux-tutorial.html 比较重点的是这个启动过程的介绍学习:https://www.runoob.c ...

  5. Linux 基础学习1

    目录 Linux 基础学习 用户登录 终端 交互式接口 bash 修改ssh连接慢的步骤 命令提示符 显示提示符格式 命令 别名 命令格式 获取命令的帮助信息 man bash 快捷键 tab 键 引 ...

  6. Linux基础学习(全)

    使用的Linux发行版本为Redhat 1.Linux(RedHat)基础学习-命令行使用入门 2.Linux(RedHat)基础学习-文件寻址与管理 3.Linux(RadHat)基础学习-vim编 ...

  7. Linux基础学习(1)--Linux系统简介

    第一章——Linux系统简介 1.UNIX和Linux发展史: 1.1 unix发展史: (1)1965年,美国麻省理工学院(MIT).通用电气公司(GE)及AT&T的贝尔实验室联合开发Mul ...

  8. Linux基础学习(二)

    前言: 我们在上一节了解了一下linux的硬件组成,虽然也许对具体的东西还不甚了解,但是我们知道了linux下一切皆文件这一特性 我们装好了CentOS7的虚拟机(这个可以看别人教程来装起来,比较简单 ...

  9. Linux 基础学习(第一节)

    IP地址的配置 配置临时IP地址 ifconfig etho 192.168.0.91 255.255.255.0 图形化下面配置IP地址: 重启网卡服务: shell环境配置网卡信息 必备的参数 关 ...

随机推荐

  1. 洛谷P4725 【模板】多项式对数函数(多项式运算)

    传送门 前置芝士:微积分(有所了解即可)(可以看看这篇,写得非常详细我看了两章就看不下去了) 以下都是一些简单的教程切莫当真,仅供理解,建议看更严谨的 导数:对于一个函数$f(x)$,它的导数$f'( ...

  2. Event Handling Guide for iOS--事件驱动指南

    事件是发送给应用程序来通知它用户动作的对象.在iOS中,事件可以有多种形式:多触摸事件,motion(,移动,手 势)事件---例如,设备的加速计(accelerometer)--和控制多媒体的事件. ...

  3. 大数据系列文章-Hadoop的HDFS读写流程(二)

    在介绍HDFS读写流程时,先介绍下Block副本放置策略. Block副本放置策略 第一个副本:放置在上传文件的DataNode:如果是集群外提交,则随机挑选一台磁盘不太满,CPU不太忙的节点. 第二 ...

  4. LuoguP3121 [USACO15FEB]审查(黄金)Censoring (Gold)【Hash做法】By cellur925

    题目传送门 其实这题正解是AC自动机的,字符串哈希吸氧才能过的,但是我太菜了不会...只能先用哈希苟了. 在扫描单词的时候首先把各个单词的哈希值和长度存起来.然后按照长度从小到大将各单词排序.而那个长 ...

  5. UvaLive6442(思维、结论)

    结论是:按位置排序好以后,对于真正的答案,走法应该是:依次走向第0个等分点,第1个等分点……这样对于这种等分情况,是最优的调度. /* 先假设一个终点位置然后按位站好 这个位置不一定是最优所以要调 调 ...

  6. 1-2JDK的安装和环境变量设置

    JDK的下载和安装 可以去oracle官网里面下载JDK:http://www.oracle.com 英文不好的同学可以通过下面这个百度网盘的链接进行下载:http://pan.baidu.com/s ...

  7. K-th Number 线段树的区间第K大

    http://poj.org/problem?id=2104 由于这题的时间限制不紧,所以用线段树水一水. 每个节点保存的是一个数组. 就是对应区间排好序的数组. 建树的时间复杂度需要nlogn 然后 ...

  8. poj2112Optimal Milking(二分+最大流)

    链接 floyd求出牛到机器的最短距离,二分距离,小于当前距离的边容量设为1,求出满容量下的最短距离. EK算法 #include <iostream> #include<cstdi ...

  9. AJPFX关于读取properties 配置文件 返回属性值

    :Properties的概述        * Properties 类表示了一个持久的属性集.        * Properties 可保存在流中或从流中加载.        * 属性列表中每个键 ...

  10. python的与或非运算

    真的很重要,栽了个跟头!!!(虽然以前好像知道...) print(True or False and False) print((True or False) and False) # True # ...